diff --git a/main/log/log.go b/main/log/log.go index c249f97..eca083b 100644 --- a/main/log/log.go +++ b/main/log/log.go @@ -4,11 +4,25 @@ import ( "XrayHelper/main/serial" "fmt" "github.com/fatih/color" + "os/exec" + "strings" "time" ) var Verbose *bool +func init() { + out, err := exec.Command("/system/bin/getprop", "persist.sys.timezone").Output() + if err != nil { + return + } + z, err := time.LoadLocation(strings.TrimSpace(string(out))) + if err != nil { + return + } + time.Local = z +} + // HandleError record error log func HandleError(v interface{}) { if str := serial.ToString(v); str != "" { diff --git a/main/main.go b/main/main.go index 06e73bf..399d956 100644 --- a/main/main.go +++ b/main/main.go @@ -1,16 +1,9 @@ package main import ( - "XrayHelper/main/builds" - "fmt" "os" ) func main() { - if len(os.Args) == 1 { - fmt.Println(builds.VersionStatement()) - fmt.Println(builds.IntroStatement()) - return - } os.Exit(LoadOption()) } diff --git a/main/option.go b/main/option.go index baaa05b..dd23245 100644 --- a/main/option.go +++ b/main/option.go @@ -6,6 +6,7 @@ import ( "XrayHelper/main/log" "fmt" "github.com/jessevdk/go-flags" + "os" ) var Option struct { @@ -20,6 +21,11 @@ var Option struct { // LoadOption load Option, the program entry func LoadOption() int { + if len(os.Args) == 1 { + fmt.Println(builds.VersionStatement()) + fmt.Println(builds.IntroStatement()) + return 0 + } rCode := 0 log.Verbose = &Option.VerboseFlag builds.ConfigFilePath = &Option.ConfigFilePath