SagerNet / sing-box

The universal proxy platform
https://sing-box.sagernet.org/
Other
15.38k stars 1.89k forks source link

outbound配置Shadowsocks协议的network为UDP时,route中无法使用此outbound #1863

Closed L1yp closed 1 week ago

L1yp commented 1 week ago

Operating system

Linux

System version

deepin_v23,debian_bookworm/sid

Installation type

Original sing-box Command Line

If you are using a graphical client, please provide the version of the client.

No response

Version

sing-box version 1.9.3

Environment: go1.22.3 linux/amd64
Tags: with_gvisor,with_quic,with_dhcp,with_wireguard,with_ech,with_utls,with_reality_server,with_acme,with_clash_api
Revision: 085f60337799afc906069b540a38368968c123e4
CGO: disabled

Description

当我使用Shadowsocks的UDP模式时,route无法正常工作。

Reproduction

  1. outbound中配置一个Shadowsocks并且network配置为udp

    {
    "outbounds": [
    {
      "type": "shadowsocks",
      "tag": "hk-proxy",
      "server": "<server>",
      "server_port": 8112,
      "method": "chacha20-ietf-poly1305",
      "password": "<password>",
      "network": "udp"
    }
    ]
    }
  2. route配置如下:

    {
    "route": {
    "final": "hk-proxy",
    "rules": [
      {
        "ip_is_private": true,
        "outbound": "direct"
      },
      {
        "domain": [
          "www.gstatic.com",
          "www.google.com",
          "www.google.com.hk"
        ],
        "outbound": "hk-proxy"
      }
    ]
    }
    }
  3. inbound如下:

    {
    "inbounds": [
    {
      "type": "mixed",
      "tag": "mixed-in",
      "listen": "0.0.0.0",
      "listen_port": 17890
    },
    {
      "type": "shadowsocks",
      "tag": "ss-in",
      "listen": "0.0.0.0",
      "listen_port": 17891,
      "tcp_fast_open": false,
      "tcp_multi_path": false,
      "udp_fragment": true,
      "udp_timeout": "5m",
      "method": "chacha20-ietf-poly1305",
      "password": "<PASSWORD>"
    }
    ]
    }
  4. 使用clash配置链接上singbox的inbound配置信息,然后在clash上点测试。

完整配置文件如下:


{
  "log": {
    "level": "info",
    "disabled": false,
    "output": "/var/log/sing-box/box.log",
    "timestamp": true
  },
  "dns": {
    "servers": [
      {
        "address": "119.29.29.29"
      },
      {
        "address": "223.5.5.5"
      }
    ],
    "strategy": "prefer_ipv4",
    "disable_cache": true
  },
  "inbounds": [
    {
      "type": "mixed",
      "tag": "mixed-in",
      "listen": "0.0.0.0",
      "listen_port": 17890
    },
    {
      "type": "shadowsocks",
      "tag": "ss-in",
      "listen": "0.0.0.0",
      "listen_port": 17891,
      "tcp_fast_open": false,
      "tcp_multi_path": false,
      "udp_fragment": true,
      "udp_timeout": "5m",
      "method": "chacha20-ietf-poly1305",
      "password": "<password>"
    }
  ],
  "outbounds": [
    {
      "type": "shadowsocks",
      "tag": "hk-proxy",
      "server": "<server>",
      "server_port": 8112,
      "method": "chacha20-ietf-poly1305",
      "password": "<password>",
      "network": "tcp"
    },
    {
      "type": "direct",
      "tag": "direct"
    }
  ],
  "route": {
    "final": "hk-proxy",
    "rules": [
      {
        "ip_is_private": true,
        "outbound": "direct"
      },
      {
        "domain": [
          "www.gstatic.com",
          "www.google.com",
          "www.google.com.hk"
        ],
        "outbound": "hk-proxy"
      }
    ]
  }
}

Logs

+0800 2024-06-14 11:14:08 INFO router: updated default interface enp3s0, index 2
+0800 2024-06-14 11:14:08 INFO inbound/mixed[mixed-in]: tcp server started at 0.0.0.0:17890
+0800 2024-06-14 11:14:08 INFO inbound/shadowsocks[ss-in]: tcp server started at 0.0.0.0:17891
+0800 2024-06-14 11:14:08 INFO inbound/shadowsocks[ss-in]: udp server started at 0.0.0.0:17891
+0800 2024-06-14 11:14:08 INFO sing-box started (0.00s)
+0800 2024-06-14 11:14:20 INFO [2405456300 0ms] inbound/shadowsocks[ss-in]: inbound connection from 192.168.0.100:52319
+0800 2024-06-14 11:14:20 INFO [3657735140 0ms] inbound/shadowsocks[ss-in]: inbound connection to www.gstatic.com:80
+0800 2024-06-14 11:14:20 ERROR [2405456300 0ms] inbound/shadowsocks[ss-in]: process connection from 192.168.0.100:52319: shadowsocks: serve TCP from 192.168.0.100:52319: missing supported outbound, closing connection

Supporter

Integrity requirements

CHIZI-0618 commented 1 week ago

你对 network 参数有误解

xiaobaicai18 commented 1 week ago

你对 network 参数有误解

抱歉,请教下怎么让outbound的shadowsocks协议支持udp?没看到相关说明