diff options
Diffstat (limited to 'sub')
| -rw-r--r-- | sub/subJsonService.go | 3 | ||||
| -rw-r--r-- | sub/subService.go | 130 |
2 files changed, 78 insertions, 55 deletions
diff --git a/sub/subJsonService.go b/sub/subJsonService.go index 76d0b126..7b072b95 100644 --- a/sub/subJsonService.go +++ b/sub/subJsonService.go @@ -223,8 +223,9 @@ func (s *SubJsonService) streamData(stream string) map[string]interface{} { streamSettings["wsSettings"] = s.removeAcceptProxy(streamSettings["wsSettings"]) case "httpupgrade": streamSettings["httpupgradeSettings"] = s.removeAcceptProxy(streamSettings["httpupgradeSettings"]) + case "splithttp": + streamSettings["splithttpSettings"] = s.removeAcceptProxy(streamSettings["splithttpSettings"]) } - return streamSettings } diff --git a/sub/subService.go b/sub/subService.go index 3ba0bda7..cc73c6a1 100644 --- a/sub/subService.go +++ b/sub/subService.go @@ -202,12 +202,11 @@ func (s *SubService) genVmessLink(inbound *model.Inbound, email string) string { case "ws": ws, _ := stream["wsSettings"].(map[string]interface{}) obj["path"] = ws["path"].(string) - obj["host"] = ws["host"].(string) - if headers, ok := ws["headers"].(map[string]interface{}); ok { - hostFromHeaders := searchHost(headers) - if hostFromHeaders != "" { - obj["host"] = hostFromHeaders - } + if host, ok := ws["host"].(string); ok && len(host) > 0 { + obj["host"] = host + } else { + headers, _ := ws["headers"].(map[string]interface{}) + obj["host"] = searchHost(headers) } case "http": obj["net"] = "h2" @@ -230,12 +229,20 @@ func (s *SubService) genVmessLink(inbound *model.Inbound, email string) string { case "httpupgrade": 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 - } + if host, ok := httpupgrade["host"].(string); ok && len(host) > 0 { + obj["host"] = host + } else { + headers, _ := httpupgrade["headers"].(map[string]interface{}) + obj["host"] = searchHost(headers) + } + case "splithttp": + splithttp, _ := stream["splithttpSettings"].(map[string]interface{}) + obj["path"] = splithttp["path"].(string) + if host, ok := splithttp["host"].(string); ok && len(host) > 0 { + obj["host"] = host + } else { + headers, _ := splithttp["headers"].(map[string]interface{}) + obj["host"] = searchHost(headers) } } security, _ := stream["security"].(string) @@ -352,13 +359,11 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string { case "ws": ws, _ := stream["wsSettings"].(map[string]interface{}) params["path"] = ws["path"].(string) - params["host"] = ws["host"].(string) - headers, _ := ws["headers"].(map[string]interface{}) - if headers != nil { - hostFromHeaders := searchHost(headers) - if hostFromHeaders != "" { - params["host"] = hostFromHeaders - } + if host, ok := ws["host"].(string); ok && len(host) > 0 { + params["host"] = host + } else { + headers, _ := ws["headers"].(map[string]interface{}) + params["host"] = searchHost(headers) } case "http": http, _ := stream["httpSettings"].(map[string]interface{}) @@ -380,13 +385,20 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string { case "httpupgrade": 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 - } + if host, ok := httpupgrade["host"].(string); ok && len(host) > 0 { + params["host"] = host + } else { + headers, _ := httpupgrade["headers"].(map[string]interface{}) + params["host"] = searchHost(headers) + } + case "splithttp": + splithttp, _ := stream["splithttpSettings"].(map[string]interface{}) + params["path"] = splithttp["path"].(string) + if host, ok := splithttp["host"].(string); ok && len(host) > 0 { + params["host"] = host + } else { + headers, _ := splithttp["headers"].(map[string]interface{}) + params["host"] = searchHost(headers) } } security, _ := stream["security"].(string) @@ -581,13 +593,11 @@ func (s *SubService) genTrojanLink(inbound *model.Inbound, email string) string case "ws": ws, _ := stream["wsSettings"].(map[string]interface{}) params["path"] = ws["path"].(string) - params["host"] = ws["host"].(string) - headers, _ := ws["headers"].(map[string]interface{}) - if headers != nil { - hostFromHeaders := searchHost(headers) - if hostFromHeaders != "" { - params["host"] = hostFromHeaders - } + if host, ok := ws["host"].(string); ok && len(host) > 0 { + params["host"] = host + } else { + headers, _ := ws["headers"].(map[string]interface{}) + params["host"] = searchHost(headers) } case "http": http, _ := stream["httpSettings"].(map[string]interface{}) @@ -609,13 +619,20 @@ func (s *SubService) genTrojanLink(inbound *model.Inbound, email string) string case "httpupgrade": 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 - } + if host, ok := httpupgrade["host"].(string); ok && len(host) > 0 { + params["host"] = host + } else { + headers, _ := httpupgrade["headers"].(map[string]interface{}) + params["host"] = searchHost(headers) + } + case "splithttp": + splithttp, _ := stream["splithttpSettings"].(map[string]interface{}) + params["path"] = splithttp["path"].(string) + if host, ok := splithttp["host"].(string); ok && len(host) > 0 { + params["host"] = host + } else { + headers, _ := splithttp["headers"].(map[string]interface{}) + params["host"] = searchHost(headers) } } security, _ := stream["security"].(string) @@ -811,13 +828,11 @@ func (s *SubService) genShadowsocksLink(inbound *model.Inbound, email string) st case "ws": ws, _ := stream["wsSettings"].(map[string]interface{}) params["path"] = ws["path"].(string) - params["host"] = ws["host"].(string) - headers, _ := ws["headers"].(map[string]interface{}) - if headers != nil { - hostFromHeaders := searchHost(headers) - if hostFromHeaders != "" { - params["host"] = hostFromHeaders - } + if host, ok := ws["host"].(string); ok && len(host) > 0 { + params["host"] = host + } else { + headers, _ := ws["headers"].(map[string]interface{}) + params["host"] = searchHost(headers) } case "http": http, _ := stream["httpSettings"].(map[string]interface{}) @@ -839,13 +854,20 @@ func (s *SubService) genShadowsocksLink(inbound *model.Inbound, email string) st case "httpupgrade": 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 - } + if host, ok := httpupgrade["host"].(string); ok && len(host) > 0 { + params["host"] = host + } else { + headers, _ := httpupgrade["headers"].(map[string]interface{}) + params["host"] = searchHost(headers) + } + case "splithttp": + splithttp, _ := stream["splithttpSettings"].(map[string]interface{}) + params["path"] = splithttp["path"].(string) + if host, ok := splithttp["host"].(string); ok && len(host) > 0 { + params["host"] = host + } else { + headers, _ := splithttp["headers"].(map[string]interface{}) + params["host"] = searchHost(headers) } } |
