mirror of
https://github.com/alireza0/s-ui.git
synced 2026-10-09 03:27:34 +00:00
fix headers in clash sub #1126
This commit is contained in:
parent
3cf47bb501
commit
b04dec5c80
1 changed files with 23 additions and 2 deletions
|
|
@ -296,8 +296,29 @@ func (s *ClashService) ConvertToClashMeta(outbounds *[]map[string]interface{}, b
|
|||
if path, ok := transport["path"].(string); ok {
|
||||
wsOpts["path"] = path
|
||||
}
|
||||
if headers, ok := transport["headers"].([]interface{}); ok {
|
||||
wsOpts["headers"] = headers
|
||||
wsHeaders := make(map[string]interface{})
|
||||
if headers, ok := transport["headers"].(map[string]interface{}); ok {
|
||||
for k, v := range headers {
|
||||
if arr, ok := v.([]interface{}); ok {
|
||||
if len(arr) > 0 {
|
||||
wsHeaders[k] = arr[0]
|
||||
}
|
||||
} else {
|
||||
wsHeaders[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
if _, hasHost := wsHeaders["Host"]; !hasHost {
|
||||
if host, ok := transport["host"].(string); ok && host != "" {
|
||||
wsHeaders["Host"] = host
|
||||
} else if isTls {
|
||||
if sni, ok := tls["server_name"].(string); ok && sni != "" {
|
||||
wsHeaders["Host"] = sni
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(wsHeaders) > 0 {
|
||||
wsOpts["headers"] = wsHeaders
|
||||
}
|
||||
if ed, ok := transport["early_data_header_name"].(string); ok {
|
||||
wsOpts["early-data-header-name"] = ed
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue