shadowsocks / shadowsocks-android

A shadowsocks client for Android
Other
35.23k stars 11.57k forks source link

Any version above 5.0.4 no longer works on IPv6 only network #2907

Open ijgnaig opened 2 years ago

ijgnaig commented 2 years ago

Please read contributing guidelines. Thanks.

Describe the bug From above version 5.0.4, the Android version of shadowsocks, shadowsocks-android no longer works on IPv6 only network, now it always resolves to IPv4 regardless of any configuration combination on both sides. PC clients like the rust and libev ports work as expected.

Server software: Arch Linux x86_64 with shadowsocks-rust 1.14.3 built from AUR Server network: IPv6 only Internet with IPv6 only dnscrypt client, no IPv4 local nor Internet address

To Reproduce Steps to reproduce the behavior:

  1. Connect to the server using its IPv6 address directly
  2. Click on Connected, tap to check connection
  3. Success: HTTPS handshake took N ms
  4. Open a browser, go to some dual stack sites, here web.telegram.org
  5. The browser returnes error connection closed
  6. On server side this line is registered on systemd: tcp tunnel [CLIENT_IPV6_ADDR]:40671 -> 149.154.167.99:443 connect failed, error: Network is unreachable (os error 101)
  7. 149.154.167.99 is actually the A record of web.telegram.org

Expected behavior shadowsocks-android either has an option to select which IP version to resolve first or its resolution behavior is determined by server side configuration, which enables ipv6_only and ipv6_first

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

Configuration Put an x inside the [ ] that applies.

Additional context

  1. Versions <= 5.0.4 work only if Bypass LAN & China route mode is selected, otherwise it will always resolve to IPv4 (For example you've selected All or GFWList)
  2. The Connected, tap to check connection works without problem. When checking connection, it resolves dns.google to 2001:4860:4860::8844 at first and then establishes a connection with IPv6
  3. Direct IPv6 connection without domain name resolution works without problem as well
  4. Server side configuration:

    
    {
    "server": "INBOUND_IPV6_ADDR",
    "server_port": 65535,
    "method": "none",
    "password": "PASSWORD",
    "local_address": "OUTBOUND_IPV6_ADDR",
    
    "dns": "udp://[::1]:53",
    "mode": "tcp_and_udp",
    
    "ipv6_first": true,
    "ipv6_only": true,
    
    "log": {
        "level": 1,
    },

}