From c37cc30e66fa2e8bcdd921983928df24b186b943 Mon Sep 17 00:00:00 2001 From: Ryan Hamilton Date: Tue, 30 Nov 2021 12:52:08 -0600 Subject: [PATCH] hide non-up interfaces --- .vscode/tasks.json | 2 +- src/utils/utils.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 84c961d..9a44712 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -40,7 +40,7 @@ "id": "appVersion", "type": "promptString", "description": "Application Version (X.Y.Z)", - "default": "1.0.0" + "default": "1.1.0" // type specific configuration attributes } ] diff --git a/src/utils/utils.go b/src/utils/utils.go index 2c773b9..39d2fbe 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -23,6 +23,8 @@ func GetIPAddress() []string { // get the interface name interfaceName := netInterface.Name + flags := netInterface.Flags.String() + // get the interface adapter address, _ := netInterface.Addrs() @@ -31,6 +33,8 @@ func GetIPAddress() []string { for _, addr := range address { if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() && + // check if up flag is set + strings.Contains(flags, "up") && !strings.Contains(ipnet.IP.String(), "169.254") && !strings.Contains(interfaceName, "VirtualBox") && !strings.Contains(interfaceName, "Virtual") {