Add support for the customization of the host domain in WebSocket (One of the V2Ray transport layers)

This commit is contained in:
OrLojqrG 2023-11-05 12:44:33 +00:00 committed by GitHub
parent 556c74ee15
commit 7044de8e4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 1 deletions

View File

@ -92,6 +92,7 @@ Specifies the timeout duration after sending a PING frame, within which a respon
```json ```json
{ {
"type": "ws", "type": "ws",
"host": "",
"path": "", "path": "",
"headers": {}, "headers": {},
"max_early_data": 0, "max_early_data": 0,
@ -99,6 +100,10 @@ Specifies the timeout duration after sending a PING frame, within which a respon
} }
``` ```
#### host
Host domain.
#### path #### path
Path of HTTP request. Path of HTTP request.

View File

@ -91,6 +91,7 @@ HTTP 请求的额外标头
```json ```json
{ {
"type": "ws", "type": "ws",
"host": "",
"path": "", "path": "",
"headers": {}, "headers": {},
"max_early_data": 0, "max_early_data": 0,
@ -98,6 +99,10 @@ HTTP 请求的额外标头
} }
``` ```
#### host
主机域名。
#### path #### path
HTTP 请求路径 HTTP 请求路径

View File

@ -75,6 +75,7 @@ type V2RayHTTPOptions struct {
} }
type V2RayWebsocketOptions struct { type V2RayWebsocketOptions struct {
Host string `json:"host,omitempty"`
Path string `json:"path,omitempty"` Path string `json:"path,omitempty"`
Headers HTTPHeader `json:"headers,omitempty"` Headers HTTPHeader `json:"headers,omitempty"`
MaxEarlyData uint32 `json:"max_early_data,omitempty"` MaxEarlyData uint32 `json:"max_early_data,omitempty"`

View File

@ -43,7 +43,11 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, opt
} else { } else {
requestURL.Scheme = "wss" requestURL.Scheme = "wss"
} }
requestURL.Host = serverAddr.String() if options.Host == "" {
requestURL.Host = serverAddr.String()
} else {
requestURL.Host = options.Host
}
requestURL.Path = options.Path requestURL.Path = options.Path
err := sHTTP.URLSetPath(&requestURL, options.Path) err := sHTTP.URLSetPath(&requestURL, options.Path)
if err != nil { if err != nil {