diff options
| author | mhsanaei <ho3ein.sanaei@gmail.com> | 2024-04-01 15:32:02 +0300 |
|---|---|---|
| committer | mhsanaei <ho3ein.sanaei@gmail.com> | 2024-04-01 15:32:02 +0300 |
| commit | 4e20bb5f02c4aef31c9026458984825e820414ba (patch) | |
| tree | 2229b2c5ce10742631b39efa4f6c1099c6d1f74f /sub/subService.go | |
| parent | 44b7eb881cb2ff2142f3566913c1e70ee8106556 (diff) | |
Add host for WS
Diffstat (limited to 'sub/subService.go')
| -rw-r--r-- | sub/subService.go | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/sub/subService.go b/sub/subService.go index 42713756..ae530597 100644 --- a/sub/subService.go +++ b/sub/subService.go @@ -202,8 +202,13 @@ func (s *SubService) genVmessLink(inbound *model.Inbound, email string) string { case "ws": ws, _ := stream["wsSettings"].(map[string]interface{}) obj["path"] = ws["path"].(string) - headers, _ := ws["headers"].(map[string]interface{}) - obj["host"] = searchHost(headers) + obj["host"] = ws["host"].(string) + if headers, ok := ws["headers"].(map[string]interface{}); ok { + hostFromHeaders := searchHost(headers) + if hostFromHeaders != "" { + obj["host"] = hostFromHeaders + } + } case "http": obj["net"] = "h2" http, _ := stream["httpSettings"].(map[string]interface{}) @@ -343,7 +348,13 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string { ws, _ := stream["wsSettings"].(map[string]interface{}) params["path"] = ws["path"].(string) headers, _ := ws["headers"].(map[string]interface{}) - params["host"] = searchHost(headers) + params["host"] = ws["host"].(string) + if headers != nil { + hostFromHeaders := searchHost(headers) + if hostFromHeaders != "" { + params["host"] = hostFromHeaders + } + } case "http": http, _ := stream["httpSettings"].(map[string]interface{}) params["path"] = http["path"].(string) @@ -560,7 +571,13 @@ func (s *SubService) genTrojanLink(inbound *model.Inbound, email string) string ws, _ := stream["wsSettings"].(map[string]interface{}) params["path"] = ws["path"].(string) headers, _ := ws["headers"].(map[string]interface{}) - params["host"] = searchHost(headers) + params["host"] = ws["host"].(string) + if headers != nil { + hostFromHeaders := searchHost(headers) + if hostFromHeaders != "" { + params["host"] = hostFromHeaders + } + } case "http": http, _ := stream["httpSettings"].(map[string]interface{}) params["path"] = http["path"].(string) @@ -778,7 +795,13 @@ func (s *SubService) genShadowsocksLink(inbound *model.Inbound, email string) st ws, _ := stream["wsSettings"].(map[string]interface{}) params["path"] = ws["path"].(string) headers, _ := ws["headers"].(map[string]interface{}) - params["host"] = searchHost(headers) + params["host"] = ws["host"].(string) + if headers != nil { + hostFromHeaders := searchHost(headers) + if hostFromHeaders != "" { + params["host"] = hostFromHeaders + } + } case "http": http, _ := stream["httpSettings"].(map[string]interface{}) params["path"] = http["path"].(string) |
