forked from reactphp/http
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13-client-ssh-proxy.php
More file actions
27 lines (20 loc) · 859 Bytes
/
13-client-ssh-proxy.php
File metadata and controls
27 lines (20 loc) · 859 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
27
<?php
// $ ssh_proxy=alice@example.com php examples/13-client-ssh-proxy.php
use Psr\Http\Message\ResponseInterface;
use React\Http\Browser;
use React\Socket\Connector;
require __DIR__ . '/../vendor/autoload.php';
// create a new SSH proxy client which connects to a SSH server listening on alice@localhost
$proxy = new Clue\React\SshProxy\SshSocksConnector(getenv('ssh_proxy') ?: 'alice@localhost');
// create a Browser object that uses the SSH proxy client for connections
$connector = new Connector(array(
'tcp' => $proxy,
'dns' => false
));
$browser = new Browser($connector);
// demo fetching HTTP headers (or bail out otherwise)
$browser->get('https://www.google.com/')->then(function (ResponseInterface $response) {
echo (string) $response->getBody();
}, function (Exception $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});