PHPackages                             clue/socks-react - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. clue/socks-react

ActiveLibrary[Queues &amp; Workers](/categories/queues)

clue/socks-react
================

Async SOCKS proxy connector client and server implementation, tunnel any TCP/IP-based protocol through a SOCKS5 or SOCKS4(a) proxy server, built on top of ReactPHP.

v1.5.0(2mo ago)1191.1M↑31.2%2620MITPHPPHP &gt;=5.3CI passing

Since May 19Pushed 2mo ago12 watchersCompare

[ Source](https://github.com/clue/reactphp-socks)[ Packagist](https://packagist.org/packages/clue/socks-react)[ Docs](https://github.com/clue/reactphp-socks)[ Fund](https://clue.engineering/support)[ GitHub Sponsors](https://github.com/clue)[ RSS](/packages/clue-socks-react/feed)WikiDiscussions 1.x Synced 2d ago

READMEChangelog (10)Dependencies (14)Versions (25)Used By (20)

clue/reactphp-socks
===================

[](#cluereactphp-socks)

[![CI status](https://github.com/clue/reactphp-socks/actions/workflows/ci.yml/badge.svg)](https://github.com/clue/reactphp-socks/actions)[![installs on Packagist](https://camo.githubusercontent.com/7cd32e416822bfeda48afdaa30a4168bd0ea498603be9c175daeb731773f624f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c75652f736f636b732d72656163743f636f6c6f723d626c7565266c6162656c3d696e7374616c6c732532306f6e2532305061636b6167697374)](https://packagist.org/packages/clue/socks-react)

Async SOCKS proxy connector client and server implementation, tunnel any TCP/IP-based protocol through a SOCKS5 or SOCKS4(a) proxy server, built on top of [ReactPHP](https://reactphp.org/).

The SOCKS proxy protocol family (SOCKS5, SOCKS4 and SOCKS4a) is commonly used to tunnel HTTP(S) traffic through an intermediary ("proxy"), to conceal the origin address (anonymity) or to circumvent address blocking (geoblocking). While many (public) SOCKS proxy servers often limit this to HTTP(S) port `80` and `443`only, this can technically be used to tunnel any TCP/IP-based protocol (HTTP, SMTP, IMAP etc.). This library provides a simple API to create these tunneled connections for you. Because it implements ReactPHP's standard [`ConnectorInterface`](https://github.com/reactphp/socket#connectorinterface), it can simply be used in place of a normal connector. This makes it fairly simple to add SOCKS proxy support to pretty much any existing higher-level protocol implementation. Besides the client side, it also provides a simple SOCKS server implementation which allows you to build your own SOCKS proxy servers with custom business logic.

- **Async execution of connections** - Send any number of SOCKS requests in parallel and process their responses as soon as results come in. The Promise-based design provides a *sane* interface to working with out of order responses and possible connection errors.
- **Standard interfaces** - Allows easy integration with existing higher-level components by implementing ReactPHP's standard [`ConnectorInterface`](https://github.com/reactphp/socket#connectorinterface).
- **Lightweight, SOLID design** - Provides a thin abstraction that is [*just good enough*](https://en.wikipedia.org/wiki/Principle_of_good_enough)and does not get in your way. Builds on top of well-tested components and well-established concepts instead of reinventing the wheel.
- **Good test coverage** - Comes with an automated tests suite and is regularly tested against actual proxy servers in the wild.

**Table of contents**

- [Support us](#support-us)
- [Quickstart example](#quickstart-example)
- [Usage](#usage)
    - [Client](#client)
        - [Plain TCP connections](#plain-tcp-connections)
        - [Secure TLS connections](#secure-tls-connections)
        - [HTTP requests](#http-requests)
        - [Protocol version](#protocol-version)
        - [DNS resolution](#dns-resolution)
        - [Authentication](#authentication)
        - [Proxy chaining](#proxy-chaining)
        - [Connection timeout](#connection-timeout)
        - [SOCKS over TLS](#socks-over-tls)
        - [Unix domain sockets](#unix-domain-sockets)
    - [Server](#server)
        - [Server connector](#server-connector)
        - [Authentication](#server-authentication)
        - [Proxy chaining](#server-proxy-chaining)
        - [SOCKS over TLS](#server-socks-over-tls)
        - [Unix domain sockets](#server-unix-domain-sockets)
- [Servers](#servers)
    - [Using a PHP SOCKS server](#using-a-php-socks-server)
    - [Using SSH as a SOCKS server](#using-ssh-as-a-socks-server)
    - [Using the Tor (anonymity network) to tunnel SOCKS connections](#using-the-tor-anonymity-network-to-tunnel-socks-connections)
- [Install](#install)
- [Tests](#tests)
- [License](#license)
- [More](#more)

Support us
----------

[](#support-us)

I maintain an ecosystem of open-source projects that have been downloaded hundreds of millions of times and are actively maintained and continuously improved. If you find any of these projects useful, please consider [becoming a sponsor on GitHub](https://github.com/sponsors/clue). Your support helps ensure long-term maintenance and continued development. Thank you! 🚀

Quickstart example
------------------

[](#quickstart-example)

Once [installed](#install), you can use the following code to send a secure HTTPS request to google.com through a local SOCKS proxy server:

```
