apernet / hysteria

Hysteria is a powerful, lightning fast and censorship resistant proxy.
https://v2.hysteria.network/
MIT License
15.04k stars 1.67k forks source link

链式代理比直连更快表现异常 #866

Closed dreamren closed 11 months ago

dreamren commented 11 months ago

描述问题 服务器上部署有xray和hysteria2,hysteria2使用基础配置,客户端是由两台Linux容器组成,一台(192.168.6.111)使用hysteria2在1080端口提供socks5,另外一台(192.168.6.2)使用xray做为透明代理网关,网关上配有名为"hy2"和"vless_hy2"的outbounds,vless_hy2使用hy2进行转发。 经过xray的observatory和curl测试发现,vless_hy2要比hy2快,vless_hy2需要大约0.19s,hy2需要0.37s,表现非常异常。 curl测试是使用第三台Linux容器(走vless_hy2),分别使用服务器本地部署的http服务和cp.cloudflare.com 测试均测试出同样的结果 time curl VPSIP real 0m0.191s user 0m0.006s sys 0m0.006s time curl VPSIP --socks5 192.168.6.111:1080 real 0m0.370s user 0m0.004s sys 0m0.008s time curl cp.cloudflare.com --socks5 192.168.6.111:1080 real 0m0.384s user 0m0.004s sys 0m0.009s time curl cp.cloudflare.com real 0m0.208s user 0m0.004s sys 0m0.008s

下面是xray相关配置:

{
  "outbounds": [{
    "protocol": "socks",
    "tag": "hy2",
    "settings": {
      "servers": [
        {
          "address": "192.168.6.111",
          "port": 1080,
          "users": []
        }
      ]
    },
    "streamSettings": {
      "sockopt": {
        "mark": 255
      }
    }
  }]
}
{
    "outbounds": [{
        "protocol": "vless",
        "tag": "vless_hy2",
        "mux": {"enabled": false,"concurrency": 1},
        "settings": {
          "vnext": [
            {
              "address": "127.0.0.1",
              "port": 8443,
              "users": [
                {
                  "encryption": "none",
                  "id": "xxxxxxxxx"
                }
              ]
            }
          ]
        },
        "streamSettings": {
          "network": "grpc",
          "security": "tls",
          "tlssettings": {
            "allowInsecure": true,
            "serverName": "xxxx"
          },
          "grpcSettings": {
            "serviceName": "xxx",
            "multiMode": true,
            "initial_windows_size": 65536
          },
          "sockopt": {
            "mark": 255,
            "dialerProxy": "hy2"
          }
        }
     }]
}

如何复现 在服务端和客户端部署xray作为前置,再通过hysteria2进行转发,对比嵌套hysteria2的xray速度和hysteria2直连速度

预期行为 hy2快于vless_hy2。

日志 2023/12/14 10:00:22 [Info] app/observatory: the outbound vless_hy2 is alive:0.194575285 2023/12/14 10:01:33 [Info] app/observatory: the outbound vless_hy2 is alive:0.188193609 2023/12/14 10:02:45 [Info] app/observatory: the outbound vless_hy2 is alive:0.196229471 2023/12/14 10:03:56 [Info] app/observatory: the outbound vless_hy2 is alive:0.189241922 2023/12/14 10:05:08 [Info] app/observatory: the outbound vless_hy2 is alive:0.188932155 2023/12/14 10:06:19 [Info] app/observatory: the outbound vless_hy2 is alive:0.189562225 2023/12/14 10:07:30 [Info] app/observatory: the outbound vless_hy2 is alive:0.186838376 2023/12/14 10:08:42 [Info] app/observatory: the outbound vless_hy2 is alive:0.188227568 2023/12/14 10:09:54 [Info] app/observatory: the outbound vless_hy2 is alive:0.188310035

2023/12/14 10:00:32 [Info] app/observatory: the outbound hy2 is alive:0.368869801 2023/12/14 10:01:44 [Info] app/observatory: the outbound hy2 is alive:0.366175571 2023/12/14 10:02:55 [Info] app/observatory: the outbound hy2 is alive:0.370707951 2023/12/14 10:04:07 [Info] app/observatory: the outbound hy2 is alive:0.381860145 2023/12/14 10:05:18 [Info] app/observatory: the outbound hy2 is alive:0.368273291 2023/12/14 10:06:29 [Info] app/observatory: the outbound hy2 is alive:0.368716895 2023/12/14 10:07:40 [Info] app/observatory: the outbound hy2 is alive:0.368685809 2023/12/14 10:08:52 [Info] app/observatory: the outbound hy2 is alive:0.367208633 2023/12/14 10:10:04 [Info] app/observatory: the outbound hy2 is alive:0.365872588

设备和操作系统 服务端Ubuntu 22.04.3 LTS x86 客户端Debian GNU/Linux 10 x86

tobyxdd commented 11 months ago

打开 fast open 呢

https://v2.hysteria.network/zh/docs/advanced/Full-Client-Config/#fast-open

dreamren commented 11 months ago

打开 fast open 呢

https://v2.hysteria.network/zh/docs/advanced/Full-Client-Config/#fast-open

有效,直连确实更快了