hide non-up interfaces
This commit is contained in:
2
.vscode/tasks.json
vendored
2
.vscode/tasks.json
vendored
@@ -40,7 +40,7 @@
|
|||||||
"id": "appVersion",
|
"id": "appVersion",
|
||||||
"type": "promptString",
|
"type": "promptString",
|
||||||
"description": "Application Version (X.Y.Z)",
|
"description": "Application Version (X.Y.Z)",
|
||||||
"default": "1.0.0"
|
"default": "1.1.0"
|
||||||
// type specific configuration attributes
|
// type specific configuration attributes
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ func GetIPAddress() []string {
|
|||||||
// get the interface name
|
// get the interface name
|
||||||
interfaceName := netInterface.Name
|
interfaceName := netInterface.Name
|
||||||
|
|
||||||
|
flags := netInterface.Flags.String()
|
||||||
|
|
||||||
// get the interface adapter
|
// get the interface adapter
|
||||||
|
|
||||||
address, _ := netInterface.Addrs()
|
address, _ := netInterface.Addrs()
|
||||||
@@ -31,6 +33,8 @@ func GetIPAddress() []string {
|
|||||||
for _, addr := range address {
|
for _, addr := range address {
|
||||||
if ipnet, ok := addr.(*net.IPNet); ok &&
|
if ipnet, ok := addr.(*net.IPNet); ok &&
|
||||||
!ipnet.IP.IsLoopback() &&
|
!ipnet.IP.IsLoopback() &&
|
||||||
|
// check if up flag is set
|
||||||
|
strings.Contains(flags, "up") &&
|
||||||
!strings.Contains(ipnet.IP.String(), "169.254") &&
|
!strings.Contains(ipnet.IP.String(), "169.254") &&
|
||||||
!strings.Contains(interfaceName, "VirtualBox") &&
|
!strings.Contains(interfaceName, "VirtualBox") &&
|
||||||
!strings.Contains(interfaceName, "Virtual") {
|
!strings.Contains(interfaceName, "Virtual") {
|
||||||
|
|||||||
Reference in New Issue
Block a user