SagerNet / sing-box

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

[Bug]: Incompatibility with servers using Mux.Cool #1876

Open radiumatic opened 1 week ago

radiumatic commented 1 week ago

Operating system

Linux

System version

Ubuntu 22.04 LTS, Kernel 5.15

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 v1.9.3

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

Description

sing-box clients (and sing-box used as a client, in general) cannot connect to servers running xray-core with multiplex that only support the Mux.Cool algorithm.

Reproduction

  1. Find or start a server running xray-core and enable mux support in the server. Generally any configuration works as long as the inbound is TCP based. Mux support in xray-core is enabled by default. Example:

    {
    "log": {
    "loglevel": "debug"
    },
    "inbounds": [
    {
      "port": 10086,
      "listen": "127.0.0.1",
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "600136f6-0509-4031-9afc-8afcf2adb01b"
          }
        ]
      },
      "streamSettings": {
        "network": "tcp"
      }
    }
    ],
    "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
    ]
    }
  2. Attempt to connect to the server using a singbox client and enable mux. Doesn't matter how many whistles and bells you add, bare configuration works too. Example:

    {
    "inbounds": [
    {
      "domain_strategy": "",
      "listen": "127.0.0.1",
      "listen_port": 10808,
      "sniff": true,
      "sniff_override_destination": false,
      "tag": "mixed-in",
      "type": "mixed"
    }
    ],
    "log": {
    "level": "debug"
    },
    "outbounds": [
    {
      "alter_id": 0,
      "domain_strategy": "",
      "multiplex": {
        "enabled": true,
        "max_streams": 8,
        "padding": false,
        "protocol": "smux" //doesn't matter which algorithm you choose
      },
      "packet_encoding": "",
      "security": "auto",
      "server": "127.0.0.1",
      "server_port": 10086,
      "tag": "proxy",
      "type": "vmess",
      "uuid": "600136f6-0509-4031-9afc-8afcf2adb01b"
    }
    ]
    }

Logs

xray-core server logs:

Xray 1.8.13 (Xray, Penetrates Everything.) 3120ca4 (go1.22.3 linux/amd64)
A unified platform for anti-censorship.
2024/06/17 21:49:22 [Info] infra/conf/serial: Reading config: xray.json
2024/06/17 21:49:22 [Debug] app/log: Logger started
2024/06/17 21:49:22 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:10086
2024/06/17 21:49:22 [Info] transport/internet/tcp: listening TCP on 127.0.0.1:10086
2024/06/17 21:49:22 [Warning] core: Xray 1.8.13 started
2024/06/17 21:53:22 [Info] [306621799] proxy/vmess/inbound: received request for tcp:sp.mux.sing-box.arpa:444
2024/06/17 21:53:22 [Info] [306621799] app/dispatcher: default route for tcp:sp.mux.sing-box.arpa:444
2024/06/17 21:53:22 [Info] [306621799] transport/internet/tcp: dialing TCP to tcp:sp.mux.sing-box.arpa:444
2024/06/17 21:53:22 127.0.0.1:52154 accepted tcp:sp.mux.sing-box.arpa:444
2024/06/17 21:53:22 [Debug] transport/internet: dialing to tcp:sp.mux.sing-box.arpa:444
2024/06/17 21:53:22 [Info] [306621799] transport/internet/tcp: dialing TCP to tcp:sp.mux.sing-box.arpa:444
2024/06/17 21:53:22 [Debug] transport/internet: dialing to tcp:sp.mux.sing-box.arpa:444
2024/06/17 21:53:22 [Info] [306621799] transport/internet/tcp: dialing TCP to tcp:sp.mux.sing-box.arpa:444
2024/06/17 21:53:22 [Debug] transport/internet: dialing to tcp:sp.mux.sing-box.arpa:444
2024/06/17 21:53:22 [Info] [306621799] transport/internet/tcp: dialing TCP to tcp:sp.mux.sing-box.arpa:444
2024/06/17 21:53:22 [Debug] transport/internet: dialing to tcp:sp.mux.sing-box.arpa:444
2024/06/17 21:53:22 [Info] [306621799] transport/internet/tcp: dialing TCP to tcp:sp.mux.sing-box.arpa:444
2024/06/17 21:53:22 [Debug] transport/internet: dialing to tcp:sp.mux.sing-box.arpa:444
2024/06/17 21:53:23 [Info] [306621799] app/proxyman/outbound: failed to process outbound traffic > proxy/freedom: failed to open connection to tcp:sp.mux.sing-box.arpa:444 > common/retry: [dial tcp: lookup sp.mux.sing-box.arpa on 127.0.0.53:53: no such host] > common/retry: all retry attempts failed
2024/06/17 21:53:23 [Info] [306621799] app/proxyman/inbound: connection ends > proxy/vmess/inbound: connection ends > io: read/write on closed pipe

sing-box client logs:

INFO[0000] router: updated default interface eth0, index 1
INFO[0000] inbound/mixed[mixed-in]: tcp server started at 127.0.0.1:10808
INFO[0000] sing-box started (0.00s)
INFO[0026] [1243402487 0ms] inbound/mixed[mixed-in]: inbound connection from 127.0.0.1:50638
INFO[0026] [1243402487 130ms] inbound/mixed[mixed-in]: inbound connection to 142.250.186.174:80
DEBUG[0026] [1243402487 130ms] router: sniffed protocol: http, domain: google.com
INFO[0026] [1243402487 130ms] outbound/vmess[proxy]: outbound multiplex connection to 142.250.186.174:80

Supporter

Integrity requirements

amirhosss commented 1 week ago

That's not a bug The mux protocols are not compatible

radiumatic commented 1 week ago

That's not a bug The mux protocols are not compatible

They can be though. xray-core clients have no problem connecting to sing-box servers.

Maybe Mux.Cool can be added as a 4th mux algorithm.

Mahdi-zarei commented 1 week ago

They can be though. xray-core clients have no problem connecting to sing-box servers.

Xray clients cannot connect to sing-box with mux. The Mux cool protocol is not compatible with the sing-box's mux protocols.

radiumatic commented 1 week ago

They can be though. xray-core clients have no problem connecting to sing-box servers.

Xray clients cannot connect to sing-box with mux. The Mux cool protocol is not compatible with the sing-box's mux protocols.

Except that they can. Try it, run a sing-box server with multiplex enabled (no other mux option) and connect to it using a xray-core client with multiplex enabled. I'm currently replying to you using this exact setup, just to make sure it actually works. (The cores aren't modified, they're github releases)