From d5f94b65b7afc35a336fd0c964491f75290bc0d0 Mon Sep 17 00:00:00 2001 From: H1JK Date: Sat, 8 Apr 2023 17:44:11 +0800 Subject: [PATCH] Fix gRPC service name escape --- transport/v2raygrpclite/client.go | 8 ++++---- transport/v2raygrpclite/server.go | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/transport/v2raygrpclite/client.go b/transport/v2raygrpclite/client.go index 393edafd..a6120c89 100644 --- a/transport/v2raygrpclite/client.go +++ b/transport/v2raygrpclite/client.go @@ -12,7 +12,6 @@ import ( "github.com/sagernet/sing-box/common/tls" "github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/transport/v2rayhttp" - F "github.com/sagernet/sing/common/format" M "github.com/sagernet/sing/common/metadata" N "github.com/sagernet/sing/common/network" @@ -48,9 +47,10 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, opt DisableCompression: true, }, url: &url.URL{ - Scheme: "https", - Host: serverAddr.String(), - Path: F.ToString("/", url.QueryEscape(options.ServiceName), "/Tun"), + Scheme: "https", + Host: serverAddr.String(), + Path: "/" + options.ServiceName + "/Tun", + RawPath: "/" + url.PathEscape(options.ServiceName) + "/Tun", }, } diff --git a/transport/v2raygrpclite/server.go b/transport/v2raygrpclite/server.go index 18809ee4..774d880f 100644 --- a/transport/v2raygrpclite/server.go +++ b/transport/v2raygrpclite/server.go @@ -2,10 +2,8 @@ package v2raygrpclite import ( "context" - "fmt" "net" "net/http" - "net/url" "os" "strings" "time" @@ -45,7 +43,7 @@ func NewServer(ctx context.Context, options option.V2RayGRPCOptions, tlsConfig t server := &Server{ tlsConfig: tlsConfig, handler: handler, - path: fmt.Sprintf("/%s/Tun", url.QueryEscape(options.ServiceName)), + path: "/" + options.ServiceName + "/Tun", h2Server: &http2.Server{ IdleTimeout: time.Duration(options.IdleTimeout), },