actually start a server, idk

canary
Marcus 2021-04-01 01:19:00 -04:00
parent d3c33cd113
commit dc25be448b
2 changed files with 13 additions and 3 deletions

View File

@ -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);
}

View File

@ -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!');