@@ -152,7 +152,7 @@ public function testHandleSocksConnectionWillEndOnInvalidData()
152152 $ connection ->emit ('data ' , array ('asdasdasdasdasd ' ));
153153 }
154154
155- public function testHandleSocksConnectionWillEstablishOutgoingConnection ()
155+ public function testHandleSocks4ConnectionWillEstablishOutgoingConnection ()
156156 {
157157 $ connection = $ this ->getMockBuilder ('React\Socket\Connection ' )->disableOriginalConstructor ()->setMethods (array ('pause ' , 'end ' ))->getMock ();
158158
@@ -165,6 +165,32 @@ public function testHandleSocksConnectionWillEstablishOutgoingConnection()
165165 $ connection ->emit ('data ' , array ("\x04\x01" . "\x00\x50" . pack ('N ' , ip2long ('127.0.0.1 ' )) . "\x00" ));
166166 }
167167
168+ public function testHandleSocks5ConnectionWillEstablishOutgoingConnection ()
169+ {
170+ $ connection = $ this ->getMockBuilder ('React\Socket\Connection ' )->disableOriginalConstructor ()->setMethods (array ('pause ' , 'end ' , 'write ' ))->getMock ();
171+
172+ $ promise = new Promise (function () { });
173+
174+ $ this ->connector ->expects ($ this ->once ())->method ('connect ' )->with ('127.0.0.1:80 ' )->willReturn ($ promise );
175+
176+ $ this ->server ->onConnection ($ connection );
177+
178+ $ connection ->emit ('data ' , array ("\x05\x01\x00" . "\x05\x01\x00\x01" . pack ('N ' , ip2long ('127.0.0.1 ' )) . "\x00\x50" ));
179+ }
180+
181+ public function testHandleSocks5ConnectionWithIpv6WillEstablishOutgoingConnection ()
182+ {
183+ $ connection = $ this ->getMockBuilder ('React\Socket\Connection ' )->disableOriginalConstructor ()->setMethods (array ('pause ' , 'end ' , 'write ' ))->getMock ();
184+
185+ $ promise = new Promise (function () { });
186+
187+ $ this ->connector ->expects ($ this ->once ())->method ('connect ' )->with ('[::1]:80 ' )->willReturn ($ promise );
188+
189+ $ this ->server ->onConnection ($ connection );
190+
191+ $ connection ->emit ('data ' , array ("\x05\x01\x00" . "\x05\x01\x00\x04" . inet_pton ('::1 ' ) . "\x00\x50" ));
192+ }
193+
168194 public function testHandleSocksConnectionWillCancelOutputConnectionIfIncomingCloses ()
169195 {
170196 $ connection = $ this ->getMockBuilder ('React\Socket\Connection ' )->disableOriginalConstructor ()->setMethods (array ('pause ' , 'end ' ))->getMock ();
0 commit comments