pinokiod 3.8.66 → 3.8.68
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/peer.js +13 -6
- package/kernel/router/index.js +7 -3
- package/package.json +1 -1
package/kernel/peer.js
CHANGED
|
@@ -35,10 +35,15 @@ class PeerDiscovery {
|
|
|
35
35
|
}, this.interval);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
_refresh(host) {
|
|
39
|
-
|
|
38
|
+
async _refresh(host) {
|
|
39
|
+
try {
|
|
40
|
+
let res = await axios.get(`http://${host}:${this.default_port}/pinokio/peer`, {
|
|
41
|
+
timeout: 2000
|
|
42
|
+
})
|
|
40
43
|
return res.data
|
|
41
|
-
})
|
|
44
|
+
} catch (e) {
|
|
45
|
+
return null
|
|
46
|
+
}
|
|
42
47
|
}
|
|
43
48
|
async refresh() {
|
|
44
49
|
this.info = {}
|
|
@@ -48,9 +53,11 @@ class PeerDiscovery {
|
|
|
48
53
|
console.log({ peer_info })
|
|
49
54
|
for(let i=0; i<peer_info.length; i++) {
|
|
50
55
|
let peer = peer_info[i]
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
if (peer) {
|
|
57
|
+
this.info[peer.host] = {
|
|
58
|
+
host: peer.host,
|
|
59
|
+
...peer
|
|
60
|
+
}
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
63
|
console.log("REFRESH", this.info)
|
package/kernel/router/index.js
CHANGED
|
@@ -23,6 +23,10 @@ class Router {
|
|
|
23
23
|
this.default_match = this.default_prefix + "." + this.default_suffix
|
|
24
24
|
this.default_port = "42000"
|
|
25
25
|
this.default_host = "127.0.0.1"
|
|
26
|
+
|
|
27
|
+
this._mapping = {}
|
|
28
|
+
this.port_mapping = {} // 127.0.0.1 => 192.168,..
|
|
29
|
+
this.local_network_mapping = {}
|
|
26
30
|
}
|
|
27
31
|
async add({ host, match, dial }) {
|
|
28
32
|
if (!this._mapping[host]) {
|
|
@@ -144,9 +148,9 @@ class Router {
|
|
|
144
148
|
}
|
|
145
149
|
|
|
146
150
|
async refresh() {
|
|
147
|
-
this._mapping = {}
|
|
148
|
-
this.port_mapping = {} // 127.0.0.1 => 192.168,..
|
|
149
|
-
this.local_network_mapping = {}
|
|
151
|
+
// this._mapping = {}
|
|
152
|
+
// this.port_mapping = {} // 127.0.0.1 => 192.168,..
|
|
153
|
+
// this.local_network_mapping = {}
|
|
150
154
|
|
|
151
155
|
// 1. Localhost handling
|
|
152
156
|
this.localhost_home_router.handle()
|