janfish / swooxy
An HTTP proxy server based on swoole
dev-master
2019-11-18 13:38 UTC
Requires
- php: >=7.1.0
- ext-swoole: 4.4.*
This package is not auto-updated.
Last update: 2025-03-05 07:11:56 UTC
README
An HTTP proxy server based on swoole
Feature
- Http proxy
- Https proxy
- Request filters
Installation
composer require janfish/swooxy -vvv
How to use
- Standard mode
$proxy = new \Swooxy\Server(); $proxy->listen();
- Use coroutine client
$proxy = new \Swooxy\Coroutine\Server(); $proxy->listen();
- Define host and port
$proxy = new \Swooxy\Server([ 'daemonize' => false, ]); $proxy->listen('0.0.0.0', 10086);
- Filter mode
$proxy = new \Swooxy\Server([ 'daemonize' => false, ]); $proxy->setFilter([ Rule::class, Log::class, ]); $proxy->listen('0.0.0.0', 10086);
How to add a request filter
use Swooxy\Filter\Base; use Swooxy\Protocol\Http; /** * Author:Robert * * Class Filter */ class Rule extends Base { /** * Author:Robert * * @param Http $http * @return bool */ public function run(Http $http): bool { print_r([ 'method' => $http->getMethod(), 'host' => $http->getHost(), 'port' => $http->getPort(), 'url' => $http->getUrl(), 'header' => $http->getHeaders(), 'body' => $http->getBody(), 'isIpv6' => $http->isIpv6(), ]); return true; } }