hysteria icon indicating copy to clipboard operation
hysteria copied to clipboard

[zh] 关于IPv6在浏览器上的fallback问题

Open awawa42 opened this issue 2 years ago • 2 comments

服务器

lsb_release -a

Description: Debian GNU/Linux 11 (bullseye)

hysteria -v

hysteria version v1.3.3 2023-02-08 06:12:21 a48d6ddb7c83d605ef0d7f8ebe51515438a85a3a

cat /etc/hysteria/server.json

{
  "listen": ":12345",
  "alpn":"h3",
  "protocol": "udp",
  "cert": "/etc/hysteria/1.crt",
  "key": "/etc/hysteria/1.key",
  "auth":{
      "mode":"password",
      "config":["mask"]
      },
  "resolve_preference": "64",
  "up_mbps": 1000,
  "down_mbps": 1000
}

客户端

lsb_release -a

Description: Debian GNU/Linux 11 (bullseye)

hysteria -v

hysteria version v1.3.3 2023-02-08 06:12:21 a48d6ddb7c83d605ef0d7f8ebe51515438a85a3a

cat test.json

{
  "server": "mask",
  "alpn":"h3",
  "auth_str": "mask",
  "protocol": "udp",
  "up_mbps": 30,
  "down_mbps": 300,
  "ca":"/etc/hysteria/SelfCA.crt",
  "socks5": {
    "listen": "[::]:2010"
  },
  "http": {
    "listen": "[::]:2011"
  }
}

一台Window 11 上的Google Chrome通过socks5连接到局域网的Hysteria客户端 版本

Version 110.0.5481.97 (Official Build) (64-bit)

问题

浏览器访问https://ipv6-test.com/

Fallback No

客户端日志

[INFO] [src:192.0.0.0:52330] [dst:fallback-v6.ipv6-test.com:443] [error:connection rejected: dial tcp [2001:41d0:701:1100::fa11:bac]:443: i/o timeout] SOCKS5 TCP error

在服务器上 dig fallback-v6.ipv6-test.com

fallback-v6.ipv6-test.com. 120 IN A 51.75.78.103

dig fallback-v6.ipv6-test.com aaaa

fallback-v6.ipv6-test.com. 120 IN AAAA 2001:41d0:701:1100::fa11:bac

2001:41d0:701:1100::fa11:bac 这个v6地址ping不通,v4是通的

curl fallback-v6.ipv6-test.com -vv

*   Trying 2001:41d0:701:1100::fa11:bac:80...
*   Trying 51.75.78.103:80...
* Connected to fallback-v6.ipv6-test.com (51.75.78.103) port 80 (#0)
> GET / HTTP/1.1
> Host: fallback-v6.ipv6-test.com
> User-Agent: curl/7.74.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 301 Moved Permanently
< Date: Tue, 14 Feb 2023 09:46:35 GMT
< Server: Apache/2.4.25 (Debian)
< Location: https://ipv6-test.com/
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8

客户端

curl fallback-v6.ipv6-test.com -x socks5h://127.0.0.1:2010 -vv

*   Trying 127.0.0.1:2010...
* SOCKS5 connect to fallback-v6.ipv6-test.com:80 (remotely resolved)
* Can't complete SOCKS5 connection to fallback-v6.ipv6-test.com. (4)
* Closing connection 0
curl: (97) Can't complete SOCKS5 connection to fallback-v6.ipv6-test.com. (4)

换 shadowsocks-rust 在同个服务器上建的代理则没有问题 curl fallback-v6.ipv6-test.com -x socks5h://127.0.0.1:2020 -vv

*   Trying 127.0.0.1:2020...
* SOCKS5 connect to fallback-v6.ipv6-test.com:80 (remotely resolved)
* SOCKS5 request granted.
* Connected to 127.0.0.1 (127.0.0.1) port 2020 (#0)
> GET / HTTP/1.1
> Host: fallback-v6.ipv6-test.com
> User-Agent: curl/7.74.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 301 Moved Permanently
< Date: Tue, 14 Feb 2023 09:52:38 GMT
< Server: Apache/2.4.25 (Debian)
< Location: https://ipv6-test.com/
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
<

局域网中的浏览器访问 https://ipv6-test.com/ 也显示支持fallback xray也没有问题,结果就不再贴了

请问这是bug还是配置文件有问题,帮帮我,感谢

awawa42 avatar Feb 14 '23 10:02 awawa42

目前的实现确实没有做到 IPv6 连不上的情况下重试 IPv4 。 看来 Resolver 相关方法应该变成同时返回 IPv4 和 IPv6 地址, 再根据 resolve_preference 设置来进行请求和 fallback 。

haruue avatar Feb 14 '23 11:02 haruue

这个不是bug,这个是系统的机制,

f4nff avatar Feb 14 '23 12:02 f4nff