Skip to content

Commit 2e8cd35

Browse files
committed
Update examples
1 parent 744eb16 commit 2e8cd35

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

examples/server-middleman.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
$target->setAuth('user','p@ssw0rd');
1515

1616
// start a new server which forwards all connections to another SOCKS server
17-
$server = new Socks\Server($loop, $target);
17+
$socket = new React\Socket\Server($loop);
18+
$server = new Socks\Server($socket, $loop, $target);
1819

19-
$server->listen('9051','localhost');
20+
$socket->listen('9051','localhost');
2021

2122
echo 'SOCKS server listening on localhost:9051 (which forwards everything to SOCKS server 127.0.0.1:9050)' . PHP_EOL;
2223

examples/server.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@
88
$dns = $dnsResolverFactory->createCached('8.8.8.8', $loop);
99

1010
$factory = new Socks\Factory($loop, $dns);
11+
12+
$connectionManager = new ConnectionManager\ConnectionManager($loop, $dns);
13+
14+
$socket = new React\Socket\Server($loop);
15+
16+
$server = new Socks\Server($socket, $loop, $connectionManager);
17+
1118
$server = $factory->createServer();
12-
$server->listen('9050','localhost');
1319
$server->setAuthArray(array(
1420
'tom' => 'god',
1521
'user' => 'p@ssw0rd'
1622
));
1723

24+
$socket->listen('9050','localhost');
25+
1826
echo 'SOCKS server listening on localhost:9050' . PHP_EOL;
1927

2028
$loop->run();

0 commit comments

Comments
 (0)