Release 1.3.0: Hysteria2 BBR/Salamander/masquerade options and subscription URL import.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -180,32 +180,7 @@ func (e *Engine) LocalSOCKSProxy() (string, bool) {
|
||||
return e.profile.SOCKSListenHostPort()
|
||||
}
|
||||
|
||||
func writeRuntimeConfig(path string, profile config.Profile) error {
|
||||
server, _, err := NormalizeShareLink(profile.Proxy)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
socks := "127.0.0.1:1080"
|
||||
httpListen := "127.0.0.1:1081"
|
||||
if hp, ok := profile.SOCKSListenHostPort(); ok {
|
||||
socks = hp
|
||||
}
|
||||
if hp, ok := profile.HTTPListenHostPort(); ok {
|
||||
httpListen = hp
|
||||
}
|
||||
|
||||
var b strings.Builder
|
||||
b.WriteString("# generated by Navis — do not edit\n")
|
||||
b.WriteString("server: " + yamlQuote(server) + "\n")
|
||||
b.WriteString("socks5:\n")
|
||||
b.WriteString(" listen: " + yamlQuote(socks) + "\n")
|
||||
b.WriteString("http:\n")
|
||||
b.WriteString(" listen: " + yamlQuote(httpListen) + "\n")
|
||||
return os.WriteFile(path, []byte(b.String()), 0o600)
|
||||
}
|
||||
|
||||
func yamlQuote(s string) string {
|
||||
// Always quote — URIs and host:port can confuse YAML.
|
||||
escaped := strings.ReplaceAll(s, `\`, `\\`)
|
||||
escaped = strings.ReplaceAll(escaped, `"`, `\"`)
|
||||
return `"` + escaped + `"`
|
||||
|
||||
Reference in New Issue
Block a user