v2ray / v2ray-core

A platform for building proxies to bypass network restrictions.
https://www.v2ray.com/
MIT License
45.37k stars 8.94k forks source link

[Solved] Shadowsocks 开启 HTTP 伪装后,浏览器与 v2ray 进行 SOCKS5 握手失败 #389

Closed oing9179 closed 7 years ago

oing9179 commented 7 years ago

操作系统:Ubuntu 16.04 x86_64 (kernel: 4.4.0-53-generic) V2Ray版本:V2Ray v2.18 (One for all) 20170210

具体问题描述

同一主机 同一个v2ray可执行文件 运行两个v2ray进程,一个使用客户端配置文件 另一个用服务器配置文件。 在未开启 HTTP 伪装的情况下(也就是配置文件里的 transport.tcpSettings.header.type = none 的情况下),可以正常的通过v2ray访问baidu.com。Wireshark 抓包如下图所示:

Shadowsocks without HTTP shell.

开启 HTTP 伪装后(transport.tcpSettings.header.type = http),浏览器尝试向v2ray进行SOCKS5握手,但过了8秒后v2ray直接返回连SOCKS5响应头都不带的HTTP 500响应。Wireshark 抓包如下图所示:

Shadowsocks with HTTP shell.

已用 Wireshark 导出 pacpng 文件,需要的话我可贴出来。

日志

客户端日志(除下面两行以外 剩下的都是重复的):

2017/02/12 17:34:32 [Info]Socks|Server: Failed to read request: Socks|Server: Insufficient header. >  
read tcp 127.0.0.1:1085->127.0.0.1:40962: i/o timeout   
2017/02/12 17:34:32 [Info]Proxyman|TCPWorker: Connection ends with Socks|Server: Insufficient header  
. > read tcp 127.0.0.1:1085->127.0.0.1:40962: i/o timeout

服务器端无日志。

配置文件

客户端配置文件: 配置文件里的 dns 使用了 127.0.0.1,因为我在本地开了个dns服务器。

{
  "log": {
    "loglevel": "debug"
  },
  "inbound": {
    "protocol": "socks",
    "listen": "127.0.0.1",
    "port": 1085,
    "settings": {
      "auth": "noauth",
      "udp": true,
      "timeout": 30
    }
  },
  "outbound": {
    "protocol": "shadowsocks",
    "settings": {
      "servers": [
        {
          "address": "127.0.0.1",
          "port": 34302,
          "method": "aes-128-cfb",
          "password": "NnfV46nqYr844EQm",
          "ota": false
        }
      ]
    },
    "streamSettings": {
      "network": "tcp"
    }
  },
  "inboundDetour": [],
  "outboundDetour": [
    {
      "protocol": "freedom",
      "settings": {},
      "tag": "direct"
    }
  ],
  "dns": {
    "servers": ["127.0.0.1"]
  },
  "routing": {
    "strategy": "rules",
    "settings": {
      "domainStrategy": "IPIfNonMatch",
      "rules": [
        {
          "type": "field",
          "ip": [
            "0.0.0.0/8",
            "10.0.0.0/8",
            "100.64.0.0/10",
            "127.0.0.0/8",
            "169.254.0.0/16",
            "172.16.0.0/12",
            "192.0.0.0/24",
            "192.0.2.0/24",
            "192.168.0.0/16",
            "198.18.0.0/15",
            "198.51.100.0/24",
            "203.0.113.0/24",
            "::1/128",
            "fc00::/7",
            "fe80::/10"
          ],
          "outboundTag": "direct"
        }
      ]
    }
  },
  "transport": {
    "tcpSettings": {
      "connectionReuse": false,
      "header": {
        "type": "http",
        "request": {
          "version": "1.1",
          "method": "GET",
          "path": ["/"],
          "headers": {
            "Host": ["www.baidu.com", "www.bing.com"],
            "User-Agent": [
              "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
              "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46"
            ],
            "Accept-Encoding": ["gzip, deflate"],
            "Connection": ["keep-alive"],
            "Pragma": "no-cache"
          }
        },
        "response": {
          "version": "1.1",
          "status": "200",
          "reason": "OK",
          "headers": {
            "Content-Type": ["application/octet-stream", "video/mpeg"],
            "Transfer-Encoding": ["chunked"],
            "Connection": ["keep-alive"],
            "Pragma": "no-cache"
          }
        }
      }
    },
    "wsSettings": {
      "connectionReuse": false,
      "path": "/ws"
    }
  }
}

服务器配置文件:

{
  "log": {
    "loglevel": "debug"
  },
  "inbound": {
    "listen": "127.0.0.1",
    "port": 34302,
    "protocol": "shadowsocks",
    "settings": {
      "method": "aes-128-cfb",
      "password": "NnfV46nqYr844EQm",
      "udp": true,
      "level": 1,
      "ota": false
    },
    "streamSettings": {
      "network": "tcp"
    }
  },
  "outbound": {
    "protocol": "freedom",
    "settings": {
      "timeout": 30
    }
  },
  "outboundDetour": [
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    }
  ],
  "routing": {
    "strategy": "rules",
    "settings": {
      "rules": [
        {
          "type": "field",
          "ip": [
            "0.0.0.0/8",
            "10.0.0.0/8",
            "100.64.0.0/10",
            "127.0.0.0/8",
            "169.254.0.0/16",
            "172.16.0.0/12",
            "192.0.0.0/24",
            "192.0.2.0/24",
            "192.168.0.0/16",
            "198.18.0.0/15",
            "198.51.100.0/24",
            "203.0.113.0/24",
            "::1/128",
            "fc00::/7",
            "fe80::/10"
          ],
          "outboundTag": "blocked"
        }
      ]
    }
  },
  "transport": {
    "tcpSettings": {
      "connectionReuse": false,
      "header": {
        "type": "http",
        "request": {
          "version": "1.1",
          "method": "GET",
          "path": ["/"],
          "headers": {
            "Host": ["www.baidu.com", "www.bing.com"],
            "User-Agent": [
              "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
              "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46"
            ],
            "Accept-Encoding": ["gzip, deflate"],
            "Connection": ["keep-alive"],
            "Pragma": "no-cache"
          }
        },
        "response": {
          "version": "1.1",
          "status": "200",
          "reason": "OK",
          "headers": {
            "Content-Type": ["application/octet-stream", "video/mpeg"],
            "Transfer-Encoding": ["chunked"],
            "Connection": ["keep-alive"],
            "Pragma": "no-cache"
          }
        }
      }
    },
    "wsSettings": {
      "connectionReuse": false,
      "path": "/ws"
    }
  }
}
v2ray commented 7 years ago

全局传输设置就是这样的,伪装设置请放到分连接的配置下。

oing9179 commented 7 years ago

原来是这样,谢谢。 问题已解决。