diff --git a/lib/node.js b/lib/node.js index 066bf1f..10d0b28 100644 --- a/lib/node.js +++ b/lib/node.js @@ -10,9 +10,12 @@ class Node extends EventEmitter { hash = null; name = null; readyPromise = null; + port = null; + identity; constructor(identity) { super(); + this.identity = identity; this.hash = md5(identity.publicKey); this.name = `valnet node - ${this.hash}`; // stp.createServer({ @@ -45,13 +48,17 @@ class Node extends EventEmitter { if(takenPorts.indexOf(port) === -1) { console.log('registering to port ' + port); await upnp.mapIndefinite(port, this.name); + this.port = port; break; } else { console.log('port ' + port + ' is taken...'); } } - + stp.createServer(this.identity, (connection) => { + console.log('incomming connection...'); + console.dir(connection); + }) // console.log(mappings, this.hash); } diff --git a/relay/index.js b/relay/index.js index 3a537a1..6be4544 100644 --- a/relay/index.js +++ b/relay/index.js @@ -21,10 +21,13 @@ const node = new Node(identity); function connectNetwork(t = 1000) { if(t > 60000) t /= 2; + const poopoo = config.endpoints[0].split(':'); + console.log(poopoo); + const client = stp.connect({ identity, - port: config.endpoints[0].split(':')[1], - ip: config.endpoints[0].split(':')[0] + port: parseInt(poopoo[1]), + ip: poopoo[0] }); client.on('ready', () => { log.success('connected to relay!');