Skip to content

Commit 1c5e640

Browse files
committed
Add Connector adapter for Socks\Client
1 parent ba95045 commit 1c5e640

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

Socks/Client.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use React\EventLoop\LoopInterface;
1111
use React\SocketClient\ConnectorInterface;
1212
use React\SocketClient\SecureConnector;
13+
use Socks\Connector;
1314
use \Exception;
1415
use \InvalidArgumentException;
1516
use \UnexpectedValueException;
@@ -117,6 +118,11 @@ public function createSecureConnector()
117118
{
118119
return new SecureConnector($this->createConnector(), $this->loop);
119120
}
121+
122+
public function createConnector()
123+
{
124+
return new Connector($this);
125+
}
120126

121127
public function getConnection($host, $port)
122128
{

Socks/Connector.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Socks;
4+
5+
use React\SocketClient\ConnectorInterface;
6+
use Socks\Client;
7+
8+
class Connector implements ConnectorInterface
9+
{
10+
private $client;
11+
12+
public function __construct(Client $socksClient)
13+
{
14+
$this->client = $socksClient;
15+
}
16+
17+
public function create($host, $port)
18+
{
19+
return $this->client->getConnection($host, $port);
20+
}
21+
}

0 commit comments

Comments
 (0)