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
{
"type": "ws",
"host": "",
"path": "",
"headers": {},
"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 of HTTP request.

View File

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

View File

@ -75,6 +75,7 @@ type V2RayHTTPOptions struct {
}
type V2RayWebsocketOptions struct {
Host string `json:"host,omitempty"`
Path string `json:"path,omitempty"`
Headers HTTPHeader `json:"headers,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 {
requestURL.Scheme = "wss"
}
requestURL.Host = serverAddr.String()
if options.Host == "" {
requestURL.Host = serverAddr.String()
} else {
requestURL.Host = options.Host
}
requestURL.Path = options.Path
err := sHTTP.URLSetPath(&requestURL, options.Path)
if err != nil {