XTLS / Xray-core

Xray, Penetrates Everything. Also the best v2ray-core, with XTLS support. Fully compatible configuration.
https://t.me/projectXray
Mozilla Public License 2.0
22.8k stars 3.65k forks source link

android can't connect to server #3090

Closed astraiosmem closed 2 months ago

astraiosmem commented 4 months ago

pc端(win和linux)能正常运行,安卓端用v2rayNG显示可以连接,但是只能访问国内网站,vps无访问记录,也用过xray4Magisk模块运行,也手动安装运行了xray-core的安卓版,结果都一样,不挂代理可以ping通vps,ssh也能连上,配置如下(已移除自己的信息)

client config:
{
    "dns": {
      "servers": [
        {
          "address": "1.1.1.1",
          "domains": ["geosite:geolocation-!cn"]
        },
        {
          "address": "223.5.5.5",
          "domains": ["geosite:cn"],
          "expectIPs": ["geoip:cn"]
        },
        {
          "address": "114.114.114.114",
          "domains": ["geosite:cn"]
        },
        "localhost"
      ]
    },
    "routing": {
      "domainStrategy": "AsIs",
      "rules": [
        {
          "type": "field",
          "domain": ["geosite:category-ads-all"],
          "outboundTag": "block"
        },
        {
          "type": "field",
          "domain": ["geosite:cn"],
          "outboundTag": "direct"
        },
        {
          "type": "field",
          "ip": ["geoip:cn", "geoip:private"],
          "outboundTag": "direct"
        },
        {
          "type": "field",
          "domain": ["geosite:geolocation-!cn"],
          "outboundTag": "proxy"
        },
        {
          "type": "field",
          "ip": ["223.5.5.5"],
          "outboundTag": "direct"
        }
      ]
    },

    "inbounds": [
        {
            "listen": "127.0.0.1",
            "port": 10808,
            "protocol": "socks",
            "settings": {
                "udp": true
            },
            "sniffing": {
                "enabled": true,
                "destOverride": [
                    "http",
                    "tls",
                    "quic"
                ],
                "routeOnly": true
            }
        },
        {
          "tag": "http-in",
          "protocol": "http",
          "listen": "127.0.0.1", 
          "port": 10801 
        }

    ],
    "outbounds": [
        {
            "tag": "proxy",
            "protocol": "vless",
            "settings": {
                "vnext": [
                    {
                        "address": "xxxx",
                        "port": 443,
                        "users": [
                            {
                                "id": "xxxx",
                                "encryption": "none",
                                "flow": "xtls-rprx-vision"
                            }
                        ]
                    }
                ]
            },
            "streamSettings": {
                "network": "tcp",
                "security": "reality",
                "realitySettings": {
                    "fingerprint": "chrome",
                    "serverName": "www.samsung.com", 
                    "publicKey": "xxxxx", 
                    "spiderX": "", 
                    "shortId": "xxxx" 
                }
            }
        },
        {
          "tag": "direct",
          "protocol": "freedom"
        },
        {
          "tag": "block",
          "protocol": "blackhole"
        }

    ]
}

服务器端:

