Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Socks React Laravel Package

clue/socks-react

Async SOCKS4/4a/5 proxy connector for ReactPHP. Route TCP connections through a SOCKS server with non-blocking I/O, supporting authentication and DNS resolving via the proxy. Integrates with React\Socket to proxy outgoing connections.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install the package: composer require clue/socks-react
  2. Ensure ReactPHP is available: The package depends on react/socket and react/promise. If you don’t already use ReactPHP, install react/react or the core components individually.
  3. First use case: Create a SOCKS5-proxied HTTP client connection:
    $loop = React\EventLoop\Factory::create();
    $socket = new React\Socket\Connector($loop, [
        'proxy' => 'socks5://user:pass@127.0.0.1:1080'
    ]);
    $socket->connect('http://example.com:80')->then(...);
    
    The proxy configuration is injected via the Connector options — no code changes required for existing ReactPHP-based clients.

Implementation Patterns

  • Transparent proxy wrapping: Use Clue\React\Socks\Client to wrap an existing ConnectorInterface, enabling SOCKS support for any ReactPHP-compatible client (e.g., HTTP clients like react/http, custom TCP bots, WebSocket clients).
  • Dynamic proxy selection: Configure proxies at runtime based on target host or user preferences:
    $proxyUrl = $isInternal ? 'socks5://internal-proxy:1080' : 'socks4://public-proxy:1080';
    $connector = new Clue\React\Socks\Client($socketConnector, $proxyUrl);
    $client = new React\Http\Browser($loop, $connector);
    
  • Auth + ACL handling: Pass credentials in the proxy URI (SOCKS5 supports user:pass). For complex auth (e.g., GSSAPI, custom methods), extend Client or use the auth option if supported by your proxy server.
  • Fallback chains: Chain multiple SOCKS proxies (via Connector::connect() chaining or custom logic) for multi-hop anonymization — e.g., Tor + public proxy.

Gotchas and Tips

  • SOCKS4 vs 5 detection: Use socks4:// or socks5:// URIs explicitly. If omitted, default is SOCKS5. SOCKS4a (domain-level resolution) works only via SOCKS5 with SOCKS5_RESOLVE_DOMAIN extension (rarely supported server-side).
  • DNS resolution location: SOCKS5 resolves DNS remotely (on the proxy), while SOCKS4 resolves locally unless you use socks4a://. Clarify which mode you want in URIs.
  • Timeouts & connection errors: Errors surface as rejected promises — always catch() to handle proxy unreachable, auth failure, or DNS resolution errors.
  • Integration with existing code: Don’t forget to pass the proxied connector to all async clients (e.g., HTTP browser, DNS resolver). ReactPHP’s Connector is composable but must be explicitly injected.
  • Performance tip: Reuse the same Client instance across requests — creating new connectors per request adds overhead and may exhaust connection slots.
  • Testing tip: Use squid or dante-server in Docker for local proxy testing. For SOCKS5, ensure AUTH is enabled if testing with credentials.
  • No UDP support: This package only proxies TCP. For DNS over SOCKS, you’ll need to tunnel UDP over TCP (e.g., via react/dns with tcp fallback) or use a SOCKS5 proxy that supports UDP associate.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport