You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[http requests through a SOCKS server](https://github.com/clue/php-buzz-react/#via-socks-server).
67
+
This works for both plain HTTP and SSL encrypted HTTPS requests.
68
+
68
69
## SOCKS Protocol versions & differences
69
70
70
-
While SOCKS4 already had (a somewhat limited) support for `SOCKS BIND` requests and SOCKS5 added generic UDP support (`SOCKS UDPASSOCIATE`), this library focuses on the most commonly used core feature of `SOCKS CONNECT`. In this mode, a SOCKS server acts as a generic proxy allowing higher level application protocols to work through it.
71
+
While SOCKS4 already had (a somewhat limited) support for `SOCKS BIND` requests
72
+
and SOCKS5 added generic UDP support (`SOCKS UDPASSOCIATE`), this library
73
+
focuses on the most commonly used core feature of `SOCKS CONNECT`.
74
+
In this mode, a SOCKS server acts as a generic proxy allowing higher level
75
+
application protocols to work through it.
71
76
72
77
<table>
73
78
<tr>
@@ -120,14 +125,20 @@ While SOCKS4 already had (a somewhat limited) support for `SOCKS BIND` requests
120
125
</tr>
121
126
</table>
122
127
123
-
Note, this is __not__ a full SOCKS5 implementation due to missing GSSAPI authentication (but it's unlikely you're going to miss it anyway).
128
+
Note, this is __not__ a full SOCKS5 implementation due to missing GSSAPI
129
+
authentication (but it's unlikely you're going to miss it anyway).
124
130
125
131
### Explicitly setting protocol version
126
132
127
133
This library supports the SOCKS4, SOCKS4a and SOCKS5 protocol versions.
128
134
Usually, there's no need to worry about which protocol version is being used.
129
-
Depending on which features you use (e.g. [remote DNS resolving](#remote-vs-local-dns-resolving) and [authentication](#username--password-authentication)), the `Socks/Client` automatically uses the _best_ protocol available. In general this library automatically switches to higher protocol versions when needed, but tries to keep things simple otherwise and sticks to lower protocol versions when possible.
130
-
The `Socks/Server` supports all protocol versions by default.
135
+
Depending on which features you use (e.g. [remote DNS resolving](#remote-vs-local-dns-resolving)
136
+
and [authentication](#username--password-authentication)),
137
+
the `Client` automatically uses the _best_ protocol available.
138
+
In general this library automatically switches to higher protocol versions
139
+
when needed, but tries to keep things simple otherwise and sticks to lower
140
+
protocol versions when possible.
141
+
The `Server` supports all protocol versions by default.
131
142
132
143
If want to explicitly set the protocol version, use the supported values `4`, `4a` or `5`:
This library supports username/password authentication for SOCKS5 servers as defined in [RFC 1929](http://tools.ietf.org/html/rfc1929).
189
+
This library supports username/password authentication for SOCKS5 servers as
190
+
defined in [RFC 1929](http://tools.ietf.org/html/rfc1929).
175
191
176
-
On the client side, simply set your username and password to use for authentication (see below).
177
-
For each further connection the client will merely send a flag to the server indicating authentication information is available. Only if the server requests authentication during the initial handshake, the actual authentication credentials will be transmitted to the server.
192
+
On the client side, simply set your username and password to use for
193
+
authentication (see below).
194
+
For each further connection the client will merely send a flag to the server
195
+
indicating authentication information is available.
196
+
Only if the server requests authentication during the initial handshake,
197
+
the actual authentication credentials will be transmitted to the server.
178
198
179
-
Note that the password is transmitted in cleartext to the SOCKS proxy server, so this methods should not be used on a network where you have to worry about eavesdropping.
180
-
Authentication is only supported by protocol version 5 (SOCKS5), so setting authentication on the `Socks/Client` enforces communication with protocol version 5 and complains if you have explicitly set anything else.
199
+
Note that the password is transmitted in cleartext to the SOCKS proxy server,
200
+
so this methods should not be used on a network where you have to worry about eavesdropping.
201
+
Authentication is only supported by protocol version 5 (SOCKS5),
202
+
so setting authentication on the `Client` enforces communication with protocol
203
+
version 5 and complains if you have explicitly set anything else.
181
204
182
205
```PHP
183
206
$client->setAuth('username', 'password');
184
207
```
185
208
186
-
Setting authentication on the `Socks/Server` enforces each further connected client to use protocol version 5. If a client tries to use any other protocol version, does not send along authentication details or if authentication details can not be verified, the connection will be rejected.
209
+
Setting authentication on the `Server` enforces each further connected client
210
+
to use protocol version 5.
211
+
If a client tries to use any other protocol version, does not send along
212
+
authentication details or if authentication details can not be verified,
213
+
the connection will be rejected.
187
214
188
-
Because your authentication mechanism might take some time to actually check the provided authentication credentials (like querying a remote database or webservice), the server side uses a [Promise](https://github.com/reactphp/promise) based interface. While this might seem complex at first, it actually provides a very simple way to handle simultanous connections in a non-blocking fashion and increases overall performance.
215
+
Because your authentication mechanism might take some time to actually check
216
+
the provided authentication credentials (like querying a remote database or webservice),
217
+
the server side uses a [Promise](https://github.com/reactphp/promise) based interface.
218
+
While this might seem complex at first, it actually provides a very simple way
219
+
to handle simultanous connections in a non-blocking fashion and increases overall performance.
// either return a boolean success value right away or use promises for delayed authentication
223
+
// either return a boolean success value right away
224
+
// or use promises for delayed authentication
193
225
});
194
226
```
195
227
196
-
Or if you only accept static authentication details, you can use the simple array-based authentication method as a shortcut:
228
+
Or if you only accept static authentication details, you can use the simple
229
+
array-based authentication method as a shortcut:
197
230
198
231
```PHP
199
232
$server->setAuthArray(array(
@@ -213,7 +246,10 @@ $server->unsetAuth();
213
246
214
247
### Using SSH as a SOCKS server
215
248
216
-
If you already have an SSH server set up, you can easily use it as a SOCKS tunnel end point. On your client, simply start your SSH client and use the `-D [port]` option to start a local SOCKS server (quoting the man page: a `local "dynamic" application-level port forwarding`) by issuing:
249
+
If you already have an SSH server set up, you can easily use it as a SOCKS
250
+
tunnel end point. On your client, simply start your SSH client and use
251
+
the `-D [port]` option to start a local SOCKS server (quoting the man page:
252
+
a `local "dynamic" application-level port forwarding`) by issuing:
217
253
218
254
`$ ssh -D 9050 ssh-server`
219
255
@@ -223,7 +259,14 @@ $client = new Client($loop, '127.0.0.1', 9050);
223
259
224
260
### Using the Tor (anonymity network) to tunnel SOCKS connections
225
261
226
-
The [Tor anonymity network](http://www.torproject.org) client software is designed to encrypt your traffic and route it over a network of several nodes to conceal its origin. It presents a SOCKS4 and SOCKS5 interface on TCP port 9050 by default which allows you to tunnel any traffic through the anonymity network. In most scenarios you probably don't want your client to resolve the target hostnames, because you would leak DNS information to anybody observing your local traffic. Also, Tor provides hidden services through an `.onion` pseudo top-level domain which have to be resolved by Tor.
262
+
The [Tor anonymity network](http://www.torproject.org) client software is designed
263
+
to encrypt your traffic and route it over a network of several nodes to conceal its origin.
264
+
It presents a SOCKS4 and SOCKS5 interface on TCP port 9050 by default
265
+
which allows you to tunnel any traffic through the anonymity network.
266
+
In most scenarios you probably don't want your client to resolve the target hostnames,
267
+
because you would leak DNS information to anybody observing your local traffic.
268
+
Also, Tor provides hidden services through an `.onion` pseudo top-level domain
0 commit comments