feat: add compatible Trojan manager image

This commit is contained in:
chermack
2026-07-26 05:01:15 +08:00
parent 059be96536
commit cb17d56cae
26 changed files with 320 additions and 41 deletions
+5 -1
View File
@@ -6,6 +6,7 @@ import (
"github.com/tidwall/pretty"
"github.com/tidwall/sjson"
"os"
"path/filepath"
)
var configPath = "/usr/local/etc/trojan/config.json"
@@ -53,10 +54,13 @@ func Save(data []byte, path string) bool {
if path == "" {
path = configPath
}
if err := os.WriteFile(path, pretty.Pretty(data), 0644); err != nil {
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { fmt.Println(err); return false }
tmp := path + ".tmp"
if err := os.WriteFile(tmp, pretty.Pretty(data), 0644); err != nil {
fmt.Println(err)
return false
}
if err := os.Rename(tmp, path); err != nil { fmt.Println(err); return false }
return true
}