From 75e342b6bacca604b4cc19b397aa29124e5c2338 Mon Sep 17 00:00:00 2001 From: problematicconsumer Date: Fri, 22 Sep 2023 23:25:38 +0330 Subject: [PATCH] Fix minor bugs --- custom/custom.go | 4 ++-- custom/status.go | 2 +- mobile/mobile.go | 4 ++-- shared/parser.go | 7 ++++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/custom/custom.go b/custom/custom.go index 32f12c6..3f67550 100644 --- a/custom/custom.go +++ b/custom/custom.go @@ -30,8 +30,8 @@ func setup(baseDir *C.char, workingDir *C.char, tempDir *C.char, statusPort C.lo } //export parse -func parse(path *C.char) *C.char { - err := shared.ParseConfig(C.GoString(path)) +func parse(path *C.char, tempPath *C.char, debug bool) *C.char { + err := shared.ParseConfig(C.GoString(path), C.GoString(tempPath), debug) if err != nil { return C.CString(err.Error()) } diff --git a/custom/status.go b/custom/status.go index 08c14bf..3c45720 100644 --- a/custom/status.go +++ b/custom/status.go @@ -29,5 +29,5 @@ func stopAndAlert(alert string, err error) error { msg, _ := json.Marshal(StatusMessage{Status: status, Alert: &alert, Message: &message}) bridge.SendStringToPort(statusPropagationPort, string(msg)) - return err + return nil } diff --git a/mobile/mobile.go b/mobile/mobile.go index 9031971..56d90ce 100644 --- a/mobile/mobile.go +++ b/mobile/mobile.go @@ -9,8 +9,8 @@ import ( "github.com/sagernet/sing-box/option" ) -func Parse(path string) error { - return shared.ParseConfig(path) +func Parse(path string, tempPath string, debug bool) error { + return shared.ParseConfig(path, tempPath, debug) } func BuildConfig(path string, configOptionsJson string) (string, error) { diff --git a/shared/parser.go b/shared/parser.go index 365df65..bf9448f 100644 --- a/shared/parser.go +++ b/shared/parser.go @@ -15,8 +15,8 @@ import ( //go:embed config.json.template var configByte []byte -func ParseConfig(path string) error { - content, err := os.ReadFile(path) +func ParseConfig(path string, tempPath string, debug bool) error { + content, err := os.ReadFile(tempPath) if err != nil { return err } @@ -28,7 +28,6 @@ func ParseConfig(path string) error { config = content } } - err = libbox.CheckConfig(string(config)) if err != nil { @@ -40,6 +39,7 @@ func ParseConfig(path string) error { } return nil } + func parseV2rayFormat(content []byte) ([]byte, error) { singconf, err := ray2sing.Ray2Singbox(string(content)) if err != nil { @@ -48,6 +48,7 @@ func parseV2rayFormat(content []byte) ([]byte, error) { } return []byte(singconf), nil } + func parseClash(content []byte) ([]byte, error) { clashConfig := clash.Clash{} err := yaml.Unmarshal(content, &clashConfig)