init
This commit is contained in:
30
vendor/clue/socks-react/examples/02-https.php
vendored
Executable file
30
vendor/clue/socks-react/examples/02-https.php
vendored
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Clue\React\Socks\Client;
|
||||
use React\Socket\Connector;
|
||||
use React\Socket\ConnectionInterface;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$proxy = isset($argv[1]) ? $argv[1] : '127.0.0.1:1080';
|
||||
|
||||
$loop = React\EventLoop\Factory::create();
|
||||
|
||||
$client = new Client($proxy, new Connector($loop));
|
||||
$connector = new Connector($loop, array(
|
||||
'tcp' => $client,
|
||||
'timeout' => 3.0,
|
||||
'dns' => false
|
||||
));
|
||||
|
||||
echo 'Demo SOCKS client connecting to SOCKS server ' . $proxy . PHP_EOL;
|
||||
|
||||
$connector->connect('tls://www.google.com:443')->then(function (ConnectionInterface $stream) {
|
||||
echo 'connected' . PHP_EOL;
|
||||
$stream->write("GET / HTTP/1.0\r\n\r\n");
|
||||
$stream->on('data', function ($data) {
|
||||
echo $data;
|
||||
});
|
||||
}, 'printf');
|
||||
|
||||
$loop->run();
|
||||
Reference in New Issue
Block a user