|
1 | 1 | # clue/reactphp-socks [](https://travis-ci.org/clue/reactphp-socks) |
2 | 2 |
|
3 | | -Async SOCKS4, SOCKS4a and SOCKS5 proxy client and server implementation, built on top of [ReactPHP](http://reactphp.org). |
| 3 | +Async SOCKS proxy connector client and server implementation, use any TCP/IP-based |
| 4 | +protocol through a SOCKS5 or SOCKS4(a) proxy server, built on top of |
| 5 | +[ReactPHP](https://reactphp.org). |
4 | 6 |
|
5 | 7 | The SOCKS protocol family can be used to easily tunnel TCP connections independent |
6 | 8 | of the actual application level protocol, such as HTTP, SMTP, IMAP, Telnet etc. |
@@ -241,91 +243,91 @@ This works for both plain HTTP and SSL encrypted HTTPS requests. |
241 | 243 |
|
242 | 244 | #### Protocol version |
243 | 245 |
|
244 | | -This library supports the SOCKS4, SOCKS4a and SOCKS5 protocol versions. |
245 | | - |
246 | | -While SOCKS4 already had (a somewhat limited) support for `SOCKS BIND` requests |
247 | | -and SOCKS5 added generic UDP support (`SOCKS UDPASSOCIATE`), this library |
248 | | -focuses on the most commonly used core feature of `SOCKS CONNECT`. |
249 | | -In this mode, a SOCKS server acts as a generic proxy allowing higher level |
250 | | -application protocols to work through it. |
| 246 | +This library supports the SOCKS5 and SOCKS4(a) protocol versions. |
| 247 | +It focuses on the most commonly used core feature of connecting to a destination |
| 248 | +host through the SOCKS proxy server. In this mode, a SOCKS proxy server acts as |
| 249 | +a generic proxy allowing higher level application protocols to work through it. |
251 | 250 |
|
252 | 251 | <table> |
253 | 252 | <tr> |
254 | 253 | <th></th> |
255 | | - <th>SOCKS4</th> |
256 | | - <th>SOCKS4a</th> |
257 | 254 | <th>SOCKS5</th> |
| 255 | + <th>SOCKS4(a)</th> |
258 | 256 | </tr> |
259 | 257 | <tr> |
260 | 258 | <th>Protocol specification</th> |
261 | | - <td><a href="http://ftp.icm.edu.pl/packages/socks/socks4/SOCKS4.protocol">SOCKS4.protocol</a></td> |
262 | | - <td><a href="http://ftp.icm.edu.pl/packages/socks/socks4/SOCKS4A.protocol">SOCKS4A.protocol</a></td> |
263 | 259 | <td><a href="http://tools.ietf.org/html/rfc1928">RFC 1928</a></td> |
| 260 | + <td> |
| 261 | + <a href="http://ftp.icm.edu.pl/packages/socks/socks4/SOCKS4.protocol">SOCKS4.protocol</a> / |
| 262 | + <a href="http://ftp.icm.edu.pl/packages/socks/socks4/SOCKS4A.protocol">SOCKS4A.protocol</a> |
| 263 | + </td> |
264 | 264 | </tr> |
265 | 265 | <tr> |
266 | | - <th>Tunnel outgoing TCP connections</th> |
267 | | - <td>✓</td> |
| 266 | + <th>Tunnel outgoing TCP/IP connections</th> |
268 | 267 | <td>✓</td> |
269 | 268 | <td>✓</td> |
270 | 269 | </tr> |
271 | 270 | <tr> |
272 | | - <th><a href="#dns-resolution">Remote DNS resolving</a></th> |
273 | | - <td>✗</td> |
274 | | - <td>✓</td> |
| 271 | + <th><a href="#dns-resolution">Remote DNS resolution</a></th> |
275 | 272 | <td>✓</td> |
| 273 | + <td>✗ / ✓</td> |
276 | 274 | </tr> |
277 | 275 | <tr> |
278 | 276 | <th>IPv6 addresses</th> |
279 | | - <td>✗</td> |
280 | | - <td>✗</td> |
281 | 277 | <td>✓</td> |
| 278 | + <td>✗</td> |
282 | 279 | </tr> |
283 | 280 | <tr> |
284 | 281 | <th><a href="#authentication">Username/Password authentication</a></th> |
285 | | - <td>✗</td> |
286 | | - <td>✗</td> |
287 | 282 | <td>✓ (as per <a href="http://tools.ietf.org/html/rfc1929">RFC 1929</a>)</td> |
| 283 | + <td>✗</td> |
288 | 284 | </tr> |
289 | 285 | <tr> |
290 | 286 | <th>Handshake # roundtrips</th> |
291 | | - <td>1</td> |
292 | | - <td>1</td> |
293 | 287 | <td>2 (3 with authentication)</td> |
| 288 | + <td>1</td> |
294 | 289 | </tr> |
295 | 290 | <tr> |
296 | 291 | <th>Handshake traffic<br />+ remote DNS</th> |
297 | | - <td>17 bytes<br />✗</td> |
298 | | - <td>17 bytes<br />+ hostname + 1</td> |
299 | 292 | <td><em>variable</em> (+ auth + IPv6)<br />+ hostname - 3</td> |
| 293 | + <td>17 bytes<br />+ hostname + 1</td> |
| 294 | + </tr> |
| 295 | + <tr> |
| 296 | + <th>Incoming BIND requests</th> |
| 297 | + <td><em>not implemented</em></td> |
| 298 | + <td><em>not implemented</em></td> |
| 299 | + </tr> |
| 300 | + <tr> |
| 301 | + <th>UDP datagrams</th> |
| 302 | + <td><em>not implemented</em></td> |
| 303 | + <td>✗</td> |
| 304 | + </tr> |
| 305 | + <tr> |
| 306 | + <th>GSSAPI authentication</th> |
| 307 | + <td><em>not implemented</em></td> |
| 308 | + <td>✗</td> |
300 | 309 | </tr> |
301 | 310 | </table> |
302 | 311 |
|
303 | | -Note, this is __not__ a full SOCKS5 implementation due to missing GSSAPI |
304 | | -authentication (but it's unlikely you're going to miss it anyway). |
305 | | - |
306 | 312 | By default, the `Client` communicates via SOCKS5 with the SOCKS server. |
307 | 313 | This is done because SOCKS5 is the latest version from the SOCKS protocol family |
308 | 314 | and generally has best support across other vendors. |
309 | 315 |
|
310 | | -If want to explicitly set the protocol version, use the supported values URI |
311 | | -schemes `socks4://` or `socks4a://`as part of the SOCKS URI: |
| 316 | +If want to explicitly set the protocol version to SOCKS4(a), you can use the URI |
| 317 | +scheme `socks4://` as part of the SOCKS URI: |
312 | 318 |
|
313 | 319 | ```php |
314 | | -$client = new Client('socks4a://127.0.0.1', $connector); |
| 320 | +$client = new Client('socks4://127.0.0.1', $connector); |
315 | 321 | ``` |
316 | 322 |
|
317 | | -As seen above, both SOCKS5 and SOCKS4a support remote and local DNS resolution. |
318 | | -If you've explicitly set this to SOCKS4, then you may want to check the following |
319 | | -chapter about local DNS resolution or you may only connect to IPv4 addresses. |
320 | | - |
321 | 323 | #### DNS resolution |
322 | 324 |
|
323 | 325 | By default, the `Client` does not perform any DNS resolution at all and simply |
324 | 326 | forwards any hostname you're trying to connect to to the SOCKS server. |
325 | 327 | The remote SOCKS server is thus responsible for looking up any hostnames via DNS |
326 | 328 | (this default mode is thus called *remote DNS resolution*). |
327 | 329 | As seen above, this mode is supported by the SOCKS5 and SOCKS4a protocols, but |
328 | | -not the SOCKS4 protocol, as the protocol lacks a way to communicate hostnames. |
| 330 | +not the original SOCKS4 protocol, as the protocol lacks a way to communicate hostnames. |
329 | 331 |
|
330 | 332 | On the other hand, all SOCKS protocol versions support sending destination IP |
331 | 333 | addresses to the SOCKS server. |
@@ -372,12 +374,6 @@ as usual. |
372 | 374 | > Note how local DNS resolution is in fact entirely handled outside of this |
373 | 375 | SOCKS client implementation. |
374 | 376 |
|
375 | | -If you've explicitly set the client to SOCKS4 and stick to the default |
376 | | -*remote DNS resolution*, then you may only connect to IPv4 addresses because |
377 | | -the protocol lacks a way to communicate hostnames. |
378 | | -If you try to connect to a hostname despite, the resulting promise will be |
379 | | -rejected right away. |
380 | | - |
381 | 377 | #### Authentication |
382 | 378 |
|
383 | 379 | This library supports username/password authentication for SOCKS5 servers as |
@@ -668,9 +664,9 @@ requests for certain clients by providing a custom implementation of the |
668 | 664 |
|
669 | 665 | #### Server protocol version |
670 | 666 |
|
671 | | -The `Server` supports all protocol versions (SOCKS4, SOCKS4a and SOCKS5) by default. |
| 667 | +The `Server` supports the SOCKS5 and SOCKS4(a) protocol versions by default. |
672 | 668 |
|
673 | | -If want to explicitly set the protocol version, use the supported values `4`, `4a` or `5`: |
| 669 | +If want to explicitly set the protocol version, use the supported values `4`, or `5`: |
674 | 670 |
|
675 | 671 | ```PHP |
676 | 672 | $server->setProtocolVersion(5); |
@@ -925,7 +921,7 @@ $client = new Client('socks+unix:///tmp/proxy.sock', $connector); |
925 | 921 |
|
926 | 922 | The [Tor anonymity network](http://www.torproject.org) client software is designed |
927 | 923 | to encrypt your traffic and route it over a network of several nodes to conceal its origin. |
928 | | -It presents a SOCKS4 and SOCKS5 interface on TCP port 9050 by default |
| 924 | +It presents a SOCKS5 and SOCKS4(a) interface on TCP port 9050 by default |
929 | 925 | which allows you to tunnel any traffic through the anonymity network. |
930 | 926 | In most scenarios you probably don't want your client to resolve the target hostnames, |
931 | 927 | because you would leak DNS information to anybody observing your local traffic. |
@@ -984,7 +980,7 @@ MIT, see LICENSE |
984 | 980 | * If you want to learn more about processing streams of data, refer to the |
985 | 981 | documentation of the underlying |
986 | 982 | [react/stream](https://github.com/reactphp/stream) component. |
987 | | -* As an alternative to a SOCKS (SOCKS4/SOCKS5) proxy, you may also want to look into |
| 983 | +* As an alternative to a SOCKS5 / SOCKS4(a) proxy, you may also want to look into |
988 | 984 | using an HTTP CONNECT proxy instead. |
989 | 985 | You may want to use [clue/reactphp-http-proxy](https://github.com/clue/reactphp-http-proxy) |
990 | 986 | which also provides an implementation of the same |
|
0 commit comments