{
    "dns": {
      "servers": [
        "https+local://1.1.1.1/dns-query", 
        "localhost"
      ]
    },
    "routing": {
      "domainStrategy": "AsIs",
      "rules": [
        {
          "type": "field",
          "ip": [
            "geoip:private" 
          ],
          "outboundTag": "block" 
        },
        {
          "type": "field",
          "domain": [
            "geosite:category-ads-all" 
          ],
          "outboundTag": "block" 
        },
        {
          "type": "field",
          "domain": ["geosite:cn"],
          "outboundTag": "block"
        },
        {
          "type": "field",
          "ip": ["geoip:cn"],
          "outboundTag": "block"
        },
        {
          "type": "field",
          "protocol": ["bittorrent"],
          "outboundTag": "block"
        }
      ]
    },

    "inbounds": [
        {
            "port": 443,
            "protocol": "vless",
            "settings": {
                "clients": [
                    {
                        "id": "xxxx", 
                        "flow": "xtls-rprx-vision",
                        "level": 0,
                        "email": "xxxx"
                    }
                ],
                "decryption": "none",
                "fallbacks": [
                    {
                        "dest": 1310, // Fall back to Xray's Trojan protocol by default
                        "xver": 1
                    },
                    {
                        "path": "/websocket", // Must be replaced with a custom PATH
                        "dest": 1234,
                        "xver": 1
                    },
                    {
                        "path": "/vmesstcp", // Must be replaced with a custom PATH
                        "dest": 2345,
                        "xver": 1
                    },
                    {
                        "path": "/vmessws", // Must be replaced with a custom PATH
                        "dest": 3456,
                        "xver": 1
                    }
                ]
            },
            "streamSettings": {
                "network": "tcp",
                "security": "reality",
                "realitySettings": {
                    "dest": "www.samsung.com:443", 
                    "serverNames": [
                        "www.samsung.com"   
                    ],
                    "privateKey": "xxxxx", 
                    "shortIds": [ 
                        "xxxxxxxx" 
                    ]
                }
            },
            "sniffing": {
                "enabled": true,
                "destOverride": [
                    "http",
                    "tls",
                    "quic"
                ],
                "routeOnly": true
            }
        },
        {
            "port": 1310,
            "listen": "127.0.0.1",
            "protocol": "trojan",
            "settings": {
                "clients": [
                    {
                        "password": "xxxx",
                        "level": 0,
                        "email": "xxxxx"
                    }
                ],
                "fallbacks": [
                    {
                        "dest": 80 
                    }
                ]
            },
            "streamSettings": {
                "network": "tcp",
                "security": "none",
                "tcpSettings": {
                    "acceptProxyProtocol": true
                }
            }
        },
        {
            "port": 1234,
            "listen": "127.0.0.1",
            "protocol": "vless",
            "settings": {
                "clients": [
                    {
                        "id": "xxxx", 
                        "level": 0,
                        "email": "xxxx"
                    }
                ],
                "decryption": "none"
            },
            "streamSettings": {
                "network": "ws",
                "security": "none",
                "wsSettings": {
                    "acceptProxyProtocol": true, 
                    "path": "/websocket" 
                }
            }
        },
        {
            "port": 2345,
            "listen": "127.0.0.1",
            "protocol": "vmess",
            "settings": {
                "clients": [
                    {
                        "id": "xxxxx", 
                        "level": 0,
                        "email": "xxxxx"
                    }
                ]
            },
            "streamSettings": {
                "network": "tcp",
                "security": "none",
                "tcpSettings": {
                    "acceptProxyProtocol": true,
                    "header": {
                        "type": "http",
                        "request": {
                            "path": [
                                "/vmesstcp" 
                            ]
                        }
                    }
                }
            }
        },
        {
            "port": 3456,
            "listen": "127.0.0.1",
            "protocol": "vmess",
            "settings": {
                "clients": [
                    {
                        "id": "xxxx", 
                        "level": 0,
                        "email": "xxxxx"
                    }
                ]
            },
            "streamSettings": {
                "network": "ws",
                "security": "none",
                "wsSettings": {
                    "acceptProxyProtocol": true, 
                    "path": "/vmessws" 
                }
            }
        }
    ],
    "outbounds": [
        {
            "tag": "direct",
            "protocol": "freedom"
        },
        {
            "tag": "block",
            "protocol": "blackhole"
        }
      ]
}
yuhan6665 commented 4 months ago

看日志

astraiosmem commented 4 months ago

看日志

v2rayNG日志:

