https://github.com/postuf/socksproxyasync
Lightweight asynchronous socks proxy client for PHP
https://github.com/postuf/socksproxyasync
async php proxy socket
Last synced: about 1 year ago
JSON representation
Lightweight asynchronous socks proxy client for PHP
- Host: GitHub
- URL: https://github.com/postuf/socksproxyasync
- Owner: Postuf
- License: mit
- Created: 2019-12-24T12:40:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-16T04:29:37.000Z (over 2 years ago)
- Last Synced: 2025-04-09T22:07:49.597Z (about 1 year ago)
- Topics: async, php, proxy, socket
- Language: PHP
- Homepage:
- Size: 208 KB
- Stars: 4
- Watchers: 2
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SocksProxyAsync
Asynchronous SOCKS5 client library
[](https://gitpod.io/#https://github.com/Postuf/SocksProxyAsync)
[](https://codecov.io/gh/Postuf/SocksProxyAsync)
## Requirements
* PHP 7.4+
* Composer
* ext-sockets
## Quick start
First of all, add library to your app user `composer`:
```
composer require postuf/socks-proxy-async
```
## How it works
Say, you have a socket and an event loop:
```
$socket = new SocketAsync(/* ... */);
while(true) {
// process events
if (!$socket->ready()) {
$socket->poll();
} else {
// your logic ...
}
}
```
We create socket, set [socket_set_nonblock](https://www.php.net/manual/ru/function.socket-set-nonblock.php), when socket is connected, `isReady` flag is set.
Internal logic is organized as state machine. You can extend it and add more steps, so that only `$socket->poll()` is called on event loop, then you just check the state and process received updates.
## Testing
Tests require working proxy and http server to be up and running, use `node/proxy.js` to start proxy, `node/http/start.sh` (`./start.sh` within its subdir) to start http server.
By default, http server runs on port 8080, proxy occupies port 1080, tests use these ports.
DNS-related tests require dns server (`node/named.js`) to be up and running.
### Make commands
- make all - run all checks
- make test - run tests
- make cs - run codesniffer checks
- make psalm - run psalm checks
- make stan - run stan checks
- make cs - run stan and psalm checks
- make get-security - get security checker
- make security - run security checker