Add host for WS

This commit is contained in:
mhsanaei
2024-04-01 17:02:02 +04:30
parent 44b7eb881c
commit 4e20bb5f02
5 changed files with 50 additions and 10 deletions

View File

@@ -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)