pinokiod 3.8.63 → 3.8.65

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
@@ -199,7 +199,7 @@ class Kernel {
199
199
  return this.api.running[id]
200
200
  }
201
201
  start_port () {
202
- if (this.router.port_mapping && this.router.port_mapping.length > 0) {
202
+ if (this.router.port_mapping && Object.keys(this.router.port_mapping).length > 0) {
203
203
  let max_caddy_port = Math.max(Object.values(this.router.port_mapping))
204
204
  let start_port = Math.max(42003, max_caddy_port + 1)
205
205
  console.log({ start_port })
@@ -77,24 +77,12 @@ class Router {
77
77
  let info = this.info()
78
78
  console.log("published info", info)
79
79
  let pub = {}
80
- for(let host in info) {
81
- let routes = info[host]
82
- pub[host] = {}
83
- for(let dial in routes) {
84
- let matches = routes[dial]
85
- // current host => the single source of truth
86
- if (dial.startsWith(this.kernel.peer.host)) {
87
- pub[host][dial] = matches
88
- // let exposed_matches = matches.filter((m) => {
89
- // return m.endsWith(`${this.kernel.peer.name}.localhost`)
90
- // })
91
- // let port = dial.split(":")[1]
92
- // let exposed_port = this.port_mapping[`${port}`]
93
- // let exposed_dial = `${this.kernel.peer.host}:${exposed_port}` // exposed_dial :- 192.168...
94
- // pub[host][exposed_dial] = exposed_matches
95
- } else {
96
- pub[host][dial] = matches
97
- }
80
+ let routes = info[this.kernel.peer.host]
81
+ for(let dial in routes) {
82
+ let matches = routes[dial]
83
+ // current host => the single source of truth
84
+ if (dial.startsWith(this.kernel.peer.host)) {
85
+ pub[dial] = matches
98
86
  }
99
87
  }
100
88
  return pub
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.8.63",
3
+ "version": "3.8.65",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -2625,9 +2625,13 @@ class Server {
2625
2625
  await this.kernel.router.refresh()
2626
2626
  let list = await this.kernel.processes.refresh()
2627
2627
  list = list.map((item) => {
2628
+ let internal_port = item.ip.split(":")[1]
2629
+ let external_port = this.kernel.router.port_mapping[internal_port]
2630
+ let external_ip = `${this.kernel.peer.host}:${external_port}`
2631
+ console.log({ internal_port, external_port, external_ip })
2628
2632
  return {
2629
2633
  //proxy: this.kernel.caddy.mapping[item.ip] || [],
2630
- router: this.kernel.router.info()[this.kernel.peer.host][item.ip] || [],
2634
+ router: this.kernel.router.published()[external_ip] || [],
2631
2635
  ...item
2632
2636
  }
2633
2637
  })
@@ -2724,6 +2728,8 @@ class Server {
2724
2728
  }
2725
2729
  }
2726
2730
 
2731
+ console.log("LIST", JSON.stringify(list, null, 2))
2732
+
2727
2733
  res.render("proxy", {
2728
2734
  ip: this.kernel.peer.current_ip,
2729
2735
  peers,