From 71de2d376c8244531110deb683ac182cb9971383 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Tue, 11 Apr 2023 11:10:48 +0200 Subject: [PATCH] Make no ipv4-addr on iface warn instead of error --- cmd/app/main.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/cmd/app/main.go b/cmd/app/main.go index 1482fdd..aaa9e08 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -59,23 +59,23 @@ func main() { logger.Error.Fatal(err) } if(len(addrs) == 0){ - logger.Error.Fatal("Interface doesnt have IPv4-Adresses") - } - - // Add the IPv6 address to the interface - ipv6Str := *convertIPv4ToIPv6(&ipv6Format, addrs[0].IPNet) - ipv6, err := netlink.ParseAddr(ipv6Str) - if err != nil { - logger.Error.Fatal(err) - } - logger.Info.Printf("Adding converted %s -> %s to interface", addrs[0].IPNet.String(), ipv6Str) - err = netlink.AddrAdd(netInterface, ipv6) - if err != nil { - switch { - case os.IsExist(err): - logger.Warn.Println("Address is already set on interface") - default: - logger.Error.Fatalf("Failed to set address on interface: %v", err) + logger.Warn.Println("Interface doesnt have IPv4-Adresses") + } else { + // Add the IPv6 address to the interface + ipv6Str := *convertIPv4ToIPv6(&ipv6Format, addrs[0].IPNet) + ipv6, err := netlink.ParseAddr(ipv6Str) + if err != nil { + logger.Error.Fatal(err) + } + logger.Info.Printf("Adding converted %s -> %s to interface", addrs[0].IPNet.String(), ipv6Str) + err = netlink.AddrAdd(netInterface, ipv6) + if err != nil { + switch { + case os.IsExist(err): + logger.Warn.Println("Address is already set on interface") + default: + logger.Error.Fatalf("Failed to set address on interface: %v", err) + } } }