bittorrent-relay
Advanced tools
Comparing version 3.0.3 to 3.0.4
33
index.js
@@ -33,3 +33,4 @@ import Debug from 'debug' | ||
* @param {Number} opts.trackerPort port used for the tracker | ||
* @param {String} opts.address address used for the dht and the tracker | ||
* @param {Number} opts.dhtHost port used for the dht | ||
* @param {Number} opts.trackerHost port used for the tracker | ||
* @param {String} opts.host host used for server | ||
@@ -65,3 +66,4 @@ * @param {Number} opts.port port used for server | ||
this.TRACKERPORT = opts.trackerPort || 16969 | ||
this.ADDRESS = opts.address || '0.0.0.0' | ||
this.DHTHOST = opts.dhtHost || '0.0.0.0' | ||
this.TRACKERHOST = opts.trackerHost || '0.0.0.0' | ||
this.host = opts.host | ||
@@ -88,4 +90,4 @@ if(!this.host){ | ||
} | ||
this.dht = {host: this.ADDRESS, port: this.DHTPORT} | ||
this.tracker = {host: this.ADDRESS, port: this.TRACKERPORT} | ||
this.dht = {host: this.DHTHOST, port: this.DHTPORT} | ||
this.tracker = {host: this.TRACKERHOST, port: this.TRACKERPORT} | ||
this.id = crypto.createHash('sha1').update(this.host + ':' + this.port).digest('hex') | ||
@@ -108,3 +110,3 @@ this.web = `ws://${this.domain || this.host}:${this.port}` | ||
if(self.trackers[socket].readyState === 1){ | ||
self.trackers[socket].send(JSON.stringify({action: 'web', address: self.ADDRESS, tracker: self.tracker, dht: self.dht, domain: self.domain, host: self.host, port: self.port, web: self.web, id: self.id})) | ||
self.trackers[socket].send(JSON.stringify({action: 'web', tracker: self.tracker, dht: self.dht, domain: self.domain, host: self.host, port: self.port, web: self.web, id: self.id})) | ||
} | ||
@@ -313,5 +315,2 @@ } | ||
} | ||
this.ws.onClose = () => { | ||
self.emit('close', 'ws') | ||
} | ||
this.ws.onListening = () => { | ||
@@ -321,2 +320,6 @@ self.ws.listening = true | ||
} | ||
this.ws.onClose = () => { | ||
self.ws.listening = false | ||
self.emit('close', 'ws') | ||
} | ||
this.ws.on('listening', this.ws.onListening) | ||
@@ -331,3 +334,2 @@ this.ws.on('close', this.ws.onClose) | ||
this.relay.onListening = () => { | ||
self.dht = self.relay.address() | ||
self.emit('listening', 'relay') | ||
@@ -458,6 +460,6 @@ } | ||
if(!this.relay.listening){ | ||
this.relay.listen(this.DHTPORT, this.ADDRESS) | ||
this.relay.listen(this.DHTPORT, this.DHTHOST) | ||
} | ||
if(!this.http.listening){ | ||
this.http.listen(this.TRACKERPORT, this.ADDRESS) | ||
this.http.listen(this.TRACKERPORT, this.TRACKERHOST) | ||
} | ||
@@ -475,3 +477,3 @@ if(cb){ | ||
// this.http.on('close', this.http.onClose) | ||
this.http.listen(this.TRACKERPORT, this.ADDRESS) | ||
this.http.listen(this.TRACKERPORT, this.TRACKERHOST) | ||
} | ||
@@ -536,3 +538,3 @@ } | ||
self.trackers[socket.id] = socket | ||
socket.send(JSON.stringify({id: self.id, address: self.ADDRESS, tracker: self.tracker, web: self.web, host: self.host, port: self.port, dht: self.dht, domain: self.domain, relays: self.relays, hashes: self.hashes, action: 'session'})) | ||
socket.send(JSON.stringify({id: self.id, tracker: self.tracker, web: self.web, host: self.host, port: self.port, dht: self.dht, domain: self.domain, relays: self.relays, hashes: self.hashes, action: 'session'})) | ||
} | ||
@@ -552,3 +554,2 @@ socket.onError = function(err){ | ||
socket.tracker = message.tracker | ||
socket.address = message.address | ||
socket.port = message.port | ||
@@ -579,6 +580,6 @@ socket.host = message.host | ||
} | ||
if(socket.tracker.address !== message.tracker.address || socket.tracker.port !== message.tracker.port){ | ||
if(socket.tracker.host !== message.tracker.host || socket.tracker.port !== message.tracker.port){ | ||
socket.tracker = message.tracker | ||
} | ||
if(socket.dht.address !== message.dht.address || socket.dht.port !== message.dht.port){ | ||
if(socket.dht.host !== message.dht.host || socket.dht.port !== message.dht.port){ | ||
socket.dht = message.dht | ||
@@ -585,0 +586,0 @@ } |
{ | ||
"name": "bittorrent-relay", | ||
"description": "Uses the mainline dht to relay requests to other trackers in a swarm", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"bin": { | ||
@@ -6,0 +6,0 @@ "bittorrent-relay": "./bin/cmd.js" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47234
1246