--------- beginning of main
03-06 21:32:52.637 I/GoLog   (30994): loading core config
03-06 21:32:52.637 I/GoLog   (30994): Preparing Domain: my_vps_ip:443
03-06 21:32:52.638 I/GoLog   (30994): Prepare Result:
03-06 21:32:52.638 I/GoLog   (30994):  Domain: my_vps_ip
03-06 21:32:52.638 I/GoLog   (30994):  Port: 443
03-06 21:32:52.638 I/GoLog   (30994):  IPs: [my_vps_ip]
03-06 21:32:52.857 I/GoLog   (30994): new core
03-06 21:32:52.910 I/GoLog   (30994): start core
03-06 21:32:52.911 I/GoLog   (30994): [Warning] core: Xray 1.8.8 started
03-06 21:33:36.634 D/com.v2ray.ang(14800): socketConnectTime IOException: java.net.ConnectException: failed to connect to /my_vps_ip (port 443) from /cellphone_ip (port 42104) after 3000ms: isConnected failed: ECONNREFUSED (Connection refused)
03-06 21:33:36.864 D/com.v2ray.ang(14800): socketConnectTime IOException: java.net.ConnectException: failed to connect to /my_vps_ip (port 443) from /cellphone_ip (port 42108) after 3000ms: isConnected failed: ECONNREFUSED (Connection refused)
03-06 21:34:36.472 D/com.v2ray.ang(14800): socketConnectTime IOException: java.net.ConnectException: failed to connect to /my_vps_ip (port 443) from /cellphone_ip (port 42140) after 3000ms: isConnected failed: ECONNREFUSED (Connection refused)
03-06 21:34:36.703 D/com.v2ray.ang(14800): socketConnectTime IOException: java.net.ConnectException: failed to connect to /my_vps_ip (port 443) from /cellphone_ip (port 42144) after 3000ms: isConnected failed: ECONNREFUSED (Connection refused)
03-06 21:34:58.958 I/GoLog   (30994): [Warning] core: Xray 1.8.8 started
03-06 21:34:58.997 I/GoLog   (30994): Not Using Prepared: tcp,my_vps_ip:443
03-06 21:34:58.997 I/GoLog   (30994): [Warning] core: Xray 1.8.8 started
03-06 21:34:59.204 I/GoLog   (30994): fdConn unix.Connect err, Close Fd: 100 Err: connection refused
03-06 21:34:59.435 I/GoLog   (30994): fdConn unix.Connect err, Close Fd: 100 Err: connection refused
03-06 21:34:59.907 I/GoLog   (30994): fdConn unix.Connect err, Close Fd: 100 Err: connection refused
03-06 21:35:00.559 I/GoLog   (30994): fdConn unix.Connect err, Close Fd: 100 Err: connection refused
03-06 21:35:01.434 I/GoLog   (30994): fdConn unix.Connect err, Close Fd: 100 Err: connection refused
03-06 21:35:02.237 D/com.v2ray.ang(30994): realPing: go.Universe$proxyerror: Get "https://www.google.com/generate_204": io: read/write on closed pipe

服务器端: access.log无访问记录(第一次在手机上用xray,有几条访问记录,后面就没了) error.log:

