pinokiod 3.8.61 → 3.8.63

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.
@@ -3,10 +3,13 @@ class Connector {
3
3
  this.router = router
4
4
  }
5
5
  handle ({ match, connector, dial, }) {
6
+ console.log("connector.handle", { match, connector, dial })
6
7
  let connector_name = connector.host + ":" + connector.port
8
+ let listener = "0.0.0.0:PORT_PLACEHOLDER_" + connector_name
9
+ let listener_pointer = connector.host + ":PORT_PLACEHOLDER_" + connector_name
7
10
  if(!this.router.config.apps.http.servers[connector_name]) {
8
11
  this.router.config.apps.http.servers[connector_name] = {
9
- "listen": ["0.0.0.0:PORT_PLACEHOLDER_" + connector_name],
12
+ "listen": [listener],
10
13
  "routes": [{
11
14
  "handle": [
12
15
  {
@@ -35,7 +38,7 @@ class Connector {
35
38
  "handle": [
36
39
  {
37
40
  "handler": "reverse_proxy",
38
- "upstreams": [{ "dial": connector.host + ":PORT_PLACEHOLDER_" + connector_name }]
41
+ "upstreams": [{ "dial": listener_pointer }]
39
42
  },
40
43
  {
41
44
  "handler": "headers",
@@ -50,7 +53,8 @@ class Connector {
50
53
  }
51
54
  ]
52
55
  })
53
- this.router.add({ host: connector.host, dial, match })
56
+ console.log("Router.add", { host: connector.host, dial: listener_pointer, match })
57
+ this.router.add({ host: connector.host, dial: listener_pointer, match })
54
58
  }
55
59
  }
56
60
  module.exports = Connector
@@ -32,8 +32,12 @@ class Router {
32
32
  this._mapping[host][dial] = new Set()
33
33
  }
34
34
  this._mapping[host][dial].add(match)
35
+ console.log(">this._mapping", this._mapping)
35
36
  }
36
37
  info() {
38
+ console.log("#### this._mapping", this._mapping)
39
+
40
+
37
41
  let mapping = {}
38
42
  for(let host in this._mapping) {
39
43
  let internal_maps = this._mapping[host]
@@ -44,23 +48,53 @@ class Router {
44
48
  mapping[host][url] = Array.from(internal_maps[url])
45
49
  }
46
50
  }
47
- return mapping
51
+
52
+ console.log("mapping", mapping)
53
+ let json = JSON.stringify(mapping)
54
+ for(let key in this.port_cache) {
55
+ console.log("replacing", key, "with", this.port_cache[key])
56
+ json = json.replaceAll(key, this.port_cache[key])
57
+ }
58
+ let m = JSON.parse(json)
59
+ console.log({ m })
60
+ return m
61
+ // return mapping
48
62
  }
63
+ /*
64
+ returns only the published peer info
65
+ {
66
+ <peer1 host>: {
67
+ <dial1>: [<match1>, <match2>, ..],
68
+ <dial2>: [<match1>, <match2>, ..],
69
+ },
70
+ <peer2 host>: {
71
+ <dial1>: [<match1>, <match2>, ..],
72
+ <dial2>: [<match1>, <match2>, ..],
73
+ },
74
+ }
75
+ */
49
76
  published() {
50
77
  let info = this.info()
78
+ console.log("published info", info)
51
79
  let pub = {}
52
80
  for(let host in info) {
53
81
  let routes = info[host]
54
82
  pub[host] = {}
55
83
  for(let dial in routes) {
56
84
  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
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
+ }
64
98
  }
65
99
  }
66
100
  return pub
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.8.61",
3
+ "version": "3.8.63",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {