bittorrent-relay
Advanced tools
Comparing version 1.0.3 to 1.0.4
27
index.js
@@ -245,15 +245,12 @@ import Debug from 'debug' | ||
} | ||
} else if(req.method === 'GET' && req.url.startsWith('/i')){ | ||
const test = req.url.split('/').filter(Boolean) | ||
if(test.length === 1){ | ||
res.setHeader('Content-Type', 'application/json') | ||
res.end(JSON.stringify(this.sendTo)) | ||
} else if(test.length === 2){ | ||
res.setHeader('Content-Type', 'application/json') | ||
res.end(this.sendTo[test[1]] ? JSON.stringify(this.sendTo[test[1]]) : []) | ||
} else { | ||
throw new Error(`invalid action in HTTP request: ${req.url}`) | ||
} | ||
} else if(req.method === 'GET' && req.url === '/i'){ | ||
res.setHeader('Content-Type', 'application/json') | ||
res.end(JSON.stringify(this.sendTo)) | ||
} else if(req.method === 'GET' && req.url.startsWith('/i/')){ | ||
const test = req.url.replace('/i/', '') | ||
res.setHeader('Content-Type', 'application/json') | ||
res.end(this.sendTo[test] ? JSON.stringify(this.sendTo[test]) : JSON.stringify([])) | ||
} else { | ||
throw new Error(`invalid action in HTTP request: ${req.url}`) | ||
res.setHeader('Content-Type', 'application/json') | ||
res.end(JSON.stringify('error')) | ||
} | ||
@@ -428,5 +425,5 @@ } | ||
} | ||
self.trackers.forEach((data) => { | ||
data.send(JSON.stringify(self.status)) | ||
}) | ||
for(const track in self.trackers){ | ||
self.trackers[track].send(JSON.stringify({action: 'status', ...self.status})) | ||
} | ||
// send url of another tracker before closing server, if no tracker is available then close server | ||
@@ -433,0 +430,0 @@ } else { |
{ | ||
"name": "bittorrent-relay", | ||
"description": "Uses the mainline dht to relay requests to other trackers in a swarm", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"bin": { | ||
@@ -6,0 +6,0 @@ "bittorrent-tracker": "./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
46926
1243