2024/03/06 06:51:46 [Debug] app/log: Logger started
2024/03/06 06:51:46 [Info] app/dns: DNS: created Local DOH client for https://1.1.1.1/dns-query
2024/03/06 06:51:46 [Info] app/dns: DNS: created localhost client
2024/03/06 06:51:46 [Debug] app/router: MphDomainMatcher is enabled for 701 domain rule(s)
2024/03/06 06:51:46 [Debug] app/router: MphDomainMatcher is enabled for 5205 domain rule(s)
2024/03/06 06:51:46 [Debug] app/proxyman/inbound: creating stream worker on 0.0.0.0:443
2024/03/06 06:51:46 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:1310
2024/03/06 06:51:46 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:1234
2024/03/06 06:51:46 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:2345
2024/03/06 06:51:46 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:3456
2024/03/06 06:51:46 [Info] transport/internet/tcp: listening TCP on 0.0.0.0:443
2024/03/06 06:51:46 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:1310
2024/03/06 06:51:46 [Warning] transport/internet/tcp: accepting PROXY protocol
2024/03/06 06:51:46 [Info] transport/internet/websocket: listening TCP(for WS) on 127.0.0.1:1234
2024/03/06 06:51:46 [Warning] transport/internet/websocket: accepting PROXY protocol
2024/03/06 06:51:46 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:2345
2024/03/06 06:51:46 [Warning] transport/internet/tcp: accepting PROXY protocol
2024/03/06 06:51:46 [Info] transport/internet/websocket: listening TCP(for WS) on 127.0.0.1:3456
2024/03/06 06:51:46 [Warning] transport/internet/websocket: accepting PROXY protocol
2024/03/06 06:51:46 [Warning] core: Xray 1.8.7 started
2024/03/06 07:18:57 [Info] transport/internet/tcp: REALITY: processed invalid connection
2024/03/06 07:26:37 [Debug] app/log: Logger started
2024/03/06 07:26:37 [Info] app/dns: DNS: created Local DOH client for https://1.1.1.1/dns-query
2024/03/06 07:26:37 [Info] app/dns: DNS: created localhost client
2024/03/06 07:26:37 [Debug] app/router: MphDomainMatcher is enabled for 701 domain rule(s)
2024/03/06 07:26:37 [Debug] app/router: MphDomainMatcher is enabled for 5205 domain rule(s)
2024/03/06 07:26:37 [Debug] app/proxyman/inbound: creating stream worker on 0.0.0.0:1443
2024/03/06 07:26:37 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:1310
2024/03/06 07:26:37 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:1234
2024/03/06 07:26:37 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:2345
2024/03/06 07:26:37 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:3456
2024/03/06 07:26:37 [Info] transport/internet/tcp: listening TCP on 0.0.0.0:1443
2024/03/06 07:26:37 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:1310
2024/03/06 07:26:37 [Warning] transport/internet/tcp: accepting PROXY protocol
2024/03/06 07:26:37 [Info] transport/internet/websocket: listening TCP(for WS) on 127.0.0.1:1234
2024/03/06 07:26:37 [Warning] transport/internet/websocket: accepting PROXY protocol
2024/03/06 07:26:37 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:2345
2024/03/06 07:26:37 [Warning] transport/internet/tcp: accepting PROXY protocol
2024/03/06 07:26:37 [Info] transport/internet/websocket: listening TCP(for WS) on 127.0.0.1:3456
2024/03/06 07:26:37 [Warning] transport/internet/websocket: accepting PROXY protocol
2024/03/06 07:26:37 [Warning] core: Xray 1.8.7 started
2024/03/06 09:30:48 [Info] transport/internet/tcp: REALITY: processed invalid connection
2024/03/06 09:30:48 [Info] transport/internet/tcp: REALITY: processed invalid connection
2024/03/06 09:30:49 [Info] transport/internet/tcp: REALITY: processed invalid connection
2024/03/06 09:30:49 [Info] transport/internet/tcp: REALITY: processed invalid connection

手动运行xray-core,手机上error.log:

