@@ -442,6 +442,7 @@ function makeStreamParser(onMessage, onFlood, maxBytesHeaders, maxContentLength)
442442 maxContentLength = maxContentLength || 604800 ;
443443
444444 var m ;
445+ var p ;
445446 var r = '' ;
446447
447448 function headers ( data ) {
@@ -457,11 +458,16 @@ function makeStreamParser(onMessage, onFlood, maxBytesHeaders, maxContentLength)
457458
458459 }
459460
460- var a = r . match ( / ^ \s * ( [ \S \s ] * ?) \r \n \r \n ( [ \S \s ] * ) $ / ) ;
461-
462- if ( a ) {
463- r = a [ 2 ] ;
464- m = parse ( a [ 1 ] ) ;
461+ var a = r . match ( / ^ P R O X Y ( \S + ) ( \S + ) ( \S + ) ( \S + ) ( \S + ) \r \n ( [ \S \s ] * ) $ / ) ;
462+ if ( a ) {
463+ p = { 'protocol' : a [ 1 ] , 'source-address' : a [ 2 ] , 'destination-address' : a [ 3 ] , 'source-port' : a [ 4 ] , 'destination-port' : a [ 5 ] } ;
464+ r = a [ 6 ] ;
465+ }
466+
467+ var b = r . match ( / ^ \s * ( [ \S \s ] * ?) \r \n \r \n ( [ \S \s ] * ) $ / ) ;
468+ if ( b ) {
469+ r = b [ 2 ] ;
470+ m = parse ( b [ 1 ] ) ;
465471
466472 if ( m && m . headers [ 'content-length' ] !== undefined ) {
467473
@@ -487,7 +493,7 @@ function makeStreamParser(onMessage, onFlood, maxBytesHeaders, maxContentLength)
487493 if ( r . length >= m . headers [ 'content-length' ] ) {
488494 m . content = r . substring ( 0 , m . headers [ 'content-length' ] ) ;
489495
490- onMessage ( m ) ;
496+ onMessage ( m , p ) ;
491497
492498 var s = r . substring ( m . headers [ 'content-length' ] ) ;
493499 state = headers ;
@@ -548,12 +554,11 @@ function makeStreamTransport(protocol, maxBytesHeaders, maxContentLength, connec
548554 flows [ flowid ] = remotes [ remoteid ] ;
549555 }
550556
551- var onMessage = function ( m ) {
552-
557+ var onMessage = function ( m , p ) {
553558 if ( checkMessage ( m ) ) {
554559 if ( m . method ) m . headers . via [ 0 ] . params . received = remote . address ;
555560 callback ( m ,
556- { protocol : remote . protocol , address : stream . remoteAddress , port : stream . remotePort , local : { address : stream . localAddress , port : stream . localPort } } ,
561+ { protocol : remote . protocol , address : stream . remoteAddress , port : stream . remotePort , local : { address : stream . localAddress , port : stream . localPort } , proxy : p } ,
557562 stream ) ;
558563 }
559564
0 commit comments