Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jpcaparas/laravel-http-socks5
A repository for Laravel HTTP SOCKS5 proxy support
https://github.com/jpcaparas/laravel-http-socks5
Last synced: about 10 hours ago
JSON representation
A repository for Laravel HTTP SOCKS5 proxy support
- Host: GitHub
- URL: https://github.com/jpcaparas/laravel-http-socks5
- Owner: jpcaparas
- Created: 2025-01-03T01:20:44.000Z (18 days ago)
- Default Branch: main
- Last Pushed: 2025-01-03T08:52:11.000Z (18 days ago)
- Last Synced: 2025-01-03T09:39:15.945Z (18 days ago)
- Language: PHP
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Laravel HTTP client macro for SOCKS5 proxying
![Tests](https://github.com/jpcaparas/laravel-http-socks5/actions/workflows/tests.yml/badge.svg)
This package extends the Laravel HTTP service to allow for easy, parameterised SOCKS5 proxying
## Installation
You can install the package via composer:
```bash
composer require jpcaparas/laravel-http-socks5
```## Usage
### Registering the Service Provider
Add the service provider to your `config/app.php`:
```php
'providers' => [
// ...
JPCaparas\Socks5Proxy\Socks5ProxyServiceProvider::class,
],
```### Setting up the SOCKS5 Proxy
To use the SOCKS5 proxy, you can utilize the fluent interface:
```php
use Illuminate\Support\Facades\Http;$response = Http::socks5()
->setHost('proxy.example.com')
->setPort(1080)
->setCredentials('username', 'password')
->get('http://example.com');
```### Method Chaining
You can chain multiple configuration methods:
```php
use Illuminate\Support\Facades\Http;$client = Http::socks5()
->setHost('proxy.example.com')
->setCredentials('username', 'password')
->withOptions([
'debug' => true,
'timeout' => 30
]);$response = $client->post('https://api.example.com/data', [
'key' => 'value'
]);
```### Debugging the Response
Enable debugging to see detailed connection information:
```php
use Illuminate\Support\Facades\Http;$response = Http::socks5()
->setHost('proxy.example.com')
->setCredentials('username', 'password')
->withOptions(['debug' => true])
->get('http://example.com');
```## Tests
```bash
composer test
```## Trying it out
You can experiment with the package using Laravel Tinker. First, run:
```bash
composer tinker
```Then try this example (outputs detailed connection info):
```php
$client = \Illuminate\Support\Facades\Http::socks5()
->setHost('amsterdam.nl.socks.nordhold.net')
->setCredentials('username', 'password');$client->withOptions(['debug' => true])->get('https://www.google.com');
```Example output:
```
* Host amsterdam.nl.socks.nordhold.net:1080 was resolved.
* IPv6: (none)
* IPv4: [REDACTED]
* Trying [REDACTED]:1080...
* Host www.google.com:443 was resolved.
* IPv6: [REDACTED]
* IPv4: [REDACTED]
* SOCKS5 connect to [REDACTED]:443 (locally resolved)
* SOCKS5 request granted.
* Connected to amsterdam.nl.socks.nordhold.net port 1080
[...]
* SSL connection using TLSv1.3
* Server certificate verified
> GET / HTTP/1.1
Host: www.google.com
[...]
< HTTP/1.1 200 OK
< Date: Fri, 03 Jan 2025 08:14:37 GMT
[...]
```