mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-31 10:31:36 +00:00
force ipv4 addresses for node 0.11+
This commit is contained in:
parent
62be68979b
commit
fe559e0db7
4
index.js
4
index.js
@ -23,6 +23,8 @@ var ACTIONS = { CONNECT: 0, ANNOUNCE: 1, SCRAPE: 2, ERROR: 3 }
|
|||||||
var EVENTS = { update: 0, completed: 1, started: 2, stopped: 3 }
|
var EVENTS = { update: 0, completed: 1, started: 2, stopped: 3 }
|
||||||
var MAX_UINT = 4294967295
|
var MAX_UINT = 4294967295
|
||||||
|
|
||||||
|
var REMOVE_IPV6_RE = /^::ffff:/
|
||||||
|
|
||||||
inherits(Tracker, EventEmitter)
|
inherits(Tracker, EventEmitter)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -579,7 +581,7 @@ Server.prototype._onHttpRequest = function (req, res) {
|
|||||||
if (s[0] === '/announce') {
|
if (s[0] === '/announce') {
|
||||||
var ip = self._trustProxy
|
var ip = self._trustProxy
|
||||||
? req.headers['x-forwarded-for'] || req.connection.remoteAddress
|
? req.headers['x-forwarded-for'] || req.connection.remoteAddress
|
||||||
: req.connection.remoteAddress
|
: req.connection.remoteAddress.replace(REMOVE_IPV6_RE, '') // force ipv4
|
||||||
var port = Number(params.port)
|
var port = Number(params.port)
|
||||||
var addr = ip + ':' + port
|
var addr = ip + ':' + port
|
||||||
var peerId = bytewiseDecodeURIComponent(params.peer_id).toString('utf8')
|
var peerId = bytewiseDecodeURIComponent(params.peer_id).toString('utf8')
|
||||||
|
Loading…
Reference in New Issue
Block a user