hide non-up interfaces

This commit is contained in:
2021-11-30 12:52:08 -06:00
parent 4eb1b5565f
commit c37cc30e66
2 changed files with 5 additions and 1 deletions

2
.vscode/tasks.json vendored
View File

@@ -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
}
]

View File

@@ -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") {