Fix override logic

This commit is contained in:
problematicconsumer
2023-08-22 00:54:58 +03:30
parent 85efdbb5ff
commit 83d668866e
8 changed files with 351 additions and 198 deletions

22
shared/debug.go Normal file
View File

@@ -0,0 +1,22 @@
package shared
import (
"bytes"
"encoding/json"
"os"
"path/filepath"
"github.com/sagernet/sing-box/option"
)
func SaveCurrentConfig(path string, options option.Options) error {
var buffer bytes.Buffer
json.NewEncoder(&buffer)
encoder := json.NewEncoder(&buffer)
encoder.SetIndent("", " ")
err := encoder.Encode(options)
if err != nil {
return err
}
return os.WriteFile(filepath.Join(path, "current-config.json"), buffer.Bytes(), 0777)
}