diff -ruN a/features/dns/localdns/client.go b/features/dns/localdns/client.go --- a/features/dns/localdns/client.go 2026-11-10 13:52:38 +++ b/features/dns/localdns/client.go 2026-11-10 13:52:38 @@ -3,6 +3,7 @@ import ( "context" "net/netip" + "runtime" "syscall" "time" @@ -33,7 +34,7 @@ func (c *Client) LookupIP(host string, option dns.IPOption) ([]net.IP, uint32, error) { var ips []net.IP var err error - if len(internet.Controllers) > 0 { + if len(internet.Controllers) > 0 && runtime.GOOS != "android" { ips, err = c.r.LookupIP(context.Background(), "ip", host) } else { ips, err = net.LookupIP(host) diff -ruN a/proxy/proxy.go b/proxy/proxy.go --- a/proxy/proxy.go 2026-11-11 02:33:08 +++ b/proxy/proxy.go 2026-11-11 02:33:08 @@ -737,7 +737,10 @@ readerConn, readCounter, _ := UnwrapRawConn(readerConn) writerConn, _, writeCounter := UnwrapRawConn(writerConn) reader := buf.NewReader(readerConn) - if runtime.GOOS != "linux" && runtime.GOOS != "android" { + // RayRay: no splice on Android, as on iOS. A spliced connection adds its bytes to the stats only when it ends, so + // a long download or a kept-alive connection stays out of the app's traffic numbers and its "the server still + // answers" checks until then. + if runtime.GOOS != "linux" { return readV(ctx, reader, writer, timer, readCounter) } tc, ok := writerConn.(*net.TCPConn) diff -ruN a/proxy/tun/rayray_limits.go b/proxy/tun/rayray_limits.go --- a/proxy/tun/rayray_limits.go 2026-11-10 13:52:38 +++ b/proxy/tun/rayray_limits.go 2026-11-10 13:52:38 @@ -71,7 +71,7 @@ } func queueLimit() int { - if runtime.GOOS == "ios" { + if runtime.GOOS == "ios" || runtime.GOOS == "android" { return 128 } return 1024 diff -ruN a/proxy/tun/stack.go b/proxy/tun/stack.go --- a/proxy/tun/stack.go 2026-11-10 13:52:38 +++ b/proxy/tun/stack.go 2026-11-10 13:52:38 @@ -115,7 +115,7 @@ if options.Remote { s.window = tcpLargeWindow } - if runtime.GOOS == "ios" { + if runtime.GOOS == "ios" || runtime.GOOS == "android" { s.window = tcpWindowIOS } readLimits() diff -ruN a/transport/internet/finalmask/realm/http.go b/transport/internet/finalmask/realm/http.go --- a/transport/internet/finalmask/realm/http.go 2026-11-10 18:07:43 +++ b/transport/internet/finalmask/realm/http.go 2026-11-10 18:07:43 @@ -14,6 +14,8 @@ "net/url" "strings" + xnet "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/tls" ) @@ -81,18 +83,29 @@ return fmt.Sprintf("realm server returned %d", e.StatusCode) } +// On Android a socket that skips the registered controllers (VpnService.protect) goes into the app's own tunnel, +// back to this outbound, and loops. +func dialThroughControllers(ctx context.Context, _, addr string) (net.Conn, error) { + dest, err := xnet.ParseDestination("tcp:" + addr) + if err != nil { + return nil, err + } + return internet.DialSystem(ctx, dest, nil) +} + func NewClient(scheme, host, port, token string, tlsConfig *tls.Config) *Client { - client := http.DefaultClient + tr := http.DefaultTransport.(*http.Transport).Clone() + tr.DialContext = dialThroughControllers + // Nothing closes this per-connection transport, so its sockets must not stay idle after a request. + tr.DisableKeepAlives = true if tlsConfig != nil { - tr := http.DefaultTransport.(*http.Transport).Clone() tr.TLSClientConfig = tlsConfig.GetTLSConfig() - client = &http.Client{Transport: tr} } return &Client{ scheme: scheme, hostport: net.JoinHostPort(host, port), token: token, - httpClient: client, + httpClient: &http.Client{Transport: tr}, } }