pinokiod 3.8.152 → 3.8.153
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/kernel/loader.js +2 -2
- package/kernel/peer.js +16 -3
- package/package.json +1 -1
package/kernel/loader.js
CHANGED
|
@@ -43,14 +43,14 @@ class Loader {
|
|
|
43
43
|
async requireJSON(filepath) {
|
|
44
44
|
let config
|
|
45
45
|
try { config = require(filepath) } catch (e) {
|
|
46
|
-
console.log(e)
|
|
46
|
+
console.log("> load", e.message, filepath)
|
|
47
47
|
}
|
|
48
48
|
return config
|
|
49
49
|
}
|
|
50
50
|
async requireJS(filepath) {
|
|
51
51
|
let config
|
|
52
52
|
try { config = require(filepath) } catch (e) {
|
|
53
|
-
console.log(e)
|
|
53
|
+
console.log("> load", e.message, filepath)
|
|
54
54
|
}
|
|
55
55
|
try {
|
|
56
56
|
// if the required module is a class, return the instantiated object
|
package/kernel/peer.js
CHANGED
|
@@ -106,6 +106,7 @@ class PeerDiscovery {
|
|
|
106
106
|
}
|
|
107
107
|
// refresh peer info
|
|
108
108
|
async refresh(peers) {
|
|
109
|
+
console.log("*Refresh")
|
|
109
110
|
// if (this.active) {
|
|
110
111
|
this.refreshing = true
|
|
111
112
|
let refresh_peers
|
|
@@ -118,6 +119,7 @@ class PeerDiscovery {
|
|
|
118
119
|
let peer_info = await Promise.all(refresh_peers.map((host) => {
|
|
119
120
|
return this._refresh(host)
|
|
120
121
|
}))
|
|
122
|
+
console.log("*Peer.refresh", { peer_info })
|
|
121
123
|
for(let i=0; i<peer_info.length; i++) {
|
|
122
124
|
let peer = peer_info[i]
|
|
123
125
|
if (peer) {
|
|
@@ -132,18 +134,29 @@ class PeerDiscovery {
|
|
|
132
134
|
// }
|
|
133
135
|
}
|
|
134
136
|
_isLocalLAN(ip) {
|
|
135
|
-
return ip.startsWith('192.168.');
|
|
137
|
+
return ip.startsWith('192.168.') || ip.startsWith('10.') || (ip.startsWith('172.') && is172Private(ip));
|
|
136
138
|
}
|
|
137
139
|
_getLocalIPAddress() {
|
|
138
140
|
const interfaces = os.networkInterfaces();
|
|
139
141
|
for (const ifaceList of Object.values(interfaces)) {
|
|
140
142
|
for (const iface of ifaceList) {
|
|
141
|
-
if (iface.family === 'IPv4' && !iface.internal
|
|
142
|
-
|
|
143
|
+
if (iface.family === 'IPv4' && !iface.internal) {
|
|
144
|
+
const ip = iface.address;
|
|
145
|
+
if (
|
|
146
|
+
ip.startsWith('10.') ||
|
|
147
|
+
ip.startsWith('192.168.') ||
|
|
148
|
+
(ip.startsWith('172.') && is172Private(ip))
|
|
149
|
+
) {
|
|
150
|
+
return ip;
|
|
151
|
+
}
|
|
143
152
|
}
|
|
144
153
|
}
|
|
145
154
|
}
|
|
146
155
|
return null;
|
|
156
|
+
function is172Private(ip) {
|
|
157
|
+
const secondOctet = parseInt(ip.split('.')[1], 10);
|
|
158
|
+
return secondOctet >= 16 && secondOctet <= 31;
|
|
159
|
+
}
|
|
147
160
|
}
|
|
148
161
|
}
|
|
149
162
|
|