From 8aae6f9e57aa7f148700b859b7d1b0a02efe4523 Mon Sep 17 00:00:00 2001 From: Josh Harshman Date: Fri, 16 Jun 2023 10:12:04 -0600 Subject: [PATCH] bugfix: Skip synchronization if IPs are up-to-date. --- cmd/update.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/update.go b/cmd/update.go index 2be4038..5247983 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -16,6 +16,7 @@ func Update() *cobra.Command { // Local variable shared between the closures. var local *user.Config + var skipSync bool return &cobra.Command{ Use: "update", @@ -36,6 +37,7 @@ func Update() *cobra.Command { currentIP, _ := user.PublicIP() _, ipExists := cfg.HasIP(currentIP) if ipExists { + skipSync = true return nil } @@ -53,6 +55,10 @@ func Update() *cobra.Command { return cfg.Write(f) }, PostRunE: func(cmd *cobra.Command, args []string) error { + if skipSync { + fmt.Println("IPs are up-to-date, skipping sync.") + return nil + } fmt.Println("syncing firewall rule") return synchronize(local) },