relay-to-relay
Advanced tools
Comparing version 1.0.5 to 1.0.6
{ | ||
"name": "relay-to-relay", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -22,3 +22,2 @@ import Events from 'events' | ||
* @param {Boolean} opts.init automatically start once instantiated | ||
* @param {Boolean} opts.relay if automatically started, this also start the dht listener for connections | ||
* @param {String} opts.server ip of the server | ||
@@ -41,7 +40,13 @@ * @param {Boolean} opts.ws options for WebSocket Server | ||
this.dev = Boolean(opts.dev) | ||
this.useInit = opts.init === false ? opts.init : true | ||
this.useRelay = opts.relay === true ? opts.relay : false | ||
this.init = opts.init === false ? opts.init : true | ||
this.limit = typeof(opts.limit) === 'object' && !Array.isArray(opts.limit) ? opts.limit : {} | ||
this.limit.serverConnections = this.limit.serverConnections || 0 | ||
this.limit.clientConnections = this.limit.clientConnections || 0 | ||
this.timer = typeof(opts.timer) === 'object' && !Array.isArray(opts.timer) ? opts.timer : {} | ||
this.timer.webOne = this.timer.webOne || 45000 | ||
this.timer.webTwo = this.timer.webTwo || 30000 | ||
this.timer.webThree = this.timer.webThree || 45000 | ||
this.timer.check = this.timer.check || 60000 | ||
this.timer.talking = this.timer.talking || 1800000 | ||
this.timer.redo = this.timer.redo || 300000 | ||
this.http = null | ||
@@ -103,3 +108,3 @@ this.ws = null | ||
this.emit('stop', 'http') | ||
setTimeout(() => {this.http.listen(this.port, this.host)}, 300000) | ||
setTimeout(() => {this.http.listen(this.port, this.host)}, this.timer.redo) | ||
} | ||
@@ -307,4 +312,4 @@ // this.http.handleListeners = () => { | ||
} | ||
if(this.useInit){ | ||
this.start(this.useRelay) | ||
if(this.init){ | ||
this.start() | ||
} | ||
@@ -626,6 +631,4 @@ } | ||
this.relay.on('close', this.relay.onClose) | ||
if(this.useRelay){ | ||
if(!this.relay.listening){ | ||
this.relay.listen(this.port, this.server) | ||
} | ||
if(!this.relay.listening){ | ||
this.relay.listen(this.port, this.server) | ||
} | ||
@@ -664,3 +667,3 @@ this.ws.on('listening', this.ws.onListening) | ||
if(test.stamp){ | ||
if((Date.now() - test.stamp) > 45000){ | ||
if((Date.now() - test.stamp) > this.timer.webOne){ | ||
test.close() | ||
@@ -671,3 +674,3 @@ } | ||
if(test.stamp){ | ||
if((Date.now() - test.stamp) > 30000){ | ||
if((Date.now() - test.stamp) > this.timer.webTwo){ | ||
test.close() | ||
@@ -678,3 +681,3 @@ } | ||
if(test.stamp){ | ||
if((Date.now() - test.stamp) > 45000){ | ||
if((Date.now() - test.stamp) > this.timer.webThree){ | ||
test.close() | ||
@@ -687,3 +690,3 @@ } | ||
} | ||
}, 60000) | ||
}, this.timer.check) | ||
} | ||
@@ -694,3 +697,3 @@ | ||
if(!this.talking){ | ||
this.talking = setInterval(() => {this.talk()}, 1800000) | ||
this.talking = setInterval(() => {this.talk()}, this.timer.talking) | ||
} | ||
@@ -715,6 +718,4 @@ } | ||
this.relay.off('close', this.relay.onClose) | ||
if(this.useRelay){ | ||
if(this.relay.listening){ | ||
this.relay.destroy() | ||
} | ||
if(this.relay.listening){ | ||
this.relay.destroy() | ||
} | ||
@@ -721,0 +722,0 @@ if(this.check){ |
60628
1565