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
24.65k stars 3.85k forks source link

xray.exe -c config.json 无法正常代理请大佬指点 #2731

Closed jiaopengzi closed 10 months ago

jiaopengzi commented 10 months ago

场景描述

使用 x-ui 搭建的节点。vless + tcp + reality

windows11系统

使用 GUI 的 v2rayN.exe能正常代理,并访问www.google.com

节点配置导出的配置文件config.json如下:(关键信息脱敏处理)

{
  "log": {
    "access": "",
    "error": "",
    "loglevel": "info"
  },
  "inbounds": [
    {
      "tag": "socks",
      "port": 10808,
      "listen": "127.0.0.1",
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"],
        "routeOnly": false
      },
      "settings": {
        "auth": "noauth",
        "udp": true,
        "allowTransparent": false
      }
    },
    {
      "tag": "http",
      "port": 10809,
      "listen": "127.0.0.1",
      "protocol": "http",
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"],
        "routeOnly": false
      },
      "settings": {
        "auth": "noauth",
        "udp": true,
        "allowTransparent": false
      }
    }
  ],
  "outbounds": [
    {
      "tag": "proxy",
      "protocol": "vless",
      "settings": {
        "vnext": [
          {
            "address": "20.*.*.192",//脱敏处理
            "port": 27001,
            "users": [
              {
                "id": "uuid46f0-uuid-40b5-fb5b-89e0767buuid",//脱敏处理
                "alterId": 0,
                "email": "t@t.tt",
                "security": "auto",
                "encryption": "none",
                "flow": "xtls-rprx-vision"
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "tcp",
        "security": "reality",
        "realitySettings": {
          "serverName": "www.amazon.com",
          "fingerprint": "chrome",
          "show": false,
          "publicKey": "5JdcPAutpTRKo7K2hugkR0vwk2XroUM",//脱敏处理
          "shortId": "",
          "spiderX": ""
        }
      },
      "mux": {
        "enabled": false,
        "concurrency": -1
      }
    },
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {
        "domainStrategy": "UseIP",
        "userLevel": 0
      }
    },
    {
      "tag": "block",
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      }
    }
  ],
  "dns": {
    "hosts": {
      "dns.google": "8.8.8.8",
      "proxy.example.com": "127.0.0.1"
    },
    "servers": [
      {
        "address": "223.5.5.5",
        "domains": ["geosite:cn"],
        "expectIPs": ["geoip:cn"]
      },
      "1.1.1.1",
      "8.8.8.8",
      "https://dns.google/dns-query"
    ]
  },
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "rules": [
      {
        "type": "field",
        "inboundTag": ["api"],
        "outboundTag": "api"
      },
      {
        "type": "field",
        "outboundTag": "proxy",
        "domain": ["google.com"]
      },
      {
        "type": "field",
        "outboundTag": "direct",
        "domain": ["geosite:cn"]
      },
      {
        "type": "field",
        "outboundTag": "direct",
        "ip": ["geoip:private", "geoip:cn"]
      },
      {
        "type": "field",
        "outboundTag": "block",
        "domain": ["geosite:category-ads-all"]
      }
    ]
  }
}

当我使用命令行运行,返回如下。

C:\ToolPortable\Xray-windows-64>xray.exe -c config.json
Xray 1.8.4 (Xray, Penetrates Everything.) Custom (go1.21.0 windows/amd64)
A unified platform for anti-censorship.
2023/11/16 19:37:48 [Info] infra/conf/serial: Reading config: config.json
2023/11/16 19:37:48 [Info] app/dns: DNS: created UDP client initialized for 223.5.5.5:53
2023/11/16 19:37:49 [Info] app/dns: DNS: created UDP client initialized for 1.1.1.1:53
2023/11/16 19:37:49 [Info] app/dns: DNS: created UDP client initialized for 8.8.8.8:53
2023/11/16 19:37:49 [Info] app/dns: DNS: created Remote DOH client for https://dns.google/dns-query
2023/11/16 19:37:49 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:10808
2023/11/16 19:37:49 [Info] transport/internet/udp: listening UDP on 127.0.0.1:10808
2023/11/16 19:37:49 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:10809
2023/11/16 19:37:49 [Warning] core: Xray 1.8.4 started

问题:

1、当运行xray.exe -c config.json 时候,浏览器无法代理访问如www.google.com

2、没有关闭上述cmd命令窗口,再打开 v2rayN.exe 能实现代理上网,cmd命令行还能捕获info信息

2023/11/16 19:38:55 [Info] [3626137704] app/proxyman/inbound: connection ends > proxy/http: failed to read http request > EOF
2023/11/16 19:38:56 [Info] [1244412467] proxy/http: request to Method [CONNECT] Host [www.google.com:443] with URL [//www.google.com:443]
2023/11/16 19:38:56 [Info] [1244412467] app/dispatcher: sniffed domain: www.google.com
2023/11/16 19:38:56 [Info] [1244412467] app/dispatcher: taking detour [proxy] for [tcp:www.google.com:443]
2023/11/16 19:38:56 127.0.0.1:12981 accepted //www.google.com:443 [http -> proxy]
2023/11/16 19:38:56 [Info] [1244412467] transport/internet/tcp: dialing TCP to tcp:20.127.167.192:27001
2023/11/16 19:38:56 [Info] [1244412467] proxy/vless/outbound: tunneling request to tcp:www.google.com:443 via 20.127.167.192:27001
2023/11/16 19:38:56 [Info] [1244412467] proxy/vless/encoding: XtlsFilterTls found tls client hello! 265
2023/11/16 19:38:56 [Info] [1244412467] proxy/vless/encoding: XtlsPadding 265 936 0
2023/11/16 19:38:56 [Info] [1244412467] proxy/vless/encoding: Xtls Unpadding new block0 16 content 4294 padding 135 0
2023/11/16 19:38:56 [Info] [1244412467] proxy/vless/encoding: XtlsFilterTls found tls 1.3! 1163 TLS_AES_256_GCM_SHA384
2023/11/16 19:38:56 [Info] [1244412467] proxy/vless/encoding: XtlsPadding 80 990 0
2023/11/16 19:38:57 [Info] [1244412467] proxy/vless/encoding: XtlsPadding 74 1216 2
2023/11/16 19:38:57 [Info] [1244412467] proxy/vless/encoding: XtlsWrite writeV 0 1295 0
2023/11/16 19:38:57 [Info] [1244412467] proxy/vless/encoding: Xtls Unpadding new block0 0 content 778 padding 486 2
2023/11/16 19:38:57 [Info] [1244412467] proxy/vless/encoding: XtlsRead readV
2023/11/16 19:38:58 [Info] [1244412467] app/proxyman/inbound: connection ends > proxy/http: connection ends > context canceled

希望实现直接使用 xray.exe -c config.json 就能代理上网,不使用GUI,请大佬指点一下,哪里出了问题。

us254 commented 10 months ago

CopyQ SGaytU

[bstore.google.com/detail/proxy-switchyomega/padekgcemlokbadohgkifijomclgjgif](chrome-extension://padekgcemlokbadohgkifijomclgjgif/options.html#!/profile/proxy)

Lowfeye commented 10 months ago

浏览器识别的是你系统设置的代理,xray在后台运行后,不打开设置系统代理,浏览器是不去走代理的 image

jiaopengzi commented 10 months ago

感谢楼上两位指点,已经可以了。