p4gefau1t / trojan-go

Go实现的Trojan代理,支持多路复用/路由功能/CDN中转/Shadowsocks混淆插件,多平台,无依赖。A Trojan proxy written in Go. An unidentifiable mechanism that helps you bypass GFW. https://p4gefau1t.github.io/trojan-go/
GNU General Public License v3.0
7.54k stars 1.64k forks source link

[BUG] Trojan-go Use IPv6 for DNS on a Server with IPv6 Disabled #524

Open Dr-Incognito opened 5 months ago

Dr-Incognito commented 5 months ago

我们建议您按照下方模板填写 Bug Report,以便我们收集更多的有效信息

简单描述这个 Bug

The IPv6 has been disabled on the server.

➜  trojan-go sysctl net.ipv6.conf | grep disable_ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.docker0.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

But Trojan-go continuously uses IPv6 for DNS queries.

[ERROR] 2024/01/10 08:42:10 github.com/p4gefau1t/trojan-go/proxy.(*Proxy).relayPacketLoop.func1.1:proxy.go:141 lookup time.apple.com on [::1]:53: dial udp [::1]:53: connect: cannot assign requested address

The Trojan-go REALLY LOVES IPv6 although it is listening to IPv4 port 8443.

➜  trojan-go netstat -nxtlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      200/systemd-resolve 
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      295/nginx: master p 
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      200/systemd-resolve 
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      295/nginx: master p 
tcp        0      0 127.0.0.54:53           0.0.0.0:*               LISTEN      200/systemd-resolve 
tcp        0      0 a.b.c.d:8443            0.0.0.0:*               LISTEN      647/trojan-go       
tcp6       0      0 :::5355                 :::*                    LISTEN      200/systemd-resolve 

Both the server and client work (with the same config) well on another server containing IPv6.

如何复现这个 Bug

服务器和客户端环境信息

在此描述你的服务器和客户端所处的网络环境,系统架构,以及其他信息

服务端和客户端日志

[ERROR] 2024/01/10 08:42:09 github.com/p4gefau1t/trojan-go/proxy.(*Proxy).relayPacketLoop.func1.1:proxy.go:141 lookup time.apple.com on [::1]:53: dial udp [::1]:53: connect: cannot assign requested address
[ERROR] 2024/01/10 08:42:10 github.com/p4gefau1t/trojan-go/proxy.(*Proxy).relayPacketLoop.func1.1:proxy.go:141 lookup time.apple.com on [::1]:53: dial udp [::1]:53: connect: cannot assign requested address
[ERROR] 2024/01/10 08:42:10 github.com/p4gefau1t/trojan-go/proxy.(*Proxy).relayPacketLoop.func1.1:proxy.go:141 lookup time.apple.com on [::1]:53: dial udp [::1]:53: connect: cannot assign requested address

服务端和客户端配置文件

{
    "run_type": "server",
    "local_addr": "0.0.0.0",
    "local_port": 8443,
    "remote_addr": "127.0.0.1",
    "remote_port": 80,
    "password": [
    ],
    "log_level": 1,
    "log_file": "/var/log/trojan-go.log",
    "ssl": {
        "cert": "fullchain.pem",
        "key":  "privkey.pem",
        "sni": "example.com",
        "fallback_port": 443
    },
    "router": {
        "enabled": true,
        "block": [
            "geoip:private"
        ],
        "geoip": "/opt/trojan-go/geoip.dat",
        "geosite": "/opt/trojan-go/geosite.dat"
    }
}

服务端和客户端版本信息

Trojan-Go v0.10.6
Go Version: go1.17.1
OS/Arch: linux/amd64
Git Commit: 2dc60f52e79ff8b910e78e444f1e80678e936450

Developed by PageFault (p4gefau1t)
Licensed under GNU General Public License version 3
GitHub Repository:      https://github.com/p4gefau1t/trojan-go
Trojan-Go Documents:    https://p4gefau1t.github.io/trojan-go/

其他信息

N/A