From 7d9538f250b352c5d63486a7ba5c3560d18eece5 Mon Sep 17 00:00:00 2001 From: Matthias Stecher Date: Thu, 16 Feb 2023 07:26:22 +0100 Subject: [PATCH] fix handling if no IP could be detected The current code for no public IP-Address ends with a panic because the error is passed through even it got handled. This commit corrects this. --- util/util.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/util.go b/util/util.go index 40eb357..94c2dc8 100644 --- a/util/util.go +++ b/util/util.go @@ -221,10 +221,12 @@ func GetPublicIP() (model.Interface, error) { ip, err := consensus.ExternalIP() if err != nil { publicInterface.IPAddress = "N/A" + } else { + publicInterface.IPAddress = ip.String() } - publicInterface.IPAddress = ip.String() - return publicInterface, err + // error handling happend above, no need to pass it through + return publicInterface, nil } // GetIPFromCIDR get ip from CIDR