Move IP-conversion into loop

dev
Ruakij 2 years ago
parent 631b1bf12e
commit ba6342a71f

@ -53,6 +53,15 @@ func main() {
logger.Error.Fatalf("Couldn't parse RECHECK_INTERVAL '%s': %s", checkIntervalStr, err)
}
// Create a WireGuard client
client, err := wgctrl.New()
if err != nil {
logger.Error.Fatal(err)
}
defer client.Close()
// Loop indefinitely
for {
// Get the IPv4 addresses of the interface
addrs, err := netlink.AddrList(netInterface, netlink.FAMILY_V4)
if err != nil {
@ -87,19 +96,11 @@ func main() {
}
processedCount++
}
if(processedCount != len(addrs)) {
if processedCount != len(addrs) {
logger.Warn.Printf("Not all Interface-Addresses were processed. Summary: %d processed, %d filtered, %d failed", processedCount, filteredCount, len(addrs)-processedCount-filteredCount)
}
// Create a WireGuard client
client, err := wgctrl.New()
if err != nil {
logger.Error.Fatal(err)
}
defer client.Close()
// Loop indefinitely
for {
// Get the WireGuard peers on the interface
wgDevice, err := client.Device(iface)
if err != nil {

Loading…
Cancel
Save