pinokiod 3.8.58 → 3.8.60
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/router/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const LocalhostPortRouter = require('./localhost_port_router')
|
|
|
7
7
|
const PeerHomeRouter = require('./peer_home_router')
|
|
8
8
|
const PeerVariableRouter = require('./peer_variable_router')
|
|
9
9
|
const PeerPortRouter = require('./peer_port_router')
|
|
10
|
+
const PeerPeerRouter = require('./peer_peer_router')
|
|
10
11
|
class Router {
|
|
11
12
|
constructor(kernel) {
|
|
12
13
|
this.kernel = kernel
|
|
@@ -16,12 +17,12 @@ class Router {
|
|
|
16
17
|
this.peer_home_router = new PeerHomeRouter(this)
|
|
17
18
|
this.peer_variable_router = new PeerVariableRouter(this)
|
|
18
19
|
this.peer_port_router = new PeerPortRouter(this)
|
|
20
|
+
this.peer_peer_router = new PeerPeerRouter(this)
|
|
19
21
|
this.default_prefix = "pinokio"
|
|
20
22
|
this.default_suffix = "localhost"
|
|
21
23
|
this.default_match = this.default_prefix + "." + this.default_suffix
|
|
22
24
|
this.default_port = "42000"
|
|
23
25
|
this.default_host = "127.0.0.1"
|
|
24
|
-
this.config
|
|
25
26
|
}
|
|
26
27
|
async add({ host, match, dial }) {
|
|
27
28
|
if (!this._mapping[host]) {
|
|
@@ -45,6 +46,25 @@ class Router {
|
|
|
45
46
|
}
|
|
46
47
|
return mapping
|
|
47
48
|
}
|
|
49
|
+
published() {
|
|
50
|
+
let info = this.info()
|
|
51
|
+
let pub = {}
|
|
52
|
+
for(let host in info) {
|
|
53
|
+
let routes = info[host]
|
|
54
|
+
pub[host] = {}
|
|
55
|
+
for(let dial in routes) {
|
|
56
|
+
let matches = routes[dial]
|
|
57
|
+
let exposed_matches = matches.filter((m) => {
|
|
58
|
+
return m.endsWith(`${this.kernel.peer.name}.localhost`)
|
|
59
|
+
})
|
|
60
|
+
let port = dial.split(":")[1]
|
|
61
|
+
let exposed_port = this.port_mapping[`${port}`]
|
|
62
|
+
let exposed_dial = `${this.kernel.peer.host}:${exposed_port}` // exposed_dial :- 192.168...
|
|
63
|
+
pub[host][exposed_dial] = exposed_matches
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return pub
|
|
67
|
+
}
|
|
48
68
|
async fill() {
|
|
49
69
|
const jsonString = JSON.stringify(this.config)
|
|
50
70
|
// find all PORT_PLACEHOLDER patterns
|
|
@@ -116,9 +136,13 @@ class Router {
|
|
|
116
136
|
console.log(">3", { peers })
|
|
117
137
|
for(let host in peers) {
|
|
118
138
|
let peer = peers[host]
|
|
119
|
-
this.
|
|
120
|
-
|
|
121
|
-
|
|
139
|
+
if (peer.host === this.kernel.peer.host) {
|
|
140
|
+
this.peer_home_router.handle(peer)
|
|
141
|
+
this.peer_variable_router.handle(peer)
|
|
142
|
+
this.peer_port_router.handle(peer)
|
|
143
|
+
} else {
|
|
144
|
+
this.peer_peer_router.handle(peer)
|
|
145
|
+
}
|
|
122
146
|
}
|
|
123
147
|
// replace :PORT_PLACEHOLDER with available ports
|
|
124
148
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const Common = require('./common')
|
|
2
|
+
class PeerPeerRouter {
|
|
3
|
+
constructor(router) {
|
|
4
|
+
this.router = router
|
|
5
|
+
this.common = new Common(router)
|
|
6
|
+
}
|
|
7
|
+
handle(peer) {
|
|
8
|
+
let routes = peer.router[peer.host]
|
|
9
|
+
for(let dial in routes) {
|
|
10
|
+
let matches = routes[dial]
|
|
11
|
+
let exposed_matches = matches.filter((m) => {
|
|
12
|
+
return m.endsWith(`${peer.name}.localhost`)
|
|
13
|
+
})
|
|
14
|
+
let port = dial.split(":")[1]
|
|
15
|
+
let exposed_dial = `${peer.host}:${port}` // exposed_dial :- 192.168...
|
|
16
|
+
for(let match of exposed_matches) {
|
|
17
|
+
console.log("common.handle", { match, exposed_dial, host: peer.host })
|
|
18
|
+
this.common.handle({
|
|
19
|
+
match,
|
|
20
|
+
dial: exposed_dial,
|
|
21
|
+
host: peer.host
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
module.exports = PeerPeerRouter
|
|
@@ -8,7 +8,7 @@ class PeerVariableRouter extends Processor {
|
|
|
8
8
|
this.connector = new Connector(router)
|
|
9
9
|
}
|
|
10
10
|
handle(peer) {
|
|
11
|
-
console.log("PeerVariableRouter", peer)
|
|
11
|
+
console.log("PeerVariableRouter", JSON.stringify(peer, null, 2))
|
|
12
12
|
for(let script_path in peer.memory.local) {
|
|
13
13
|
let local_variables = peer.memory.local[script_path]
|
|
14
14
|
for(let key in local_variables) {
|
|
@@ -9,12 +9,13 @@ class Processor {
|
|
|
9
9
|
let api_path
|
|
10
10
|
let rel_path
|
|
11
11
|
let name
|
|
12
|
+
let _path
|
|
12
13
|
if (platform === 'win32') {
|
|
13
|
-
|
|
14
|
+
_path = path.win32
|
|
14
15
|
api_path = _path.resolve(home, "api")
|
|
15
16
|
rel_path = _path.relative(api_path, str)
|
|
16
17
|
} else {
|
|
17
|
-
|
|
18
|
+
_path = path.posix
|
|
18
19
|
api_path = _path.resolve(home, "api")
|
|
19
20
|
rel_path = _path.relative(api_path, str)
|
|
20
21
|
}
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -3264,7 +3264,8 @@ class Server {
|
|
|
3264
3264
|
platform: this.kernel.platform,
|
|
3265
3265
|
name: this.kernel.peer.name,
|
|
3266
3266
|
host: this.kernel.peer.host,
|
|
3267
|
-
router: this.kernel.router.info(),
|
|
3267
|
+
//router: this.kernel.router.info(),
|
|
3268
|
+
router: this.kernel.router.published(),
|
|
3268
3269
|
memory: this.kernel.memory
|
|
3269
3270
|
})
|
|
3270
3271
|
}))
|