@@ -158,9 +158,9 @@ This makes it fairly simple to add SSH proxy support to pretty much any
158158higher-level component:
159159
160160``` diff
161- - $client = new SomeClient ($connector);
162- + $proxy = new SshProcessConnector('[email protected] ', $loop);163- + $client = new SomeClient ($proxy);
161+ - $acme = new AcmeApi ($connector);
162+ + $proxy = new Clue\React\SshProxy\ SshProcessConnector('[email protected] ', $loop);163+ + $acme = new AcmeApi ($proxy);
164164```
165165
166166### SshSocksConnector
@@ -242,9 +242,9 @@ This makes it fairly simple to add SSH proxy support to pretty much any
242242higher-level component:
243243
244244``` diff
245- - $client = new SomeClient ($connector);
246- + $proxy = new SshSocksConnector('[email protected] ', $loop);247- + $client = new SomeClient ($proxy);
245+ - $acme = new AcmeApi ($connector);
246+ + $proxy = new Clue\React\SshProxy\ SshSocksConnector('[email protected] ', $loop);247+ + $acme = new AcmeApi ($proxy);
248248```
249249
250250## Usage
@@ -259,13 +259,13 @@ a streaming plain TCP/IP connection on the `SshProcessConnector` or `SshSocksCon
259259and use any higher level protocol like so:
260260
261261``` php
262- $proxy = new SshProcessConnector('
[email protected] ', $loop);
262+ $proxy = new
Clue\React\SshProxy\ SshProcessConnector('
[email protected] ', $loop);
263263// or
264- $proxy = new SshSocksConnector('
[email protected] ', $loop);
264+ $proxy = new
Clue\React\SshProxy\ SshSocksConnector('
[email protected] ', $loop);
265265
266- $proxy->connect('tcp://smtp.googlemail.com:587')->then(function (ConnectionInterface $stream ) {
267- $stream ->write("EHLO local\r\n");
268- $stream ->on('data', function ($chunk) use ($stream ) {
266+ $proxy->connect('tcp://smtp.googlemail.com:587')->then(function (React\Socket\ ConnectionInterface $connection ) {
267+ $connection ->write("EHLO local\r\n");
268+ $connection ->on('data', function ($chunk) use ($connection ) {
269269 echo $chunk;
270270 });
271271});
@@ -275,14 +275,18 @@ You can either use the `SshProcessConnector` or `SshSocksConnector` directly or
275275may want to wrap this connector in ReactPHP's [ ` Connector ` ] ( https://github.com/reactphp/socket#connector ) :
276276
277277``` php
278- $connector = new Connector($loop, array(
278+ $proxy = new Clue\React\SshProxy\SshProcessConnector('
[email protected] ', $loop);
279+ // or
280+ $proxy = new Clue\React\SshProxy\SshSocksConnector('
[email protected] ', $loop);
281+
282+ $connector = new React\Socket\Connector($loop, array(
279283 'tcp' => $proxy,
280284 'dns' => false
281285));
282286
283- $connector->connect('tcp://smtp.googlemail.com:587')->then(function (ConnectionInterface $stream ) {
284- $stream ->write("EHLO local\r\n");
285- $stream ->on('data', function ($chunk) use ($stream ) {
287+ $connector->connect('tcp://smtp.googlemail.com:587')->then(function (React\Socket\ ConnectionInterface $connection ) {
288+ $connection ->write("EHLO local\r\n");
289+ $connection ->on('data', function ($chunk) use ($connection ) {
286290 echo $chunk;
287291 });
288292});
@@ -304,16 +308,16 @@ ReactPHP's [`Connector`](https://github.com/reactphp/socket#connector) or the
304308low-level [ ` SecureConnector ` ] ( https://github.com/reactphp/socket#secureconnector ) :
305309
306310``` php
307- $proxy = new SshSocksConnector('
[email protected] ', $loop);
311+ $proxy = new
Clue\React\SshProxy\ SshSocksConnector('
[email protected] ', $loop);
308312
309- $connector = new Connector($loop, array(
313+ $connector = new React\Socket\ Connector($loop, array(
310314 'tcp' => $proxy,
311315 'dns' => false
312316));
313317
314- $connector->connect('tls://smtp.googlemail.com:465')->then(function (ConnectionInterface $stream ) {
315- $stream ->write("EHLO local\r\n");
316- $stream ->on('data', function ($chunk) use ($stream ) {
318+ $connector->connect('tls://smtp.googlemail.com:465')->then(function (React\Socket\ ConnectionInterface $connection ) {
319+ $connection ->write("EHLO local\r\n");
320+ $connection ->on('data', function ($chunk) use ($connection ) {
317321 echo $chunk;
318322 });
319323});
@@ -336,7 +340,7 @@ In order to send HTTP requests, you first have to add a dependency for
336340This allows you to send both plain HTTP and TLS-encrypted HTTPS requests like this:
337341
338342``` php
339- $proxy = new Clue\React\SshProxy\SshSocksConnector('me@localhost:22 ', $loop);
343+ $proxy = new Clue\React\SshProxy\SshSocksConnector('
[email protected] ', $loop);
340344
341345$connector = new React\Socket\Connector($loop, array(
342346 'tcp' => $proxy,
@@ -381,7 +385,7 @@ $factory = new React\MySQL\Factory($loop, $proxy);
381385$connection = $factory->createLazyConnection($uri);
382386
383387$connection->query('SELECT * FROM book')->then(
384- function (QueryResult $command) {
388+ function (React\MySQL\ QueryResult $command) {
385389 echo count($command->resultRows) . ' row(s) in set' . PHP_EOL;
386390 },
387391 function (Exception $error) {
@@ -422,13 +426,17 @@ It provides the same `connect()` method, but will automatically reject the
422426underlying connection attempt if it takes too long:
423427
424428``` php
425- $connector = new Connector($loop, array(
429+ $proxy = new Clue\React\SshProxy\SshProcessConnector('
[email protected] ', $loop);
430+ // or
431+ $proxy = new Clue\React\SshProxy\SshSocksConnector('
[email protected] ', $loop);
432+
433+ $connector = new React\Socket\Connector($loop, array(
426434 'tcp' => $proxy,
427435 'dns' => false,
428436 'timeout' => 3.0
429437));
430438
431- $connector->connect('tcp://google.com:80')->then(function ($stream ) {
439+ $connector->connect('tcp://google.com:80')->then(function (React\Socket\ConnectionInterface $connection ) {
432440 // connection succeeded within 3.0 seconds
433441});
434442```
@@ -464,7 +472,11 @@ Given that remote DNS resolution is assumed to be the preferred mode, all
464472other examples explicitly disable DNS resolution like this:
465473
466474``` php
467- $connector = new Connector($loop, array(
475+ $proxy = new Clue\React\SshProxy\SshProcessConnector('
[email protected] ', $loop);
476+ // or
477+ $proxy = new Clue\React\SshProxy\SshSocksConnector('
[email protected] ', $loop);
478+
479+ $connector = new React\Socket\Connector($loop, array(
468480 'tcp' => $proxy,
469481 'dns' => false
470482));
@@ -473,8 +485,12 @@ $connector = new Connector($loop, array(
473485If you want to explicitly use * local DNS resolution* , you can use the following code:
474486
475487``` php
488+ $proxy = new Clue\React\SshProxy\SshProcessConnector('
[email protected] ', $loop);
489+ // or
490+ $proxy = new Clue\React\SshProxy\SshSocksConnector('
[email protected] ', $loop);
491+
476492// set up Connector which uses Google's public DNS (8.8.8.8)
477- $connector = new Connector($loop, array(
493+ $connector = new React\Socket\ Connector($loop, array(
478494 'tcp' => $proxy,
479495 'dns' => '8.8.8.8'
480496));
@@ -508,9 +524,9 @@ If your SSH proxy server requires password authentication, you may pass the
508524username and password as part of the SSH proxy server URL like this:
509525
510526``` php
511- $proxy = new SshProcessConnector('user:
[email protected] ', $loop);
527+ $proxy = new
Clue\React\SshProxy\ SshProcessConnector('user:
[email protected] ', $loop);
512528// or
513- $proxy = new SshSocksConnector('user:
[email protected] ', $loop);
529+ $proxy = new
Clue\React\SshProxy\ SshSocksConnector('user:
[email protected] ', $loop);
514530```
515531
516532For this to work, you will have to have the ` sshpass ` binary installed. On
@@ -527,7 +543,7 @@ special characters:
527543$user = 'he:llo';
528544$pass = 'p@ss';
529545
530- $proxy = new SshProcessConnector(
546+ $proxy = new Clue\React\SshProxy\ SshProcessConnector(
531547 rawurlencode($user) . ':' . rawurlencode($pass) . '@example.com:2222',
532548 $loop
533549);
0 commit comments