mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-31 10:31:36 +00:00
Merge pull request #17 from fisch0920/master
small bugfix for erroneous trackers
This commit is contained in:
commit
7d880680ab
10
index.js
10
index.js
@ -151,7 +151,7 @@ Tracker.prototype._requestHttp = function (requestUrl, opts) {
|
|||||||
var data = ''
|
var data = ''
|
||||||
if (res.statusCode !== 200) {
|
if (res.statusCode !== 200) {
|
||||||
res.resume() // consume the whole stream
|
res.resume() // consume the whole stream
|
||||||
self.client.emit('error', new Error('Invalid response code ' + res.statusCode + ' from tracker'))
|
self.client.emit('error', new Error('Invalid response code ' + res.statusCode + ' from tracker ' + requestUrl))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
res.on('data', function (chunk) {
|
res.on('data', function (chunk) {
|
||||||
@ -182,14 +182,12 @@ Tracker.prototype._requestUdp = function (requestUrl, opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function error (message) {
|
function error (message) {
|
||||||
self.client.emit('error', new Error(message))
|
self.client.emit('error', new Error(message + ' (connecting to tracker ' + requestUrl + ')'))
|
||||||
socket.close()
|
try { socket.close() } catch (e) { }
|
||||||
clearTimeout(timeout)
|
clearTimeout(timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.on('error', function (err) {
|
socket.on('error', error)
|
||||||
error(err)
|
|
||||||
})
|
|
||||||
|
|
||||||
socket.on('message', function (message, rinfo) {
|
socket.on('message', function (message, rinfo) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user