pinokiod 3.18.2 → 3.18.3
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/index.js
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const Common = require('./common')
|
|
3
|
+
const Processor = require('./processor')
|
|
4
|
+
class CustomDomainRouter extends Processor {
|
|
5
|
+
constructor(router) {
|
|
6
|
+
super()
|
|
7
|
+
this.router = router
|
|
8
|
+
this.common = new Common(router)
|
|
9
|
+
}
|
|
10
|
+
handle (peer) {
|
|
11
|
+
console.log("CustomDomainRouter", peer)
|
|
12
|
+
for(let domain in this.router.custom_domains) {
|
|
13
|
+
let port = this.router.custom_domains[domain]
|
|
14
|
+
this.common.handle({
|
|
15
|
+
match: `${domain}.localhost`,
|
|
16
|
+
dial: `127.0.0.1:${port}`,
|
|
17
|
+
host: this.router.kernel.peer.host,
|
|
18
|
+
})
|
|
19
|
+
/*
|
|
20
|
+
this.common.handle({
|
|
21
|
+
match: `${domain}.${peer.name}.localhost`,
|
|
22
|
+
dial: `${peer.host}:${port"127.0.0.1",
|
|
23
|
+
host: this.router.kernel.peer.host,
|
|
24
|
+
})
|
|
25
|
+
*/
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
module.exports = CustomDomainRouter
|
package/kernel/router/index.js
CHANGED
|
@@ -9,6 +9,7 @@ const PeerHomeRouter = require('./peer_home_router')
|
|
|
9
9
|
const PeerVariableRouter = require('./peer_variable_router')
|
|
10
10
|
const PeerPortRouter = require('./peer_port_router')
|
|
11
11
|
const PeerPeerRouter = require('./peer_peer_router')
|
|
12
|
+
const CustomDomainRouter = require('./custom_domain_router')
|
|
12
13
|
const Environment = require("../environment")
|
|
13
14
|
class Router {
|
|
14
15
|
constructor(kernel) {
|
|
@@ -20,6 +21,7 @@ class Router {
|
|
|
20
21
|
this.peer_variable_router = new PeerVariableRouter(this)
|
|
21
22
|
this.peer_port_router = new PeerPortRouter(this)
|
|
22
23
|
this.peer_peer_router = new PeerPeerRouter(this)
|
|
24
|
+
this.custom_domain_router = new CustomDomainRouter(this)
|
|
23
25
|
this.default_prefix = "pinokio"
|
|
24
26
|
this.default_suffix = "localhost"
|
|
25
27
|
this.default_match = this.default_prefix + "." + this.default_suffix
|
|
@@ -55,18 +57,41 @@ class Router {
|
|
|
55
57
|
|
|
56
58
|
// create a custom_map that maps port to custom router declarations
|
|
57
59
|
/*
|
|
60
|
+
|
|
58
61
|
custom_routers = {
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
ports: {
|
|
63
|
+
PORT1: <caddy handler>,
|
|
64
|
+
PORT2: <caddy handler>,
|
|
65
|
+
}
|
|
66
|
+
...
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
custom_domains = {
|
|
70
|
+
domains: {
|
|
71
|
+
NAME1: PORT1,
|
|
72
|
+
NAME2: PORT2,
|
|
73
|
+
...
|
|
74
|
+
}
|
|
61
75
|
...
|
|
62
76
|
}
|
|
77
|
+
|
|
63
78
|
*/
|
|
64
79
|
this.custom_routers = {}
|
|
80
|
+
this.custom_domains = {}
|
|
65
81
|
for(let router_path of router_paths) {
|
|
66
82
|
let router_abs_path = this.kernel.path("network", router_path)
|
|
67
83
|
let config = await this.kernel.require(router_abs_path)
|
|
68
|
-
|
|
69
|
-
|
|
84
|
+
if (config.ports) {
|
|
85
|
+
let ports = config.ports
|
|
86
|
+
for(let key in ports) {
|
|
87
|
+
this.custom_routers[key] = ports[key]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (config.domains) {
|
|
91
|
+
let domains = config.domains
|
|
92
|
+
for(let key in domains) {
|
|
93
|
+
this.custom_domains[key] = domains[key]
|
|
94
|
+
}
|
|
70
95
|
}
|
|
71
96
|
}
|
|
72
97
|
|
|
@@ -181,6 +206,7 @@ class Router {
|
|
|
181
206
|
if (this.kernel.peer.active) {
|
|
182
207
|
for(let host in this.kernel.peer.info) {
|
|
183
208
|
let peer = this.kernel.peer.info[host]
|
|
209
|
+
console.log(">>>>>>>>>>>>>>>>PEER", peer)
|
|
184
210
|
if (peer.host === this.kernel.peer.host) {
|
|
185
211
|
this.peer_home_router.handle(peer)
|
|
186
212
|
this.peer_variable_router.handle(peer)
|
|
@@ -204,6 +230,14 @@ class Router {
|
|
|
204
230
|
this.mapping = this._mapping
|
|
205
231
|
this.info = this._info()
|
|
206
232
|
}
|
|
233
|
+
async custom_domain() {
|
|
234
|
+
for(let host in this.kernel.peer.info) {
|
|
235
|
+
let peer = this.kernel.peer.info[host]
|
|
236
|
+
this.custom_domain_router.handle(peer)
|
|
237
|
+
}
|
|
238
|
+
//await this.fill()
|
|
239
|
+
this.mapping = this._mapping
|
|
240
|
+
}
|
|
207
241
|
|
|
208
242
|
// update caddy config
|
|
209
243
|
async update() {
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -2490,12 +2490,15 @@ class Server {
|
|
|
2490
2490
|
await fse.remove(p)
|
|
2491
2491
|
console.log(`[DONE] reset ${p}`)
|
|
2492
2492
|
|
|
2493
|
-
let p2 = path.resolve(home, "prototype")
|
|
2493
|
+
let p2 = path.resolve(home, "prototype/system")
|
|
2494
2494
|
await fse.remove(p2)
|
|
2495
2495
|
|
|
2496
2496
|
let p3 = path.resolve(home, "plugin")
|
|
2497
2497
|
await fse.remove(p3)
|
|
2498
2498
|
|
|
2499
|
+
let p4 = path.resolve(home, "network/system")
|
|
2500
|
+
await fse.remove(p4)
|
|
2501
|
+
|
|
2499
2502
|
let gitconfig = path.resolve(home, "gitconfig")
|
|
2500
2503
|
await fse.remove(gitconfig)
|
|
2501
2504
|
|