Update config flow

This commit is contained in:
problematicconsumer
2023-08-19 14:09:49 +03:30
parent 076a25ea42
commit b43301ca0b
4 changed files with 35 additions and 58 deletions

View File

@@ -1,12 +1,30 @@
package mobile
import (
"encoding/json"
"os"
"github.com/hiddify/libcore/shared"
_ "github.com/sagernet/gomobile/event/key"
"github.com/sagernet/sing-box/option"
)
func ConvertToSingbox(path string) (string, error) {
options := shared.ConfigTemplateOptions{IncludeTunInbound: true, IncludeMixedInbound: false, IncludeLogOutput: false}
config, err := shared.ConvertToSingbox(path, options)
func Parse(path string) error {
return shared.ParseConfig(path)
}
func ApplyOverrides(path 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
}
overrides := shared.ConfigOverrides{ExcludeTunInbound: false, IncludeMixedInbound: false, IncludeLogOutput: false, LogLevel: "", IncludeLogTimestamp: false, ClashApiPort: 9090}
options = shared.ApplyOverrides(options, overrides)
config, err := json.Marshal(options)
return string(config), err
}