承接 jpcaparas/laravel-http-socks5 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jpcaparas/laravel-http-socks5

最新稳定版本:v0.1.3

Composer 安装命令:

composer require jpcaparas/laravel-http-socks5

包简介

Extends the Laravel HTTP service to allow for easy SOCKS5 proxying and provides the ability to debug the response.

README 文档

README

Tests

This package extends the Laravel HTTP service to allow for easy, parameterised SOCKS5 proxying

Installation

You can install the package via composer:

composer require jpcaparas/laravel-http-socks5

Usage

Registering the Service Provider

Add the service provider to your config/app.php:

'providers' => [
    // ...
    JPCaparas\Socks5Proxy\Socks5ProxyServiceProvider::class,
],

Setting up the SOCKS5 Proxy

To use the SOCKS5 proxy, you can utilize the fluent interface:

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:

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:

use Illuminate\Support\Facades\Http;

$response = Http::socks5()
    ->setHost('proxy.example.com')
    ->setCredentials('username', 'password')
    ->withOptions(['debug' => true])
    ->get('http://example.com');

Tests

composer test

Trying it out

You can experiment with the package using Laravel Tinker. First, run:

composer tinker

Then try this example (outputs detailed connection info):

$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
[...]

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-03