Xray-core icon indicating copy to clipboard operation
Xray-core copied to clipboard

流量经过loopback后,再次路由时无法将域名解析为ip进行匹配

Open zxd65885152 opened this issue 2 years ago • 8 comments

Xray版本

1.5.4

问题描述

流量经过loopback后再次进入路由,但不根据domainStrategy的配置将域名解析为IP,也不发起dns请求,因此无法匹配基于ip的规则 将loopback跳开后恢复正常

客户端配置

{
    "log":{
        "access":"",
        "error":"",
        "loglevel":"debug",
        "dnsLog":true
    },
    "dns":{
        "tag":"dns_inbound",
        "servers":[
            {
                "address":"223.5.5.5",
                "expectIPs":[
                    "geoip:cn",
                    "geoip:private"
                ]
            },
            "8.8.8.8"
        ]
    },
    "routing":{
        "domainStrategy":"IPOnDemand",
        "rules":[
            {
                "type":"field",
                "inboundTag":[
                    "dns_inbound",
                    "socks",
                    "http"
                ],
                "outboundTag":"loop_po"
            },
            {
                "type":"field",
                "inboundTag":[
                    "loop_po_loop"
                ],
                "ip":[
                    "geoip:cn",
                    "geoip:private"
                ],
                "outboundTag":"direct"
            },
            {
                "type":"field",
                "inboundTag":[
                    "loop_po_loop"
                ],
                "outboundTag":"proxy"
            }
        ]
    },
    "inbounds":[
        {
            "tag":"socks",
            "listen":"127.0.0.1",
            "port":10808,
            "protocol":"socks",
            "settings":{
                "udp":true
            }
        },
        {
            "tag":"http",
            "listen":"127.0.0.1",
            "port":10809,
            "protocol":"http"
        }
    ],
    "outbounds":[
        {
            "tag":"block",
            "protocol":"blackhole"
        },
        {
            "tag":"direct",
            "protocol":"freedom",
            "settings":{
                "domainStrategy":"UseIP"
            }
        },
        {
            "tag":"loop_po",
            "protocol":"loopback",
            "settings":{
                "inboundTag":"loop_po_loop"
            }
        },
        {
            "tag":"proxy",
            "protocol":"vless",
            "settings":{
                "vnext":[
                    {
                        "address":"",
                        "port":443,
                        "users":[
                            {
                                "id":"",
                                "encryption":"none"
                            }
                        ]
                    }
                ]
            },
            "streamSettings":{
                "network":"ws",
                "security":"tls",
                "tlsSettings":{
                    "serverName":"",
                    "allowInsecure":false,
                    "fingerprint":"chrome"
                },
                "wsSettings":{
                    "path":"",
                    "headers":{
                        "host":""
                    }
                }
            }
        }
    ]
}

客户端日志

Xray 1.5.4 (Xray, Penetrates Everything.) Custom (go1.17.7 windows/amd64)
A unified platform for anti-censorship.
2022/03/25 01:11:22 Using default config:  
2022/03/25 01:11:22 [Info] infra/conf/serial: Reading config: 
2022/03/25 01:11:23 [Debug] app/log: Logger started
2022/03/25 01:11:23 [Info] app/dns: DNS: created UDP client initialized for 223.5.5.5:53
2022/03/25 01:11:23 [Info] app/dns: DNS: created UDP client initialized for 8.8.8.8:53
2022/03/25 01:11:23 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:10808
2022/03/25 01:11:23 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:10809
2022/03/25 01:11:23 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:10808
2022/03/25 01:11:23 [Info] transport/internet/udp: listening UDP on 127.0.0.1:10808
2022/03/25 01:11:23 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:10809
2022/03/25 01:11:23 [Warning] core: Xray 1.5.4 started
2022/03/25 01:11:31 [Info] [1670189940] proxy/socks: TCP Connect request to tcp:www.baidu.com:443
2022/03/25 01:11:31 [Info] [1670189940] app/dispatcher: taking detour [loop_po] for [tcp:www.baidu.com:443]
2022/03/25 01:11:31 [Info] [1670189940] proxy/loopback: opening connection to tcp:www.baidu.com:443
2022/03/25 01:11:31 [Info] [1670189940] app/dispatcher: taking detour [proxy] for [tcp:www.baidu.com:443]
2022/03/25 01:11:31 tcp:127.0.0.1:5646 accepted tcp:www.baidu.com:443 [loop_po]
2022/03/25 01:11:31 tcp:127.0.0.1:5646 accepted tcp:www.baidu.com:443 [proxy]
2022/03/25 01:11:31 [Info] [1670189940] transport/internet/websocket: creating connection to tcp:代理:443
2022/03/25 01:11:31 [Info] [1670189940] proxy/vless/outbound: tunneling request to tcp:www.baidu.com:443 via 代理:443
2022/03/25 01:11:31 [Debug] transport/internet: dialing to tcp:代理:443
2022/03/25 01:11:32 [Info] [1670189940] app/proxyman/outbound: failed to process outbound traffic > proxy/loopback: connection ends > context canceled
2022/03/25 01:11:32 [Info] [1670189940] app/proxyman/inbound: connection ends > proxy/socks: connection ends > context canceled
2022/03/25 01:11:32 [Info] [1670189940] app/proxyman/outbound: failed to process outbound traffic > proxy/vless/outbound: connection ends > context canceled

zxd65885152 avatar Mar 24 '22 17:03 zxd65885152

发完去隔壁看了一下,有人提了相同的问题。。 https://github.com/v2fly/v2ray-core/issues/1691

不过那个日志里有dns解析的记录,但应该是由于将流量转发进loopback的规则也是ip规则,在进入loopback前都是正常解析和匹配的。。因此问题应该是一样的。。

zxd65885152 avatar Mar 24 '22 17:03 zxd65885152

这个loopback估计只是给它打了个tag 不根据入站的配置进一步处理 不行开routeonly

Fangliding avatar Apr 14 '24 17:04 Fangliding

没有太理解什么叫开 开routeonly

zxd65885152 avatar Apr 15 '24 06:04 zxd65885152

麻烦reopen一下 我一直在关注 但是无人回复 这不是陈旧issue

zxd65885152 avatar Apr 15 '24 06:04 zxd65885152

麻烦reopen一下 我一直在关注 但是无人回复 这不是陈旧issue

好吧 那按那个issue的说法 你把content.SkipDNSResolve那去掉编译再试试? 暂时不知道为啥这样设置 为了防止死循环?

Fangliding avatar Apr 15 '24 07:04 Fangliding

SkipDNSResolve那个我也看到了 我也没搞懂为啥进入loopback后直接屏蔽了dns解析。。 主要我不是golang开发者 搭环境会需要一些时间 这个issue能不能不关呢

zxd65885152 avatar Apr 15 '24 08:04 zxd65885152

@zxd65885152 你fork一个仓库开开action 然后去编辑之后 action会自动编译 再进去下就行了

Fangliding avatar Apr 15 '24 08:04 Fangliding