2024/03/07 02:13:37 [Debug] app/log: Logger started
2024/03/07 02:13:37 [Info] app/dns: DNS: created UDP client initialized for 1.1.1.1:53
2024/03/07 02:13:37 [Info] app/dns: DNS: created UDP client initialized for 223.5.5.5:53
2024/03/07 02:13:37 [Info] app/dns: DNS: created UDP client initialized for 114.114.114.114:53
2024/03/07 02:13:37 [Info] app/dns: DNS: created localhost client
2024/03/07 02:13:37 [Debug] app/router: MphDomainMatcher is enabled for 720 domain rule(s)
2024/03/07 02:13:37 [Debug] app/router: MphDomainMatcher is enabled for 5246 domain rule(s)
2024/03/07 02:13:37 [Debug] app/router: MphDomainMatcher is enabled for 20708 domain rule(s)
2024/03/07 02:13:37 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:10808
2024/03/07 02:13:37 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:10801
2024/03/07 02:13:37 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:10801
2024/03/07 02:13:37 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:10808
2024/03/07 02:13:37 [Info] transport/internet/udp: listening UDP on 127.0.0.1:10808
2024/03/07 02:13:37 [Warning] core: Xray 1.8.8 started
2024/03/07 02:14:51 [Debug] app/log: Logger closing
2024/03/07 02:15:23 [Debug] app/log: Logger started
2024/03/07 02:15:23 [Info] app/dns: DNS: created UDP client initialized for 1.1.1.1:53
2024/03/07 02:15:23 [Info] app/dns: DNS: created UDP client initialized for 223.5.5.5:53
2024/03/07 02:15:23 [Info] app/dns: DNS: created UDP client initialized for 114.114.114.114:53
2024/03/07 02:15:23 [Info] app/dns: DNS: created localhost client
2024/03/07 02:15:23 [Debug] app/router: MphDomainMatcher is enabled for 720 domain rule(s)
2024/03/07 02:15:23 [Debug] app/router: MphDomainMatcher is enabled for 5246 domain rule(s)
2024/03/07 02:15:23 [Debug] app/router: MphDomainMatcher is enabled for 20708 domain rule(s)
2024/03/07 02:15:23 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:10808
2024/03/07 02:15:23 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:10801
2024/03/07 02:15:23 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:10801
2024/03/07 02:15:23 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:10808
2024/03/07 02:15:23 [Info] transport/internet/udp: listening UDP on 127.0.0.1:10808
2024/03/07 02:15:23 [Warning] core: Xray 1.8.8 started
2024/03/07 02:15:26 [Debug] app/log: Logger closing
2024/03/07 02:15:58 [Debug] app/log: Logger started
2024/03/07 02:15:58 [Info] app/dns: DNS: created UDP client initialized for 1.1.1.1:53
2024/03/07 02:15:58 [Info] app/dns: DNS: created UDP client initialized for 223.5.5.5:53
2024/03/07 02:15:58 [Info] app/dns: DNS: created UDP client initialized for 114.114.114.114:53
2024/03/07 02:15:58 [Info] app/dns: DNS: created localhost client
2024/03/07 02:15:58 [Debug] app/router: MphDomainMatcher is enabled for 720 domain rule(s)
2024/03/07 02:15:58 [Debug] app/router: MphDomainMatcher is enabled for 5246 domain rule(s)
2024/03/07 02:15:58 [Debug] app/router: MphDomainMatcher is enabled for 20708 domain rule(s)
2024/03/07 02:15:58 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:10808
2024/03/07 02:15:58 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:10801
2024/03/07 02:15:58 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:10801
2024/03/07 02:15:58 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:10808
2024/03/07 02:15:58 [Info] transport/internet/udp: listening UDP on 127.0.0.1:10808
2024/03/07 02:15:58 [Warning] core: Xray 1.8.8 started
2024/03/07 02:16:02 [Debug] app/log: Logger closing

用v2rayNG上的延迟测试,-1ms, 无法ping通google.com 另外一台延迟测试1000多ms的vps上,error.log:

