clue/socks-react
Async SOCKS5/SOCKS4(a) proxy client and server for ReactPHP. Tunnel any TCP/IP protocol (HTTP, SMTP, IMAP, etc.) through a SOCKS proxy using the standard ConnectorInterface, enabling easy drop-in proxy support and parallel connections.
psr/http-client-implementation and ReactPHP integration). The package’s ReactPHP foundation ensures non-blocking I/O, critical for high-throughput proxy routing.Guzzle, Symfony HTTP Client) or custom TCP-based services (e.g., WebSockets, SMTP).Connector, enabling seamless integration with existing async stacks (e.g., react/http, react/socket).GuzzleHttp\HandlerStack with a custom SocksHandler. Feasible but adds complexity.HttpClient::withOptions(['proxy' => 'socks://...']) (PHP 8.1+). Prefer this for simplicity.Client with React\Socket\ConnectionInterface for low-level protocols (e.g., SMTP, Redis).react/async-queue + SOCKS-wrapped connections).ProxyService).Spatie\Async or Laravel Horizon for async job orchestration.Sentry, Laravel Log)?| Laravel Component | Integration Strategy | Tools/Libraries |
|---|---|---|
| HTTP Clients (Guzzle/Symfony) | Replace default connector with SOCKS-wrapped Connector or use Symfony’s proxy option. |
clue/socks-react, symfony/http-client |
| Queues | Custom queue driver using React\AsyncQueue + SOCKS connections. |
react/async-queue, illuminate/queue |
| TCP Services | Direct Client usage with React\Socket\ConnectionInterface. |
clue/socks-react, react/socket |
| Artisan Commands | Async command handlers with SOCKS support (e.g., php artisan proxy:fetch). |
laravel/framework, clue/socks-react |
| Event Listeners | Async listeners using React\EventLoop (advanced). |
react/event-loop, laravel/events |
Phase 1: HTTP Proxying (Low Risk)
GuzzleHttp\Client with Symfony\HttpClient (PHP 8.1+).HttpClient::withOptions(['proxy' => 'socks://user:pass@host:port']).curl --socks5-hostname to validate behavior.symfony/http-client, phpunit.Phase 2: Async TCP Services (Medium Risk)
ProxyConnector service wrapping Clue\React\Socks\Client.$connector = new React\Socket\Connector([
'tcp' => new Clue\React\Socks\Client('socks5://proxy:1080'),
'dns' => false,
]);
React\AsyncQueue for async jobs.reactphp/react, spatie/async.Phase 3: Full Async Stack (High Risk)
React\EventLoop.Laravel React packages (e.g., laravel-react/queue) for async queues.laravel-react/queue, reactphp/promise.SocksHandler implementation.socks5:// URI parsing).user:pass@host).Route::get('/proxy-test', ...)).Symfony\HttpClient for simplicity.config/proxy.php).'enabled' => env('USE_SOCKS_PROXY', false),
'host' => env('SOCKS_HOST', '127.0.0.1'),
'port' => env('SOCKS_PORT', 1080),
ProxyService with direct connection fallback:
public function connect(string $uri): ConnectionInterface {
try {
return $this->socksClient->connect($uri);
} catch (Exception $e) {
return $this->directConnector->connect($uri);
}
}
clue/socks-react and reactphp/react for breaking changes.composer.json to avoid surprises (e.g., ^1.0).config/proxy.php to avoid hardcoded values.env() for runtime overrides.\Log::debug('SOCKS connection', [
'proxy' => $proxy->getUri(),
'target' => $uri,
'duration_ms' => $stopwatch->duration(),
]);
connect_timeout in Connector options.socks5://user:pass@host).'dns' => false).tcpdump to inspect SOCKS traffic.socks-proxy-cli to test proxy connectivity.proxy.md to the Laravel app’s docs with:
round-robin across multiple SOCKS servers).How can I help you explore Laravel packages today?