Skip to content

Commit f1003ea

Browse files
authored
Merge pull request #85 from clue-labs/examples
Improve documentation for examples and link to other projects
2 parents c602a0f + f26e005 commit f1003ea

12 files changed

Lines changed: 82 additions & 5 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ HTTP operates on a higher layer than this low-level SOCKS implementation.
237237
If you want to issue HTTP requests, you can add a dependency for
238238
[clue/reactphp-buzz](https://github.com/clue/reactphp-buzz).
239239
It can interact with this library by issuing all
240-
[http requests through a SOCKS server](https://github.com/clue/reactphp-buzz#socks-proxy).
241-
This works for both plain HTTP and SSL encrypted HTTPS requests.
240+
[HTTP requests through a SOCKS proxy server](https://github.com/clue/reactphp-buzz#socks-proxy).
241+
This works for both plain HTTP and TLS-encrypted HTTPS requests.
242242

243243
#### Protocol version
244244

examples/01-http.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
// A simple example which requests http://www.google.com/ through a SOCKS proxy.
4+
// The proxy can be given as first argument and defaults to localhost:1080 otherwise.
5+
//
6+
// Not already running a SOCKS proxy server? See also example #11 or try this: `ssh -D 1080 localhost`
7+
//
8+
// For illustration purposes only. If you want to send HTTP requests in a real
9+
// world project, take a look at https://github.com/clue/reactphp-buzz#socks-proxy
10+
311
use Clue\React\Socks\Client;
412
use React\Socket\Connector;
513
use React\Socket\ConnectionInterface;

examples/02-https.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
// A simple example which requests https://www.google.com/ through a SOCKS proxy.
4+
// The proxy can be given as first argument and defaults to localhost:1080 otherwise.
5+
//
6+
// Not already running a SOCKS proxy server? See also example #11 or try this: `ssh -D 1080 localhost`
7+
//
8+
// For illustration purposes only. If you want to send HTTP requests in a real
9+
// world project, take a look at https://github.com/clue/reactphp-buzz#socks-proxy
10+
311
use Clue\React\Socks\Client;
412
use React\Socket\Connector;
513
use React\Socket\ConnectionInterface;

examples/03-proxy-chaining.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
// A more advanced example which requests http://www.google.com/ through a chain of SOCKS proxy servers.
4+
// The proxy servers can be given as arguments.
5+
//
6+
// Not already running a SOCKS proxy server? See also example #11 or try this: `ssh -D 1080 localhost`
7+
//
8+
// For illustration purposes only. If you want to send HTTP requests in a real
9+
// world project, take a look at https://github.com/clue/reactphp-buzz#socks-proxy
10+
311
use Clue\React\Socks\Client;
412
use React\Socket\Connector;
513
use React\Socket\ConnectionInterface;

examples/04-local-dns.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
// A simple example which requests https://www.google.com/ through a SOCKS proxy with local DNS resolution.
4+
// The proxy can be given as first argument and defaults to localhost:1080 otherwise.
5+
//
6+
// Not already running a SOCKS proxy server? See also example #11 or try this: `ssh -D 1080 localhost`
7+
//
8+
// For illustration purposes only. If you want to send HTTP requests in a real
9+
// world project, take a look at https://github.com/clue/reactphp-buzz#socks-proxy
10+
311
use Clue\React\Socks\Client;
412
use React\Socket\Connector;
513
use React\Socket\ConnectionInterface;

examples/11-server.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<?php
22

3+
// A simple example which runs a SOCKS proxy server.
4+
// The listen address can be given as first argument and defaults to localhost:1080 otherwise.
5+
//
6+
// See also examples #01 and #02 for the client side.
7+
38
use Clue\React\Socks\Server;
49
use React\Socket\Server as Socket;
510

examples/12-server-with-password.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
// A simple example which runs a SOCKS proxy server with hard-coded authentication details.
4+
// The listen address can be given as first argument and defaults to localhost:1080 otherwise.
5+
//
6+
// See also examples #01 and #02 for the client side.
7+
//
8+
// Note that the client examples do not pass any authentication details by default
9+
// and as such will fail to authenticate against this example server. You can
10+
// explicitly pass authentication details to the client example like this:
11+
//
12+
// $ php examples/01-http.php tom:god@localhost:1080
13+
314
use Clue\React\Socks\Server;
415
use React\Socket\Server as Socket;
516

examples/13-server-blacklist.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<?php
22

3-
// A SOCKS server that rejects connections to some domains (blacklist / filtering)
3+
// A more advanced example which runs a SOCKS proxy server that rejects connections
4+
// to some domains (blacklist /filtering).
5+
// The listen address can be given as first argument and defaults to localhost:1080 otherwise.
6+
//
7+
// See also examples #01 and #02 for the client side.
8+
// Client example #01 is expected to fail because port 80 is blocked in this server example.
9+
// Client example #02 is expected to succceed because it is not blacklisted.
410

511
use React\EventLoop\Factory as LoopFactory;
612
use ConnectionManager\Extra\Multiple\ConnectionManagerSelective;

examples/21-server-proxy-chaining.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<?php
22

3-
// A SOCKS server that forwards (proxy chaining) to other SOCKS servers
3+
// A more advanced example which runs a SOCKS proxy server that forwards to
4+
// other SOCKS servers (proxy chaining).
5+
// The listen address can be given as first argument.
6+
// The upstream proxy servers can be given as additional arguments.
7+
//
8+
// See also examples #01 and #02 for the client side.
49

510
use Clue\React\Socks\Client;
611
use Clue\React\Socks\Server;

examples/22-server-proxy-chaining-from-random-pool.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<?php
22

3-
// A SOCKS server that randomly forwards (proxy chaining) to a pool of SOCKS servers
3+
// A more advanced example which runs a SOCKS proxy server that randomly forwards
4+
// to a pool of SOCKS servers (random proxy chaining).
5+
// The listen address can be given as first argument.
6+
// The upstream proxy servers can be given as additional arguments.
7+
//
8+
// See also examples #01 and #02 for the client side.
49

510
use React\EventLoop\Factory as LoopFactory;
611
use ConnectionManager\Extra\Multiple\ConnectionManagerRandom;

0 commit comments

Comments
 (0)