From abe3d0dc3356824285ad424a45f3f295da73ee7b Mon Sep 17 00:00:00 2001 From: Ruakij Date: Tue, 11 Apr 2023 10:38:38 +0200 Subject: [PATCH] Change recheck-interval to go-time-format --- README.md | 2 +- cmd/app/main.go | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 530cf9a..69ceda9 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Variable|Description|Default `INTERFACE`* | Wireguard-Interface Name | `IPV6_FORMAT` | Format to use for converting v4 to v6
The CIDR-Mask gets translated using 128 - 24 - Mask
e.g. `10.0.100.5/16` -> `fc12::0a00:6405/96` | `fc12::%02x%02x:%02x%02x/%d` `FILTER_PREFIX` | Prefix to filter for IP-Networks | `100.100` -`RECHECK_INTERVAL` | Interval in seconds to recheck AllowedIPs entries in case something changed | 300 +`RECHECK_INTERVAL` | Interval in go-time-format to recheck AllowedIPs entries in case something changed | 5m *\* Required* diff --git a/cmd/app/main.go b/cmd/app/main.go index 0e94083..1482fdd 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -4,7 +4,6 @@ import ( "fmt" "net" "os" - "strconv" "time" envChecks "git.ruekov.eu/ruakij/routingtabletowg/lib/environmentchecks" @@ -21,7 +20,7 @@ var envRequired = []string{ var envDefaults = map[string]string{ "IPV6_FORMAT": "fc12::%02x%02x:%02x%02x/%d", "FILTER_PREFIX": "100.100", - "RECHECK_INTERVAL": "300", + "RECHECK_INTERVAL": "5m", } func main() { @@ -49,11 +48,10 @@ func main() { filterPrefix := os.Getenv("FILTER_PREFIX") checkIntervalStr := os.Getenv("RECHECK_INTERVAL") - checkIntervalSec, err := strconv.Atoi(checkIntervalStr) + checkInterval, err := time.ParseDuration(checkIntervalStr) if err != nil { - logger.Error.Fatalf("Couldn't read RECHECK_INTERVAL '%s': %s", checkIntervalStr, err) + logger.Error.Fatalf("Couldn't parse RECHECK_INTERVAL '%s': %s", checkIntervalStr, err) } - checkInterval := time.Second * time.Duration(checkIntervalSec) // Get the IPv4 address of the interface addrs, err := netlink.AddrList(netInterface, netlink.FAMILY_V4)