Fix v2ray transport's client path

&& Update the docs
This commit is contained in:
unknown 2023-12-22 18:28:47 +03:30
parent c16b017cd1
commit 4cc9ebb5e8
5 changed files with 16 additions and 6 deletions

View File

@ -55,7 +55,7 @@ The client will choose randomly and the server will verify if not empty.
Path of HTTP request. Path of HTTP request.
The server will verify if not empty. `/` will be used if empty.
#### method #### method
@ -103,7 +103,7 @@ Specifies the timeout duration after sending a PING frame, within which a respon
Path of HTTP request. Path of HTTP request.
The server will verify if not empty. `/` will be used if empty.
#### headers #### headers
@ -203,7 +203,7 @@ The server will verify if not empty.
Path of HTTP request. Path of HTTP request.
The server will verify if not empty. `/` will be used if empty.
#### headers #### headers

View File

@ -54,7 +54,7 @@ V2Ray Transport 是 v2ray 发明的一组私有协议,并污染了其他协议
HTTP 请求路径 HTTP 请求路径
默认服务器将验证 默认 `/`
#### method #### method
@ -102,7 +102,7 @@ HTTP 请求的额外标头
HTTP 请求路径 HTTP 请求路径
默认服务器将验证 默认 `/`
#### headers #### headers
@ -202,7 +202,7 @@ gRPC 服务名称。
HTTP 请求路径 HTTP 请求路径
默认服务器将验证 默认 `/`
#### headers #### headers

View File

@ -7,6 +7,7 @@ import (
"net" "net"
"net/http" "net/http"
"net/url" "net/url"
"strings"
"time" "time"
"github.com/sagernet/sing-box/adapter" "github.com/sagernet/sing-box/adapter"
@ -77,6 +78,9 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, opt
} else { } else {
uri.Scheme = "https" uri.Scheme = "https"
} }
if !strings.Contains(options.Path, "/") {
options.Path = "/" + options.Path
}
uri.Host = serverAddr.String() uri.Host = serverAddr.String()
uri.Path = options.Path uri.Path = options.Path
err := sHTTP.URLSetPath(&uri, options.Path) err := sHTTP.URLSetPath(&uri, options.Path)

View File

@ -50,6 +50,9 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, opt
} else { } else {
requestURL.Scheme = "https" requestURL.Scheme = "https"
} }
if !strings.Contains(options.Path, "/") {
options.Path = "/" + options.Path
}
requestURL.Host = serverAddr.String() requestURL.Host = serverAddr.String()
requestURL.Path = options.Path requestURL.Path = options.Path
err := sHTTP.URLSetPath(&requestURL, options.Path) err := sHTTP.URLSetPath(&requestURL, options.Path)

View File

@ -46,6 +46,9 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, opt
} else { } else {
requestURL.Scheme = "wss" requestURL.Scheme = "wss"
} }
if !strings.Contains(options.Path, "/") {
options.Path = "/" + options.Path
}
requestURL.Host = serverAddr.String() requestURL.Host = serverAddr.String()
requestURL.Path = options.Path requestURL.Path = options.Path
err := sHTTP.URLSetPath(&requestURL, options.Path) err := sHTTP.URLSetPath(&requestURL, options.Path)