@@ -158,9 +158,9 @@ This makes it fairly simple to add SSH proxy support to pretty much any
158
158
higher-level component:
159
159
160
160
``` diff
161
- - $client = new SomeClient ($connector);
162
- + $proxy = new SshProcessConnector('user@example.com', $loop);
163
- + $client = new SomeClient ($proxy);
161
+ - $acme = new AcmeApi ($connector);
162
+ + $proxy = new Clue\React\SshProxy\ SshProcessConnector('user@example.com', $loop);
163
+ + $acme = new AcmeApi ($proxy);
164
164
```
165
165
166
166
### SshSocksConnector
@@ -242,9 +242,9 @@ This makes it fairly simple to add SSH proxy support to pretty much any
242
242
higher-level component:
243
243
244
244
``` diff
245
- - $client = new SomeClient ($connector);
246
- + $proxy = new SshSocksConnector('user@example.com', $loop);
247
- + $client = new SomeClient ($proxy);
245
+ - $acme = new AcmeApi ($connector);
246
+ + $proxy = new Clue\React\SshProxy\ SshSocksConnector('user@example.com', $loop);
247
+ + $acme = new AcmeApi ($proxy);
248
248
```
249
249
250
250
## Usage
@@ -259,13 +259,13 @@ a streaming plain TCP/IP connection on the `SshProcessConnector` or `SshSocksCon
259
259
and use any higher level protocol like so:
260
260
261
261
``` php
262
- $proxy = new SshProcessConnector('user@example.com', $loop);
262
+ $proxy = new Clue\React\SshProxy\ SshProcessConnector('user@example.com', $loop);
263
263
// or
264
- $proxy = new SshSocksConnector('user@example.com', $loop);
264
+ $proxy = new Clue\React\SshProxy\ SshSocksConnector('user@example.com', $loop);
265
265
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 ) {
269
269
echo $chunk;
270
270
});
271
271
});
@@ -275,14 +275,18 @@ You can either use the `SshProcessConnector` or `SshSocksConnector` directly or
275
275
may want to wrap this connector in ReactPHP's [ ` Connector ` ] ( https://github.com/reactphp/socket#connector ) :
276
276
277
277
``` php
278
- $connector = new Connector($loop, array(
278
+ $proxy = new Clue\React\SshProxy\SshProcessConnector('user@example.com', $loop);
279
+ // or
280
+ $proxy = new Clue\React\SshProxy\SshSocksConnector('user@example.com', $loop);
281
+
282
+ $connector = new React\Socket\Connector($loop, array(
279
283
'tcp' => $proxy,
280
284
'dns' => false
281
285
));
282
286
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 ) {
286
290
echo $chunk;
287
291
});
288
292
});
@@ -304,16 +308,16 @@ ReactPHP's [`Connector`](https://github.com/reactphp/socket#connector) or the
304
308
low-level [ ` SecureConnector ` ] ( https://github.com/reactphp/socket#secureconnector ) :
305
309
306
310
``` php
307
- $proxy = new SshSocksConnector('user@example.com', $loop);
311
+ $proxy = new Clue\React\SshProxy\ SshSocksConnector('user@example.com', $loop);
308
312
309
- $connector = new Connector($loop, array(
313
+ $connector = new React\Socket\ Connector($loop, array(
310
314
'tcp' => $proxy,
311
315
'dns' => false
312
316
));
313
317
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 ) {
317
321
echo $chunk;
318
322
});
319
323
});
@@ -336,7 +340,7 @@ In order to send HTTP requests, you first have to add a dependency for
336
340
This allows you to send both plain HTTP and TLS-encrypted HTTPS requests like this:
337
341
338
342
``` php
339
- $proxy = new Clue\React\SshProxy\SshSocksConnector('me@localhost:22 ', $loop);
343
+ $proxy = new Clue\React\SshProxy\SshSocksConnector('user@example.com ', $loop);
340
344
341
345
$connector = new React\Socket\Connector($loop, array(
342
346
'tcp' => $proxy,
@@ -381,7 +385,7 @@ $factory = new React\MySQL\Factory($loop, $proxy);
381
385
$connection = $factory->createLazyConnection($uri);
382
386
383
387
$connection->query('SELECT * FROM book')->then(
384
- function (QueryResult $command) {
388
+ function (React\MySQL\ QueryResult $command) {
385
389
echo count($command->resultRows) . ' row(s) in set' . PHP_EOL;
386
390
},
387
391
function (Exception $error) {
@@ -422,13 +426,17 @@ It provides the same `connect()` method, but will automatically reject the
422
426
underlying connection attempt if it takes too long:
423
427
424
428
``` php
425
- $connector = new Connector($loop, array(
429
+ $proxy = new Clue\React\SshProxy\SshProcessConnector('user@example.com', $loop);
430
+ // or
431
+ $proxy = new Clue\React\SshProxy\SshSocksConnector('user@example.com', $loop);
432
+
433
+ $connector = new React\Socket\Connector($loop, array(
426
434
'tcp' => $proxy,
427
435
'dns' => false,
428
436
'timeout' => 3.0
429
437
));
430
438
431
- $connector->connect('tcp://google.com:80')->then(function ($stream ) {
439
+ $connector->connect('tcp://google.com:80')->then(function (React\Socket\ConnectionInterface $connection ) {
432
440
// connection succeeded within 3.0 seconds
433
441
});
434
442
```
@@ -464,7 +472,11 @@ Given that remote DNS resolution is assumed to be the preferred mode, all
464
472
other examples explicitly disable DNS resolution like this:
465
473
466
474
``` php
467
- $connector = new Connector($loop, array(
475
+ $proxy = new Clue\React\SshProxy\SshProcessConnector('user@example.com', $loop);
476
+ // or
477
+ $proxy = new Clue\React\SshProxy\SshSocksConnector('user@example.com', $loop);
478
+
479
+ $connector = new React\Socket\Connector($loop, array(
468
480
'tcp' => $proxy,
469
481
'dns' => false
470
482
));
@@ -473,8 +485,12 @@ $connector = new Connector($loop, array(
473
485
If you want to explicitly use * local DNS resolution* , you can use the following code:
474
486
475
487
``` php
488
+ $proxy = new Clue\React\SshProxy\SshProcessConnector('user@example.com', $loop);
489
+ // or
490
+ $proxy = new Clue\React\SshProxy\SshSocksConnector('user@example.com', $loop);
491
+
476
492
// 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(
478
494
'tcp' => $proxy,
479
495
'dns' => '8.8.8.8'
480
496
));
@@ -508,9 +524,9 @@ If your SSH proxy server requires password authentication, you may pass the
508
524
username and password as part of the SSH proxy server URL like this:
509
525
510
526
``` php
511
- $proxy = new SshProcessConnector('user:pass@example.com', $loop);
527
+ $proxy = new Clue\React\SshProxy\ SshProcessConnector('user:pass@example.com', $loop);
512
528
// or
513
- $proxy = new SshSocksConnector('user:pass@example.com', $loop);
529
+ $proxy = new Clue\React\SshProxy\ SshSocksConnector('user:pass@example.com', $loop);
514
530
```
515
531
516
532
For this to work, you will have to have the ` sshpass ` binary installed. On
@@ -527,7 +543,7 @@ special characters:
527
543
$user = 'he:llo';
528
544
$pass = 'p@ss';
529
545
530
- $proxy = new SshProcessConnector(
546
+ $proxy = new Clue\React\SshProxy\ SshProcessConnector(
531
547
rawurlencode($user) . ':' . rawurlencode($pass) . '@example.com:2222',
532
548
$loop
533
549
);
0 commit comments