add header for httpupgrade

This commit is contained in:
mhsanaei
2024-04-02 23:41:06 +03:30
parent fa7a6a3f99
commit c147636133
6 changed files with 133 additions and 50 deletions

View File

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