mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-08 22:24:15 +00:00
fix: Clash proxy YAML indentation for Clash Verge compatibility
Proxy entry fields were at same indent level as list item marker, causing "invalid yaml" in Clash Verge. Fixed to 4-space indent for fields and 6-space for nested *-opts sub-fields.
This commit is contained in:
parent
e059425d92
commit
d1e571adb7
1 changed files with 16 additions and 16 deletions
|
|
@ -283,7 +283,7 @@ func (s *SubClashService) buildProxyEntry(inbound *model.Inbound, client model.C
|
||||||
parts = append(parts, fmt.Sprintf("cipher: %q", cipher))
|
parts = append(parts, fmt.Sprintf("cipher: %q", cipher))
|
||||||
parts = append(parts, fmt.Sprintf("password: %q", password))
|
parts = append(parts, fmt.Sprintf("password: %q", password))
|
||||||
parts = append(parts, "udp: true")
|
parts = append(parts, "udp: true")
|
||||||
return strings.Join(parts, "\n ")
|
return strings.Join(parts, "\n ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TLS settings
|
// TLS settings
|
||||||
|
|
@ -294,9 +294,9 @@ func (s *SubClashService) buildProxyEntry(inbound *model.Inbound, client model.C
|
||||||
// publicKey and fingerprint are nested under realitySettings.settings
|
// publicKey and fingerprint are nested under realitySettings.settings
|
||||||
realityInner, _ := realitySetting["settings"].(map[string]any)
|
realityInner, _ := realitySetting["settings"].(map[string]any)
|
||||||
if publicKey, ok := realityInner["publicKey"].(string); ok && publicKey != "" {
|
if publicKey, ok := realityInner["publicKey"].(string); ok && publicKey != "" {
|
||||||
realityOpts := fmt.Sprintf("reality-opts:\n public-key: %q", publicKey)
|
realityOpts := fmt.Sprintf("reality-opts:\n public-key: %q", publicKey)
|
||||||
if shortIds, ok := realitySetting["shortIds"].([]any); ok && len(shortIds) > 0 {
|
if shortIds, ok := realitySetting["shortIds"].([]any); ok && len(shortIds) > 0 {
|
||||||
realityOpts += fmt.Sprintf("\n short-id: %q", fmt.Sprintf("%v", shortIds[0]))
|
realityOpts += fmt.Sprintf("\n short-id: %q", fmt.Sprintf("%v", shortIds[0]))
|
||||||
}
|
}
|
||||||
parts = append(parts, realityOpts)
|
parts = append(parts, realityOpts)
|
||||||
}
|
}
|
||||||
|
|
@ -345,13 +345,13 @@ func (s *SubClashService) buildProxyEntry(inbound *model.Inbound, client model.C
|
||||||
case "ws":
|
case "ws":
|
||||||
ws, _ := stream["wsSettings"].(map[string]any)
|
ws, _ := stream["wsSettings"].(map[string]any)
|
||||||
if path, ok := ws["path"].(string); ok && path != "" {
|
if path, ok := ws["path"].(string); ok && path != "" {
|
||||||
wsOpts := fmt.Sprintf("ws-opts:\n path: %q", path)
|
wsOpts := fmt.Sprintf("ws-opts:\n path: %q", path)
|
||||||
if host, ok := ws["host"].(string); ok && host != "" {
|
if host, ok := ws["host"].(string); ok && host != "" {
|
||||||
wsOpts += fmt.Sprintf("\n headers:\n Host: %q", host)
|
wsOpts += fmt.Sprintf("\n headers:\n Host: %q", host)
|
||||||
} else {
|
} else {
|
||||||
headers, _ := ws["headers"].(map[string]any)
|
headers, _ := ws["headers"].(map[string]any)
|
||||||
if h, ok := headers["Host"].(string); ok && h != "" {
|
if h, ok := headers["Host"].(string); ok && h != "" {
|
||||||
wsOpts += fmt.Sprintf("\n headers:\n Host: %q", h)
|
wsOpts += fmt.Sprintf("\n headers:\n Host: %q", h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parts = append(parts, wsOpts)
|
parts = append(parts, wsOpts)
|
||||||
|
|
@ -360,19 +360,19 @@ func (s *SubClashService) buildProxyEntry(inbound *model.Inbound, client model.C
|
||||||
case "grpc":
|
case "grpc":
|
||||||
grpc, _ := stream["grpcSettings"].(map[string]any)
|
grpc, _ := stream["grpcSettings"].(map[string]any)
|
||||||
if serviceName, ok := grpc["serviceName"].(string); ok && serviceName != "" {
|
if serviceName, ok := grpc["serviceName"].(string); ok && serviceName != "" {
|
||||||
parts = append(parts, fmt.Sprintf("grpc-opts:\n grpc-service-name: %q", serviceName))
|
parts = append(parts, fmt.Sprintf("grpc-opts:\n grpc-service-name: %q", serviceName))
|
||||||
}
|
}
|
||||||
|
|
||||||
case "h2":
|
case "h2":
|
||||||
h2, _ := stream["h2Settings"].(map[string]any)
|
h2, _ := stream["h2Settings"].(map[string]any)
|
||||||
if path, ok := h2["path"].(string); ok && path != "" {
|
if path, ok := h2["path"].(string); ok && path != "" {
|
||||||
h2Opts := fmt.Sprintf("h2-opts:\n path: %q", path)
|
h2Opts := fmt.Sprintf("h2-opts:\n path: %q", path)
|
||||||
if host, ok := h2["host"].([]any); ok && len(host) > 0 {
|
if host, ok := h2["host"].([]any); ok && len(host) > 0 {
|
||||||
hostStrs := make([]string, len(host))
|
hostStrs := make([]string, len(host))
|
||||||
for i, h := range host {
|
for i, h := range host {
|
||||||
hostStrs[i] = fmt.Sprintf("%q", fmt.Sprintf("%v", h))
|
hostStrs[i] = fmt.Sprintf("%q", fmt.Sprintf("%v", h))
|
||||||
}
|
}
|
||||||
h2Opts += fmt.Sprintf("\n host: [%s]", strings.Join(hostStrs, ", "))
|
h2Opts += fmt.Sprintf("\n host: [%s]", strings.Join(hostStrs, ", "))
|
||||||
}
|
}
|
||||||
parts = append(parts, h2Opts)
|
parts = append(parts, h2Opts)
|
||||||
}
|
}
|
||||||
|
|
@ -384,13 +384,13 @@ func (s *SubClashService) buildProxyEntry(inbound *model.Inbound, client model.C
|
||||||
request, _ := header["request"].(map[string]any)
|
request, _ := header["request"].(map[string]any)
|
||||||
httpOpts := "http-opts:"
|
httpOpts := "http-opts:"
|
||||||
if path, ok := request["path"].([]any); ok && len(path) > 0 {
|
if path, ok := request["path"].([]any); ok && len(path) > 0 {
|
||||||
httpOpts += fmt.Sprintf("\n path:\n - %q", fmt.Sprintf("%v", path[0]))
|
httpOpts += fmt.Sprintf("\n path:\n - %q", fmt.Sprintf("%v", path[0]))
|
||||||
}
|
}
|
||||||
if headers, ok := request["headers"].(map[string]any); ok && len(headers) > 0 {
|
if headers, ok := request["headers"].(map[string]any); ok && len(headers) > 0 {
|
||||||
httpOpts += "\n headers:"
|
httpOpts += "\n headers:"
|
||||||
for k, v := range headers {
|
for k, v := range headers {
|
||||||
if vals, ok := v.([]any); ok && len(vals) > 0 {
|
if vals, ok := v.([]any); ok && len(vals) > 0 {
|
||||||
httpOpts += fmt.Sprintf("\n %s:\n - %q", k, fmt.Sprintf("%v", vals[0]))
|
httpOpts += fmt.Sprintf("\n %s:\n - %q", k, fmt.Sprintf("%v", vals[0]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -400,20 +400,20 @@ func (s *SubClashService) buildProxyEntry(inbound *model.Inbound, client model.C
|
||||||
case "httpupgrade":
|
case "httpupgrade":
|
||||||
hu, _ := stream["httpupgradeSettings"].(map[string]any)
|
hu, _ := stream["httpupgradeSettings"].(map[string]any)
|
||||||
if path, ok := hu["path"].(string); ok && path != "" {
|
if path, ok := hu["path"].(string); ok && path != "" {
|
||||||
huOpts := fmt.Sprintf("httpupgrade-opts:\n path: %q", path)
|
huOpts := fmt.Sprintf("httpupgrade-opts:\n path: %q", path)
|
||||||
if host, ok := hu["host"].(string); ok && host != "" {
|
if host, ok := hu["host"].(string); ok && host != "" {
|
||||||
huOpts += fmt.Sprintf("\n host: %q", host)
|
huOpts += fmt.Sprintf("\n host: %q", host)
|
||||||
} else {
|
} else {
|
||||||
headers, _ := hu["headers"].(map[string]any)
|
headers, _ := hu["headers"].(map[string]any)
|
||||||
if h, ok := headers["Host"].(string); ok && h != "" {
|
if h, ok := headers["Host"].(string); ok && h != "" {
|
||||||
huOpts += fmt.Sprintf("\n host: %q", h)
|
huOpts += fmt.Sprintf("\n host: %q", h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parts = append(parts, huOpts)
|
parts = append(parts, huOpts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join(parts, "\n ")
|
return strings.Join(parts, "\n ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseShadowsocksSettings extracts cipher and password from shadowsocks client settings.
|
// parseShadowsocksSettings extracts cipher and password from shadowsocks client settings.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue