File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,11 @@ var common = require('./common')
55var REMOVE_IPV4_MAPPED_IPV6_RE = / ^ : : f f f f : /
66
77function parseHttpRequest ( req , options ) {
8+ options = options || { }
89 var s = req . url . split ( '?' )
910 var params = common . querystringParse ( s [ 1 ] )
1011
11- if ( s [ 0 ] === '/announce' ) {
12+ if ( options . action === 'announce' || s [ 0 ] === '/announce' ) {
1213 params . action = common . ACTIONS . ANNOUNCE
1314
1415 if ( typeof params . info_hash !== 'string' || params . info_hash . length !== 20 )
@@ -32,7 +33,7 @@ function parseHttpRequest (req, options) {
3233 ? req . headers [ 'x-forwarded-for' ] || req . connection . remoteAddress
3334 : req . connection . remoteAddress . replace ( REMOVE_IPV4_MAPPED_IPV6_RE , '' ) // force ipv4
3435 params . addr = ( common . IPV6_RE . test ( params . ip ) ? '[' + params . ip + ']' : params . ip ) + ':' + params . port
35- } else if ( s [ 0 ] === '/scrape' ) {
36+ } else if ( options . action === 'scrape' || s [ 0 ] === '/scrape' ) {
3637 params . action = common . ACTIONS . SCRAPE
3738 if ( typeof params . info_hash === 'string' )
3839 params . info_hash = [ params . info_hash ]
Original file line number Diff line number Diff line change @@ -121,12 +121,14 @@ Server.prototype.getSwarm = function (infoHash) {
121121 return swarm
122122}
123123
124- Server . prototype . onHttpRequest = function ( req , res ) {
124+ Server . prototype . onHttpRequest = function ( req , res , options ) {
125125 var self = this
126+ options = options || { }
127+ options . trustProxy = options . trustProxy || self . _trustProxy
126128
127129 var params
128130 try {
129- params = parseHttpRequest ( req , { trustProxy : self . _trustProxy } )
131+ params = parseHttpRequest ( req , options )
130132 params . httpReq = req
131133 params . httpRes = res
132134 } catch ( err ) {
You can’t perform that action at this time.
0 commit comments