2024/03/06 22:46:31 [Info] [2679931381] proxy/vless/inbound: firstLen = 1186
2024/03/06 22:46:31 [Info] [2679931381] proxy/vless/inbound: received request for tcp:www.google.com:443
2024/03/06 22:46:31 [Info] [2679931381] proxy: Xtls Unpadding new block, content 256 padding 949 command 0
2024/03/06 22:46:31 [Info] [2679931381] proxy: XtlsFilterTls found tls client hello! 256
2024/03/06 22:46:31 [Info] [2679931381] app/dispatcher: sniffed domain: www.google.com
2024/03/06 22:46:31 [Info] [2679931381] app/dispatcher: default route for tcp:www.google.com:443
2024/03/06 22:46:31 [Info] [2679931381] transport/internet/tcp: dialing TCP to tcp:www.google.com:443
2024/03/06 22:46:31 [Debug] transport/internet: dialing to tcp:www.google.com:443
2024/03/06 22:46:32 [Info] [2679931381] proxy/freedom: connection opened to tcp:www.google.com:443, local endpoint my_vps_ip:49354, remote endpoint xxxxxxxxx:443
2024/03/06 22:46:32 [Info] [2679931381] proxy: XtlsFilterTls found tls 1.3! 4279 TLS_CHACHA20_POLY1305_SHA256
2024/03/06 22:46:32 [Info] [2679931381] proxy: XtlsPadding 4279 66 0
2024/03/06 22:46:32 [Info] [2679931381] proxy: Xtls Unpadding new block, content 64 padding 914 command 0
2024/03/06 22:46:32 [Info] [2679931381] proxy: Xtls Unpadding new block, content 148 padding 1026 command 2
2024/03/06 22:46:32 [Info] [2679931381] proxy: CopyRawConn readv
2024/03/06 22:46:32 [Info] [2679931381] proxy: XtlsPadding 225 983 2
2024/03/06 22:46:32 [Info] [2679931381] app/proxyman/inbound: connection ends > proxy/vless/inbound: connection ends > proxy/vless/inbound: failed to transfer request payload > proxy: failed to process response$
2024/03/06 22:46:36 [Info] transport/internet/tcp: REALITY: processed invalid connection
2024/03/06 22:46:37 [Info] transport/internet/tcp: REALITY: processed invalid connection
yuhan6665 commented 4 months ago

看起来是网络不通

astraiosmem commented 4 months ago

看起来是网络不通

手机试过两台vps(美国),都无法连接,但是pc端都可以 用clash的别的机场节点可以访问外网,试过重置网络设置,开关飞行模式,都无效, 其中另一台vps用v2rayNG延迟测试大概1000多ms,但是也无法访问外网

astraiosmem commented 4 months ago

两台vps的traceroute vps2

astraiosmem commented 4 months ago

vps1

yuhan6665 commented 4 months ago

看到你补充的日志了 似乎是 acceptProxyProtocol 的问题 实在不行改一下用这个配置 https://github.com/chika0801/Xray-examples/tree/main/VLESS-Vision-REALITY

astraiosmem commented 4 months ago

看到你补充的日志了 似乎是 acceptProxyProtocol 的问题 实在不行改一下用这个配置 https://github.com/chika0801/Xray-examples/tree/main/VLESS-Vision-REALITY

我的配置就是在这个模板上加了点回落,这个会有影响吗; 另外我想问一下和shortIds有关吗,我手机上和电脑的shortIds一样

astraiosmem commented 3 months ago

看到你补充的日志了 似乎是 acceptProxyProtocol 的问题 实在不行改一下用这个配置 https://github.com/chika0801/Xray-examples/tree/main/VLESS-Vision-REALITY

已尝试,还是不行,换个手机试了,结果一样

astraiosmem commented 3 months ago

看到你补充的日志了 似乎是 acceptProxyProtocol 的问题 实在不行改一下用这个配置 https://github.com/chika0801/Xray-examples/tree/main/VLESS-Vision-REALITY

重试了这个配置,在很特殊的情况下能连上:用手机usb给电脑共享以太网,再开启v2rayng,能够正常运行,但是一拔usb线就无法连接

amintong commented 3 months ago

手机和电脑用的同一个wifi吗

astraiosmem commented 3 months ago

手机和电脑用的同一个wifi吗

不是,电脑没有网络,用数据线连接手机和电脑,手机上打开usb网络共享功能,电脑通过手机以太网进行NAT吧

Fangliding commented 2 months ago

无法复现 也算不出来命了 不行要不试试用隔壁nekobox