Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility Between Sing-box Tunnel and V2Ray Proxy on iOS #2511

Open
MTShafie opened this issue Jan 30, 2025 · 0 comments
Open

Compatibility Between Sing-box Tunnel and V2Ray Proxy on iOS #2511

MTShafie opened this issue Jan 30, 2025 · 0 comments

Comments

@MTShafie
Copy link

I am trying to run V2Ray in proxy mode and use Sing-box as a tunnel. This setup works perfectly on all platforms (Windows, Linux, macOS) except iOS, where it seems that direct configuration methods like process_name, process_path, and package_name are not applicable.

I have successfully managed to route the tunnel traffic through V2Ray as a proxy, and Sing-box as a tunnel on other platforms. However, on iOS, I’m unable to achieve the same result due to limitations with direct configuration options.

In Windows, Linux, and macOS, I use the following route rule to direct traffic based on the process name:

"route": {
  "rules": [
    {
      "outbound": "direct",
      "process_name": [
        "xray",
        "xray.exe"
      ]
    }
  ]
}

But on iOS, I cannot use process_name or similar parameters.

I need help figuring out how to properly direct traffic through V2Ray and Sing-box on iOS, and how to make them work together seamlessly, especially given that iOS doesn't seem to support the usual methods for tunnel direction.

Execution Command for Each:

  • For Sing-box (Tunnel mode):

    sudo sing-box run -c tunnel.json
  • For V2Ray (Proxy mode):

    xray run -c proxy.json

V2Ray Config (Proxy):

{
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 3973,
      "protocol": "socks",
      "settings": {
        "auth": "noauth",
        "udp": true
      },
      "sniffing": {
        "destOverride": [
          "http",
          "tls"
        ],
        "enabled": true,
        "routeOnly": false
      },
      "tag": "socks"
    }
  ],
  "log": {
    "access": "",
    "error": "",
    "loglevel": "warning"
  },
  "outbounds": [
    {
      "mux": {
        "concurrency": 8,
        "enabled": true
      },
      "protocol": "vless",
      "settings": {
        "vNext": [
          {
            "address": "xxxxxx",  // <-- Replace with actual address
            "port": 443,
            "users": [
              {
                "alterId": 0,
                "encryption": "none",
                "flow": "",
                "id": "xxxxxx",  // <-- Replace with actual ID
                "security": "auto"
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "ws",
        "security": "tls",
        "sockopt": {
          "dialerProxy": "fragment",
          "mark": 255,
          "tcpKeepAliveIdle": 100,
          "tcpNoDelay": true
        },
        "tlsSettings": {
          "alpn": [
            "h2",
            "http/1.1",
            "h3"
          ],
          "fingerprint": "randomized",
          "serverName": "xxxxxx"  // <-- Replace with actual server name
        },
        "wsSettings": {
          "headers": {
            "host": "xxxxxx"  // <-- Replace with actual host
          },
          "path": "/xxxxxx"  // <-- Replace with actual path
        }
      },
      "tag": "proxy"
    },
    {
      "protocol": "freedom",
      "settings": {
        "domainStrategy": "AsIs",
        "fragment": {
          "interval": "20-30",
          "length": "50-100",
          "packets": "tlshello"
        }
      },
      "streamSettings": {
        "sockopt": {
          "tcpKeepAliveIdle": 100,
          "tcpNoDelay": true
        }
      },
      "tag": "fragment"
    },
    {
      "protocol": "freedom",
      "settings": {},
      "tag": "direct"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "block"
    }
  ],
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "outboundTag": "proxy",
        "port": "0-65535",
        "type": "field"
      }
    ]
  }
}

Sing-box Tunnel Config:

{
  "dns": {
    "independent_cache": true,
    "rules": [
      {
        "domain": [
          ""  // <-- Specify domain if required
        ],
        "domain_suffix": [],
        "server": "dns-direct"
      },
      {
        "query_type": [
          32,
          33
        ],
        "server": "dns-block"
      },
      {
        "domain_suffix": ".lan",
        "server": "dns-block"
      }
    ],
    "servers": [
      {
        "address": "local",  // <-- Replace with actual address if required
        "address_resolver": "dns-local",
        "detour": "direct",
        "strategy": "",
        "tag": "dns-direct"
      },
      {
        "address": "rcode://success",  // <-- Replace with actual address if required
        "tag": "dns-block"
      },
      {
        "address": "local",  // <-- Replace with actual address if required
        "detour": "direct",
        "tag": "dns-local"
      }
    ]
  },
  "inbounds": [
    {
      "auto_route": true,
      "domain_strategy": "",
      "endpoint_independent_nat": true,
      "inet4_address": "172.19.0.1/30",
      "inet6_address": "fdfe:dcba:9876::1/126",
      "interface_name": "",
      "mtu": 9000,
      "sniff": true,
      "sniff_override_destination": false,
      "stack": "system",
      "strict_route": false,
      "tag": "tun-in",
      "type": "tun"
    },
    {
      "listen": "0.0.0.0",
      "listen_port": 10808,
      "sniff": true,
      "sniff_override_destination": false,
      "tag": "mixed-in",
      "type": "mixed"
    }
  ],
  "log": {
    "level": "info",
    "timestamp": true
  },
  "outbounds": [
    {
      "server": "127.0.0.1",
      "server_port": 3973,
      "tag": "proxy",
      "type": "socks"
    },
    {
      "tag": "dns-out",
      "type": "dns"
    },
    {
      "tag": "block",
      "type": "block"
    },
    {
      "tag": "direct",
      "type": "direct"
    },
    {
      "tag": "bypass",
      "type": "direct"
    }
  ],
  "route": {
    "auto_detect_interface": true,
    "final": "proxy",
    "rules": [
      {
        "ip_cidr": [
          "192.0.2.0/24"
        ],
        "outbound": "direct"
      },
      {
        "outbound": "dns-out",
        "protocol": "dns"
      },
      {
        "network": "udp",
        "outbound": "block",
        "port": [
          135,
          137,
          138,
          139,
          5353
        ]
      },
      {
        "ip_cidr": [
          "224.0.0.0/3",
          "ff00::/8"
        ],
        "outbound": "block"
      },
      {
        "outbound": "block",
        "source_ip_cidr": [
          "224.0.0.0/3",
          "ff00::/8"
        ]
      }
    ]
  }
}

I'm looking for guidance on how to make the V2Ray and Sing-box tunnel configuration work correctly on iOS, especially in situations where standard configuration methods like process_name and package_name do not apply. Any insight into overcoming iOS-specific limitations would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant