Files
umbrix-libcore/mobile/mobile.go
problematicconsumer 953e6a02d7 Add config export
2023-11-12 12:50:14 +03:30

33 lines
744 B
Go

package mobile
import (
"encoding/json"
"os"
"github.com/hiddify/libcore/shared"
_ "github.com/sagernet/gomobile/event/key"
"github.com/sagernet/sing-box/option"
)
func Parse(path string, tempPath string, debug bool) error {
return shared.ParseConfig(path, tempPath, debug)
}
func BuildConfig(path string, configOptionsJson string) (string, error) {
fileContent, err := os.ReadFile(path)
if err != nil {
return "", err
}
var options option.Options
err = options.UnmarshalJSON(fileContent)
if err != nil {
return "", err
}
configOptions := &shared.ConfigOptions{}
err = json.Unmarshal([]byte(configOptionsJson), configOptions)
if err != nil {
return "", nil
}
return shared.BuildConfigJson(*configOptions, options)
}