pinokiod 3.8.34 → 3.8.35
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/caddy.js +24 -23
- package/package.json +1 -1
package/kernel/caddy.js
CHANGED
|
@@ -37,10 +37,10 @@ class Caddy {
|
|
|
37
37
|
let internal_ip = "127.0.0.1:42000"
|
|
38
38
|
let namespaced_url = "pinokio.localhost"
|
|
39
39
|
|
|
40
|
-
if (!this.
|
|
41
|
-
this.
|
|
40
|
+
if (!this._mapping[internal_ip]) {
|
|
41
|
+
this._mapping[internal_ip] = new Set()
|
|
42
42
|
}
|
|
43
|
-
this.
|
|
43
|
+
this._mapping[internal_ip].add(namespaced_url)
|
|
44
44
|
|
|
45
45
|
return {
|
|
46
46
|
"apps": {
|
|
@@ -161,10 +161,10 @@ class Caddy {
|
|
|
161
161
|
// proxy proxy => proxy
|
|
162
162
|
if (key === "url") {
|
|
163
163
|
let namespaced_url = `${name}.${account}.localhost`.toLowerCase()
|
|
164
|
-
if (!this.
|
|
165
|
-
this.
|
|
164
|
+
if (!this._mapping[internal_ip]) {
|
|
165
|
+
this._mapping[internal_ip] = new Set()
|
|
166
166
|
}
|
|
167
|
-
this.
|
|
167
|
+
this._mapping[internal_ip].add(namespaced_url)
|
|
168
168
|
payload.apps.http.servers.main.routes.push({
|
|
169
169
|
"match": [{
|
|
170
170
|
"host": [namespaced_url]
|
|
@@ -189,10 +189,10 @@ class Caddy {
|
|
|
189
189
|
})
|
|
190
190
|
}
|
|
191
191
|
let namespaced_url = `${name}.${account}.localhost`.toLowerCase()
|
|
192
|
-
if (!this.
|
|
193
|
-
this.
|
|
192
|
+
if (!this._mapping[internal_ip]) {
|
|
193
|
+
this._mapping[internal_ip] = new Set()
|
|
194
194
|
}
|
|
195
|
-
this.
|
|
195
|
+
this._mapping[internal_ip].add(namespaced_url)
|
|
196
196
|
payload.apps.http.servers.main.routes.push({
|
|
197
197
|
"match": [{
|
|
198
198
|
"host": [namespaced_url],
|
|
@@ -247,10 +247,10 @@ class Caddy {
|
|
|
247
247
|
if (chunks.length === 2) {
|
|
248
248
|
if (key === "url") {
|
|
249
249
|
let url = `${name}.localhost`.toLowerCase()
|
|
250
|
-
if (!this.
|
|
251
|
-
this.
|
|
250
|
+
if (!this._mapping[val]) {
|
|
251
|
+
this._mapping[val] = new Set()
|
|
252
252
|
}
|
|
253
|
-
this.
|
|
253
|
+
this._mapping[val].add(url)
|
|
254
254
|
payload.apps.http.servers.main.routes.push({
|
|
255
255
|
"match": [{
|
|
256
256
|
"host": [url]
|
|
@@ -365,13 +365,13 @@ class Caddy {
|
|
|
365
365
|
namespaced_url = chunks.join(".")
|
|
366
366
|
}
|
|
367
367
|
console.log("##x", { chunks, namespaced_url, https_domain })
|
|
368
|
-
if (!this.
|
|
369
|
-
this.
|
|
368
|
+
if (!this._mapping[internal_ip]) {
|
|
369
|
+
this._mapping[internal_ip] = new Set()
|
|
370
370
|
}
|
|
371
|
-
console.log("this.mapping", this.
|
|
371
|
+
console.log("this.mapping", this._mapping)
|
|
372
372
|
console.log("internal_ip", internal_ip)
|
|
373
|
-
console.log("result", this.
|
|
374
|
-
this.
|
|
373
|
+
console.log("result", this._mapping[internal_ip])
|
|
374
|
+
this._mapping[internal_ip].add(namespaced_url)
|
|
375
375
|
console.log({ namespaced_url, https_domain, internal_ip })
|
|
376
376
|
// 1. point proxy URL to the 127.0.0.1:EXPOSED_PORT
|
|
377
377
|
payload.apps.http.servers.main.routes.push({
|
|
@@ -409,10 +409,10 @@ class Caddy {
|
|
|
409
409
|
}
|
|
410
410
|
for(let item of list) {
|
|
411
411
|
let url = `${item.port}.localhost`
|
|
412
|
-
if (!this.
|
|
413
|
-
this.
|
|
412
|
+
if (!this._mapping[item.ip]) {
|
|
413
|
+
this._mapping[item.ip] = new Set()
|
|
414
414
|
}
|
|
415
|
-
this.
|
|
415
|
+
this._mapping[item.ip].add(url)
|
|
416
416
|
payload.apps.http.servers.main.routes.push({
|
|
417
417
|
"match": [{
|
|
418
418
|
"host": [url],
|
|
@@ -455,7 +455,7 @@ class Caddy {
|
|
|
455
455
|
console.log("Caddy Response", { response })
|
|
456
456
|
}
|
|
457
457
|
async payload () {
|
|
458
|
-
this.
|
|
458
|
+
this._mapping = {}
|
|
459
459
|
this.ip_mapping = {}
|
|
460
460
|
this.port_mapping = {} // 127.0.0.1 => 192.168,..
|
|
461
461
|
|
|
@@ -492,8 +492,9 @@ class Caddy {
|
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
-
|
|
496
|
-
|
|
495
|
+
this.mapping = {}
|
|
496
|
+
for(let key in this._mapping) {
|
|
497
|
+
this.mapping[key] = Array.from(this._mapping[key])
|
|
497
498
|
}
|
|
498
499
|
|
|
499
500
|
|