File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,11 +141,11 @@ public function connect($uri)
141141
142142 // append hostname from URI to query string unless explicitly given
143143 if (!isset ($ args ['hostname ' ])) {
144- $ args ['hostname ' ] = $ parts [ ' host ' ] ;
144+ $ args ['hostname ' ] = $ host ;
145145 }
146146
147147 // append query string
148- $ socksUri .= '? ' . http_build_query ($ args , '' , '& ' );;
148+ $ socksUri .= '? ' . http_build_query ($ args , '' , '& ' );
149149
150150 // append fragment from URI if given
151151 if (isset ($ parts ['fragment ' ])) {
Original file line number Diff line number Diff line change @@ -262,6 +262,24 @@ public function testEmitSocks5DataInvalidAddressTypeWillRejectConnection()
262262 $ promise ->then (null , $ this ->expectCallableOnceWithExceptionCode (SOCKET_EBADMSG ));
263263 }
264264
265+ public function testEmitSocks5DataIpv6AddressWillResolveConnection ()
266+ {
267+ $ stream = $ this ->getMockBuilder ('React\Socket\Connection ' )->disableOriginalConstructor ()->setMethods (array ('write ' , 'close ' ))->getMock ();
268+ $ stream ->expects ($ this ->never ())->method ('close ' );
269+
270+ $ promise = \React \Promise \resolve ($ stream );
271+
272+ $ this ->connector ->expects ($ this ->once ())->method ('connect ' )->with ('127.0.0.1:1080?hostname=%3A%3A1 ' )->willReturn ($ promise );
273+
274+ $ this ->client = new Client ('socks5://127.0.0.1:1080 ' , $ this ->connector );
275+
276+ $ promise = $ this ->client ->connect ('[::1]:80 ' );
277+
278+ $ stream ->emit ('data ' , array ("\x05\x00" . "\x05\x00\x00\x04" . inet_pton ('::1 ' ) . "\x00\x50" ));
279+
280+ $ promise ->then ($ this ->expectCallableOnce ());
281+ }
282+
265283 public function testEmitSocks5DataHostnameAddressWillResolveConnection ()
266284 {
267285 $ stream = $ this ->getMockBuilder ('React\Socket\Connection ' )->disableOriginalConstructor ()->setMethods (array ('write ' , 'close ' ))->getMock ();
You can’t perform that action at this time.
0 commit comments