From 34fdfd1ad89f9790454481f9b49c259929d06dfc Mon Sep 17 00:00:00 2001 From: codeskyblue Date: Fri, 20 Mar 2020 13:09:17 +0800 Subject: [PATCH] update gorilla lib version, add lazyInit --- .goreleaser.yml | 1 - go.mod | 4 ++-- main.go | 20 +++++++------------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index df4fb5b..f0495cc 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -2,7 +2,6 @@ builds: - goos: - linux - - windows goarch: - amd64 - arm diff --git a/go.mod b/go.mod index bcf118d..507cc13 100644 --- a/go.mod +++ b/go.mod @@ -21,8 +21,8 @@ require ( github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect github.com/google/go-querystring v1.0.0 // indirect github.com/gorilla/context v1.1.1 // indirect - github.com/gorilla/handlers v1.4.0 - github.com/gorilla/mux v1.6.2 + github.com/gorilla/handlers v1.4.2 + github.com/gorilla/mux v1.7.4 github.com/gorilla/websocket v1.4.0 github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 diff --git a/main.go b/main.go index c109f3c..5e724a0 100644 --- a/main.go +++ b/main.go @@ -64,10 +64,6 @@ const ( apkVersionName = "1.0.4" ) -func init() { - syslog.SetFlags(syslog.Lshortfile | syslog.LstdFlags) -} - // singleFight for http request // - minicap // - minitouch @@ -418,6 +414,8 @@ func stopSelf() { } func init() { + syslog.SetFlags(syslog.Lshortfile | syslog.LstdFlags) + // Set timezone. // // Note that Android zoneinfo is stored in /system/usr/share/zoneinfo, @@ -443,12 +441,16 @@ func init() { } time.Local = time.FixedZone(tz, offset*3600) } +} +// lazyInit will be called in func:main +func lazyInit() { // watch rotation and send to rotatinPublisher go _watchRotation() if !isMinicapSupported() { minicapSocketPath = "@minicapagent" } + if !fileExists("/data/local/tmp/minitouch") { minitouchSocketPath = "@minitouchagent" } else if sdk, _ := strconv.Atoi(getCachedProperty("ro.build.version.sdk")); sdk > 28 { // Android Q.. @@ -566,15 +568,6 @@ func main() { } } - // if *fRequirements { - // log.Println("check dependencies") - // if err := installRequirements(); err != nil { - // // panic(err) - // log.Println("requirements not ready:", err) - // return - // } - // } - serverURL := *fServerURL if serverURL != "" { if !regexp.MustCompile(`https?://`).MatchString(serverURL) { @@ -606,6 +599,7 @@ func main() { } fmt.Printf("atx-agent version %s\n", version) + lazyInit() // show ip outIp, err := getOutboundIP()