Skip to content
This repository has been archived by the owner on May 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #89 from Regner/fix/listening-windows-tunnel
Browse files Browse the repository at this point in the history
No longer listen to Windows tunnel devices.
  • Loading branch information
regner authored Aug 21, 2017
2 parents 55af87d + 3515afa commit fc66f02
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/net_interface_filter_nix_darw.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package client
import (
"net"

"github.com/regner/albionmarket-client/log"
"github.com/regner/albiondata-client/log"
)

// Gets all physical interfaces based on filter results, ignoring all VM, Loopback and Tunnel interfaces.
Expand Down
20 changes: 18 additions & 2 deletions client/net_interface_filter_win.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package client
import (
"os"
"syscall"
"unicode/utf16"
"unsafe"

"golang.org/x/sys/windows"
Expand All @@ -13,6 +14,7 @@ import (
const (
IfOperStatusUp = 1
IF_TYPE_SOFTWARE_LOOPBACK = 24
IF_TYPE_TUNNEL = 131
)

const hexDigit = "0123456789abcdef"
Expand Down Expand Up @@ -67,6 +69,20 @@ func physicalAddrToString(physAddr [8]byte) string {
return string(buf)
}

func cStringToString(cs *uint16) (s string) {
if cs != nil {
us := make([]uint16, 0, 256)
for p := uintptr(unsafe.Pointer(cs)); ; p += 2 {
u := *(*uint16)(unsafe.Pointer(p))
if u == 0 {
return string(utf16.Decode(us))
}
us = append(us, u)
}
}
return ""
}

// Gets all physical interfaces based on filter results, ignoring all VM, Loopback and Tunnel interfaces.
func getAllPhysicalInterface() []string {
aa, _ := adapterAddresses()
Expand All @@ -76,9 +92,9 @@ func getAllPhysicalInterface() []string {
for _, pa := range aa {
mac := physicalAddrToString(pa.PhysicalAddress)
name := "\\Device\\NPF_" + bytePtrToString(pa.AdapterName)
var flags uint32 = pa.Flags

if flags&uint32(IF_TYPE_SOFTWARE_LOOPBACK) == 0 && flags&uint32(IfOperStatusUp) == 1 && isPhysicalInterface(mac) {
if pa.IfType != uint32(IF_TYPE_SOFTWARE_LOOPBACK) && pa.IfType != uint32(IF_TYPE_TUNNEL) &&
pa.OperStatus == uint32(IfOperStatusUp) && isPhysicalInterface(mac) {
outInterfaces = append(outInterfaces, name)
}
}
Expand Down

0 comments on commit fc66f02

Please sign in to comment.