如下代码
<?php
$ch = curl_init('httpbin.org/ip');
curl_setopt($ch, CURLOPT_PROXY, 'socks5://user1:[email protected]:1080');
curl_exec($ch);
curl_setopt($ch, CURLOPT_PROXY, 'socks5://another_user:[email protected]:1080'); // 切换用户
curl_exec($ch);
在 socks5 服务器中,只看得到第一次连接时的用户验证信息,第二次连接没有验证过程
复用了链接而不重新发起 socks5 验证
* Found bundle for host httpbin.org: 0x55ab9a6ec800
* Re-using existing connection! (#0) with host 127.0.0.1
* Connected to 127.0.0.1 (127.0.0.1) port 1080 (#0)
详细日志
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Hostname was NOT found in DNS cache
* 54
* 235
* 212
* 238
* Connected to 127.0.0.1 (127.0.0.1) port 1080 (#0)
> GET /ip HTTP/1.1
Host: httpbin.org
User-Agent: GuzzleHttp/6.2.1 curl/7.38.0 PHP/7.0.16-1~dotdeb+8.1
< HTTP/1.1 200 OK
< Connection: keep-alive
* Server gunicorn/19.7.0 is not blacklisted
< Server: gunicorn/19.7.0
< Date: Mon, 20 Mar 2017 11:00:08 GMT
< Content-Type: application/json
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Content-Length: 30
< Via: 1.1 vegur
<
* Connection #0 to host httpbin.org left intact
{
"origin": "xx.xx.xx.xx"
}
* Found bundle for host httpbin.org: 0x55ab9a6ec800
* Re-using existing connection! (#0) with host 127.0.0.1
* Connected to 127.0.0.1 (127.0.0.1) port 1080 (#0)
> GET /ip HTTP/1.1
Host: httpbin.org
User-Agent: GuzzleHttp/6.2.1 curl/7.38.0 PHP/7.0.16-1~dotdeb+8.1
< HTTP/1.1 200 OK
< Connection: keep-alive
* Server gunicorn/19.7.0 is not blacklisted
< Server: gunicorn/19.7.0
< Date: Mon, 20 Mar 2017 11:00:13 GMT
< Content-Type: application/json
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Content-Length: 30
< Via: 1.1 vegur
<
* Connection #0 to host httpbin.org left intact
{
"origin": "xx.xx.xx.xx"
}
Re-using authenticated connection when unauthenticated
google 到类似的问题,7.42.0 修复了 NTLM 的问题
刚用 7.51.0 测试 socks5 的问题,还是会复用连接
1
pubby 2017-03-20 11:25:00 +08:00
httpbin.org/ip keepalive 了吧,这样第二个请求根本不用走代理
|
2
fuxkcsdn OP @pubby 确实是 keep alive 了,但它还是走代理的,只是复用了链接而不重新发起 socks5 验证
```shell * Found bundle for host httpbin.org: 0x55ab9a6ec800 * Re-using existing connection! (#0) with host 127.0.0.1 * Connected to 127.0.0.1 (127.0.0.1) port 1080 (#0) ``` 详细日志 ```shell * Hostname was NOT found in DNS cache * Trying 127.0.0.1... * Hostname was NOT found in DNS cache * 54 * 235 * 212 * 238 * Connected to 127.0.0.1 (127.0.0.1) port 1080 (#0) > GET /ip HTTP/1.1 Host: httpbin.org User-Agent: GuzzleHttp/6.2.1 curl/7.38.0 PHP/7.0.16-1~dotdeb+8.1 < HTTP/1.1 200 OK < Connection: keep-alive * Server gunicorn/19.7.0 is not blacklisted < Server: gunicorn/19.7.0 < Date: Mon, 20 Mar 2017 11:00:08 GMT < Content-Type: application/json < Access-Control-Allow-Origin: * < Access-Control-Allow-Credentials: true < Content-Length: 30 < Via: 1.1 vegur < * Connection #0 to host httpbin.org left intact { "origin": "xx.xx.xx.xx" } * Found bundle for host httpbin.org: 0x55ab9a6ec800 * Re-using existing connection! (#0) with host 127.0.0.1 * Connected to 127.0.0.1 (127.0.0.1) port 1080 (#0) > GET /ip HTTP/1.1 Host: httpbin.org User-Agent: GuzzleHttp/6.2.1 curl/7.38.0 PHP/7.0.16-1~dotdeb+8.1 < HTTP/1.1 200 OK < Connection: keep-alive * Server gunicorn/19.7.0 is not blacklisted < Server: gunicorn/19.7.0 < Date: Mon, 20 Mar 2017 11:00:13 GMT < Content-Type: application/json < Access-Control-Allow-Origin: * < Access-Control-Allow-Credentials: true < Content-Length: 30 < Via: 1.1 vegur < * Connection #0 to host httpbin.org left intact { "origin": "xx.xx.xx.xx" } ``` |
3
pubby 2017-03-21 01:28:42 +08:00 via Android
Socks5 协议里,每次连接才会认证用户,既然是连接复用,没有从新连接,只是在原来的连接上继续收发数据(HTTP 1.1 keepalive 的行为)。
你可以指定请求头部 Connection: close 来禁止 keepalive 试试 |