SagerNet / sing-box

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

vless-grpc conflicts with fakeip #672

Closed Hubedge closed 1 year ago

Hubedge commented 1 year ago

Welcome

Description of the problem

vless-grpc conflicts with fakeip. Replacing fakedns dns server with directdns make it work though.

Version of sing-box

```console $ sing-box version sing-box version unknown Environment: go1.20.2 windows/amd64 Tags: with_quic,with_grpc,with_dhcp,with_wireguard,with_shadowsocksr,with_ech,with_utls,with_reality_server,with_clash_api,with_v2ray_api,with_gvisor CGO: disabled ``` complied with ```powershell go install -v -trimpath -tags "with_quic,with_grpc,with_dhcp,with_wireguard,with_shadowsocksr,with_ech,with_utls,with_reality_server,with_clash_api,with_v2ray_api,with_gvisor" github.com/sagernet/sing-box/cmd/sing-box@dev-next ```

Server and client configuration file

Client side: ```json { "log": { "disabled": false, "level": "info", "output": "./src/log/box.log", "timestamp": true }, "dns": { "fakeip": { "enabled": true, "inet4_range": "198.18.0.0/15", "inet6_range": "fc00::/18" }, "servers": [ { "tag": "directdns", "address": "223.6.6.6", "detour": "DIRECT" }, { "tag": "fakedns", "address": "fakeip" } ], "rules": [ { "outbound": "any", "server": "directdns" } ], "final": "fakedns", // changing fakedns to directdns makes it work "strategy": "prefer_ipv4", "disable_cache": false, "disable_expire": false }, "inbounds": [ { "tag": "tun", "type": "tun", "interface_name": "tun1", "inet4_address": "172.19.0.1/30", "inet6_address": "fdfe:dcba:9876::1/126", "mtu": 36000, "auto_route": true, "strict_route": true, "stack": "system", "sniff": true } ], "outbounds": [ { "tag": "DIRECT", "type": "direct" }, { "tag": "BLOCK", "type": "block" }, { "tag": "dns", "type": "dns" }, { "tag": "PROXY", "type": "urltest", "interval": "5m", "outbounds": [ "Proxy-gRPC" ] }, { "tag": "Proxy-gRPC", "type": "vless", "server": "example.com", "server_port": 443, "uuid": "uuid", "tls": { "enabled": true, "insecure": false, "server_name": "example.com" }, "transport": { "type": "grpc", "service_name": "servicename" } } ], "route": { "geosite": { "path": "./src/geosite.db", "download_url": "https://raw.githubusercontent.com/CHIZI-0618/v2ray-rules-dat/release/geosite.db", "download_detour": "PROXY" }, "geoip": { "path": "./src/geoip.db", "download_url": "https://raw.githubusercontent.com/CHIZI-0618/v2ray-rules-dat/release/geoip.db", "download_detour": "PROXY" }, "rules": [ { "protocol": "dns", "outbound": "dns" }, { "protocol": [ "quic" ], "outbound": "BLOCK" } ], "final": "PROXY", "auto_detect_interface": true, "find_process": true }, "experimental": { "clash_api": { "external_controller": "127.0.0.1:9909", "external_ui": "Dashboard", "default_mode": "rule", "secret": "xxxxxxxxxxxxxx", "cache_file": "./src/cache.db", "store_selected": true, "store_fakeip": true } } } ```

Server and client log file

