forked from clue/reactphp-socks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path31-server-secure.php
More file actions
26 lines (18 loc) · 804 Bytes
/
31-server-secure.php
File metadata and controls
26 lines (18 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
// A more advanced example which runs a secure SOCKS over TLS proxy server.
// The listen address can be given as first argument and defaults to localhost:1080 otherwise.
//
// See also example #32 for the client side.
use Clue\React\Socks\Server;
use React\Socket\Server as Socket;
require __DIR__ . '/../vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
// start a new SOCKS proxy server
$server = new Server($loop);
// listen on tls://127.0.0.1:1080 or first argument
$listen = isset($argv[1]) ? $argv[1] : '127.0.0.1:1080';
$socket = new Socket('tls://' . $listen, $loop, array('tls' => array(
'local_cert' => __DIR__ . '/localhost.pem',
)));
echo 'SOCKS over TLS server listening on ' . str_replace('tls:', 'sockss:', $socket->getAddress()) . PHP_EOL;
$loop->run();