1. Go to this page and download the library: Download clue/reactphp-ssh-proxy library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
clue / reactphp-ssh-proxy example snippets
y = new Clue\React\SshProxy\SshProcessConnector('[email protected]');
$connector = new React\Socket\Connector(array(
'tcp' => $proxy,
'dns' => false
));
$browser = new React\Http\Browser($connector);
$browser->get('https://google.com/')->then(function (Psr\Http\Message\ResponseInterface $response) {
var_dump($response->getHeaders(), (string) $response->getBody());
}, function (Exception $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});
$proxy = new Clue\React\SshProxy\SshProcessConnector('[email protected]');
$proxy = new Clue\React\SshProxy\SshSocksConnector('[email protected]');
$proxy = new Clue\React\SshProxy\SshSocksConnector('[email protected]?bind=127.1.1.1:1081');
$proxy = new Clue\React\SshProxy\SshProcessConnector('[email protected]');
// or
$proxy = new Clue\React\SshProxy\SshSocksConnector('[email protected]');
$proxy->connect('tcp://smtp.googlemail.com:587')->then(function (React\Socket\ConnectionInterface $connection) {
$connection->write("EHLO local\r\n");
$connection->on('data', function ($chunk) use ($connection) {
echo $chunk;
});
});
$proxy = new Clue\React\SshProxy\SshProcessConnector('[email protected]');
// or
$proxy = new Clue\React\SshProxy\SshSocksConnector('[email protected]');
$connector = new React\Socket\Connector(array(
'tcp' => $proxy,
'dns' => false
));
$connector->connect('tcp://smtp.googlemail.com:587')->then(function (React\Socket\ConnectionInterface $connection) {
$connection->write("EHLO local\r\n");
$connection->on('data', function ($chunk) use ($connection) {
echo $chunk;
});
});
$proxy = new Clue\React\SshProxy\SshSocksConnector('[email protected]');
$connector = new React\Socket\Connector(array(
'tcp' => $proxy,
'dns' => false
));
$connector->connect('tls://smtp.googlemail.com:465')->then(function (React\Socket\ConnectionInterface $connection) {
$connection->write("EHLO local\r\n");
$connection->on('data', function ($chunk) use ($connection) {
echo $chunk;
});
});
$proxy = new Clue\React\SshProxy\SshSocksConnector('[email protected]');
$connector = new React\Socket\Connector(array(
'tcp' => $proxy,
'dns' => false
));
$browser = new React\Http\Browser($connector);
$browser->get('https://google.com/')->then(function (Psr\Http\Message\ResponseInterface $response) {
var_dump($response->getHeaders(), (string) $response->getBody());
}, function (Exception $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});
$proxy = new Clue\React\SshProxy\SshProcessConnector('[email protected]');
$uri = 'test:test@localhost/test';
$factory = new React\MySQL\Factory(null, $proxy);
$connection = $factory->createLazyConnection($uri);
$connection->query('SELECT * FROM book')->then(
function (React\MySQL\QueryResult $command) {
echo count($command->resultRows) . ' row(s) in set' . PHP_EOL;
},
function (Exception $error) {
echo 'Error: ' . $error->getMessage() . PHP_EOL;
}
);
$connection->quit();
$proxy = new Clue\React\SshProxy\SshProcessConnector('[email protected]');
// or
$proxy = new Clue\React\SshProxy\SshSocksConnector('[email protected]');
$connector = new React\Socket\Connector(array(
'tcp' => $proxy,
'dns' => false,
'timeout' => 3.0
));
$connector->connect('tcp://google.com:80')->then(function (React\Socket\ConnectionInterface $connection) {
// connection succeeded within 3.0 seconds
});
$proxy = new Clue\React\SshProxy\SshProcessConnector('[email protected]');
// or
$proxy = new Clue\React\SshProxy\SshSocksConnector('[email protected]');
$connector = new React\Socket\Connector(array(
'tcp' => $proxy,
'dns' => false
));
$proxy = new Clue\React\SshProxy\SshProcessConnector('[email protected]');
// or
$proxy = new Clue\React\SshProxy\SshSocksConnector('[email protected]');
// set up Connector which uses Google's public DNS (8.8.8.8)
$connector = new React\Socket\Connector(array(
'tcp' => $proxy,
'dns' => '8.8.8.8'
));
$proxy = new Clue\React\SshProxy\SshProcessConnector('alice:[email protected]');
// or
$proxy = new Clue\React\SshProxy\SshSocksConnector('alice:[email protected]');