Client side: ```console > .\sing-box.exe run -c box1.json panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x28 pc=0x13c8af9] goroutine 37 [running]: github.com/sagernet/sing-box/transport/fakeip.(*Transport).Lookup(0xc000288700, {0xc0003105c0?, 0x0?}, {0xc0003319af, 0xb}, 0x1) github.com/sagernet/sing-box@v1.2.8-0.20230623081225-c2bda9fbdeff/transport/fakeip/server.go:72 +0x59 github.com/sagernet/sing-dns.(*Client).Lookup(0xc000281110, {0x196ec38, 0xc00030a4b0}, {0x1972890?, 0xc000288700}, {0xc0003319af, 0xb}, 0x1) github.com/sagernet/sing-dns@v0.1.6-0.20230623081049-1fdb177c60aa/client.go:247 +0x50c github.com/sagernet/sing-box/route.(*Router).Lookup(0xc00024a500, {0x196ece0, 0xc000308780}, {0xc0003319af, 0xb}, 0x0) github.com/sagernet/sing-box@v1.2.8-0.20230623081225-c2bda9fbdeff/route/router_dns.go:133 +0x225 github.com/sagernet/sing-box/route.(*Router).LookupDefault(0x196ece0?, {0x196ece0?, 0xc000308780?}, {0xc0003319af?, 0x1526600?}) github.com/sagernet/sing-box@v1.2.8-0.20230623081225-c2bda9fbdeff/route/router_dns.go:146 +0x2b github.com/sagernet/sing-box/common/dialer.(*ResolveDialer).DialContext(0xc000281590, {0x196ece0, 0xc0003086f0}, {0x176ca17, 0x3}, {{{0x0, 0x0}, 0x0}, 0x1bb, {0xc0003319af, ...}}) github.com/sagernet/sing-box@v1.2.8-0.20230623081225-c2bda9fbdeff/common/dialer/resolve.go:44 +0x1d0 github.com/sagernet/sing-box/transport/v2raygrpc.NewClient.func1({0x196ece0, 0xc0003086f0}, {0xc0003319af?, 0xc00031c510?}) github.com/sagernet/sing-box@v1.2.8-0.20230623081225-c2bda9fbdeff/transport/v2raygrpc/client.go:63 +0xd1 google.golang.org/grpc/internal/transport.dial({0x196ece0, 0xc0003086f0}, 0xc0002599f8, {{0xc0003319af, 0xf}, {0xc000283430, 0xb}, 0x0, 0x0, 0x0, ...}, ...) google.golang.org/grpc@v1.56.0/internal/transport/http2_client.go:171 +0x22b google.golang.org/grpc/internal/transport.newHTTP2Client({_, _}, {_, _}, {{0xc0003319af, 0xf}, {0xc000283430, 0xb}, 0x0, 0x0, ...}, ...) google.golang.org/grpc@v1.56.0/internal/transport/http2_client.go:216 +0x194 google.golang.org/grpc/internal/transport.NewClientTransport(...) google.golang.org/grpc@v1.56.0/internal/transport/transport.go:606 google.golang.org/grpc.(*addrConn).createTransport(_, {_, _}, {{0xc0003319af, 0xf}, {0xc000283430, 0xb}, 0x0, 0x0, 0x0, ...}, ...) google.golang.org/grpc@v1.56.0/clientconn.go:1451 +0x365 google.golang.org/grpc.(*addrConn).tryAllAddrs(0xc00036e000, {0x196ec38, 0xc00030a2d0}, {0xc00030a280?, 0x1, 0x0?}, {0x10ca782?, 0x0?, 0x2322d40?}) google.golang.org/grpc@v1.56.0/clientconn.go:1398 +0x408 google.golang.org/grpc.(*addrConn).resetTransport(0xc00036e000) google.golang.org/grpc@v1.56.0/clientconn.go:1335 +0x1f2 google.golang.org/grpc.(*addrConn).connect(0xc00036e000) google.golang.org/grpc@v1.56.0/clientconn.go:978 +0x96 created by google.golang.org/grpc.(*acBalancerWrapper).Connect google.golang.org/grpc@v1.56.0/balancer_conn_wrappers.go:398 +0x59 ```
Hubedge commented 1 year ago

invalid 啥意思,无法复现?

Hubedge commented 1 year ago

Solved. server needs to be an IP address.

    {
      "tag": "Proxy-gRPC",
      "type": "vless",
      "server": "1.2.3.4", // IP address here
      "server_port": 443,
      "uuid": "uuid",
      "tls": {
        "enabled": true,
        "insecure": false,
        "server_name": "example.com"
      },
      "transport": {
        "type": "grpc",
        "service_name": "servicename"
      }
    }