diff options
| author | mhsanaei <ho3ein.sanaei@gmail.com> | 2024-04-02 23:11:06 +0300 |
|---|---|---|
| committer | mhsanaei <ho3ein.sanaei@gmail.com> | 2024-04-02 23:11:06 +0300 |
| commit | c147636133a62b5a5b90f9cc4abc37949832e2e1 (patch) | |
| tree | 6471ed45e3971185a6ddc832a1264f364bfcf7eb /sub/subService.go | |
| parent | fa7a6a3f99ba2d0b08f9893fc6f04c434a3ec8f8 (diff) | |
add header for httpupgrade
Diffstat (limited to 'sub/subService.go')
| -rw-r--r-- | sub/subService.go | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/sub/subService.go b/sub/subService.go index ae530597..3ba0bda7 100644 --- a/sub/subService.go +++ b/sub/subService.go @@ -231,8 +231,13 @@ func (s *SubService) genVmessLink(inbound *model.Inbound, email string) string { httpupgrade, _ := stream["httpupgradeSettings"].(map[string]interface{}) obj["path"] = httpupgrade["path"].(string) obj["host"] = httpupgrade["host"].(string) + if headers, ok := httpupgrade["headers"].(map[string]interface{}); ok { + hostFromHeaders := searchHost(headers) + if hostFromHeaders != "" { + obj["host"] = hostFromHeaders + } + } } - security, _ := stream["security"].(string) obj["tls"] = security if security == "tls" { @@ -347,8 +352,8 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string { case "ws": ws, _ := stream["wsSettings"].(map[string]interface{}) params["path"] = ws["path"].(string) - headers, _ := ws["headers"].(map[string]interface{}) params["host"] = ws["host"].(string) + headers, _ := ws["headers"].(map[string]interface{}) if headers != nil { hostFromHeaders := searchHost(headers) if hostFromHeaders != "" { @@ -376,8 +381,14 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string { httpupgrade, _ := stream["httpupgradeSettings"].(map[string]interface{}) params["path"] = httpupgrade["path"].(string) params["host"] = httpupgrade["host"].(string) + headers, _ := httpupgrade["headers"].(map[string]interface{}) + if headers != nil { + hostFromHeaders := searchHost(headers) + if hostFromHeaders != "" { + params["host"] = hostFromHeaders + } + } } - security, _ := stream["security"].(string) if security == "tls" { params["security"] = "tls" @@ -570,8 +581,8 @@ func (s *SubService) genTrojanLink(inbound *model.Inbound, email string) string case "ws": ws, _ := stream["wsSettings"].(map[string]interface{}) params["path"] = ws["path"].(string) - headers, _ := ws["headers"].(map[string]interface{}) params["host"] = ws["host"].(string) + headers, _ := ws["headers"].(map[string]interface{}) if headers != nil { hostFromHeaders := searchHost(headers) if hostFromHeaders != "" { @@ -599,8 +610,14 @@ func (s *SubService) genTrojanLink(inbound *model.Inbound, email string) string httpupgrade, _ := stream["httpupgradeSettings"].(map[string]interface{}) params["path"] = httpupgrade["path"].(string) params["host"] = httpupgrade["host"].(string) + headers, _ := httpupgrade["headers"].(map[string]interface{}) + if headers != nil { + hostFromHeaders := searchHost(headers) + if hostFromHeaders != "" { + params["host"] = hostFromHeaders + } + } } - security, _ := stream["security"].(string) if security == "tls" { params["security"] = "tls" @@ -794,8 +811,8 @@ func (s *SubService) genShadowsocksLink(inbound *model.Inbound, email string) st case "ws": ws, _ := stream["wsSettings"].(map[string]interface{}) params["path"] = ws["path"].(string) - headers, _ := ws["headers"].(map[string]interface{}) params["host"] = ws["host"].(string) + headers, _ := ws["headers"].(map[string]interface{}) if headers != nil { hostFromHeaders := searchHost(headers) if hostFromHeaders != "" { @@ -823,6 +840,13 @@ func (s *SubService) genShadowsocksLink(inbound *model.Inbound, email string) st httpupgrade, _ := stream["httpupgradeSettings"].(map[string]interface{}) params["path"] = httpupgrade["path"].(string) params["host"] = httpupgrade["host"].(string) + headers, _ := httpupgrade["headers"].(map[string]interface{}) + if headers != nil { + hostFromHeaders := searchHost(headers) + if hostFromHeaders != "" { + params["host"] = hostFromHeaders + } + } } security, _ := stream["security"].(string) |
