diff --git a/analyzer/tcp/socks.go b/analyzer/tcp/socks.go index 18ffc2b..a242069 100644 --- a/analyzer/tcp/socks.go +++ b/analyzer/tcp/socks.go @@ -208,10 +208,10 @@ func (s *socksStream) parseSocks5ReqMethod() utils.LSMAction { switch method { case Socks5AuthNotRequired: s.authReqMethod = Socks5AuthNotRequired - break + return utils.LSMActionNext case Socks5AuthPassword: s.authReqMethod = Socks5AuthPassword - break + return utils.LSMActionNext default: // TODO: more auth method to support } diff --git a/cmd/root.go b/cmd/root.go index aec1650..0c8fa77 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -5,7 +5,6 @@ import ( "fmt" "os" "os/signal" - "strconv" "strings" "syscall" @@ -278,15 +277,15 @@ func runMain(cmd *cobra.Command, args []string) { ctx, cancelFunc := context.WithCancel(context.Background()) go func() { // Graceful shutdown - shutdownChan := make(chan os.Signal) - signal.Notify(shutdownChan, os.Interrupt, os.Kill) + shutdownChan := make(chan os.Signal, 1) + signal.Notify(shutdownChan, os.Interrupt, syscall.SIGTERM) <-shutdownChan logger.Info("shutting down gracefully...") cancelFunc() }() go func() { // Rule reload - reloadChan := make(chan os.Signal) + reloadChan := make(chan os.Signal, 1) signal.Notify(reloadChan, syscall.SIGHUP) for { <-reloadChan @@ -431,11 +430,3 @@ func envOrDefaultString(key, def string) string { } return def } - -func envOrDefaultBool(key string, def bool) bool { - if v := os.Getenv(key); v != "" { - b, _ := strconv.ParseBool(v) - return b - } - return def -} diff --git a/ruleset/builtins/geo/geo_loader.go b/ruleset/builtins/geo/geo_loader.go index de5166a..8e16509 100644 --- a/ruleset/builtins/geo/geo_loader.go +++ b/ruleset/builtins/geo/geo_loader.go @@ -49,7 +49,7 @@ func (l *V2GeoLoader) shouldDownload(filename string) bool { if os.IsNotExist(err) { return true } - dt := time.Now().Sub(info.ModTime()) + dt := time.Since(info.ModTime()) if l.UpdateInterval == 0 { return dt > geoDefaultUpdateInterval } else {