From d9008ac35cc9eff988680895a81445ad6b049d65 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 26 Aug 2019 14:46:43 -0600 Subject: wintun: match suffix numbers --- tun/wintun/wintun_windows.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tun') diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go index c1f5025..81da251 100644 --- a/tun/wintun/wintun_windows.go +++ b/tun/wintun/wintun_windows.go @@ -121,8 +121,15 @@ func GetInterface(ifname string) (*Wintun, error) { if err != nil { continue } + ifname2 = strings.ToLower(ifname2) + ifname3 := strings.TrimRight(ifname2, "0123456789") + if ifname3 != ifname2 && len(ifname3) > 1 && ifname3[len(ifname3)-1] == ' ' { + ifname3 = ifname3[:len(ifname3)-1] + } else { + ifname3 = "" + } - if ifname == strings.ToLower(ifname2) { + if ifname == ifname2 || (len(ifname3) > 0 && ifname == ifname3) { err = devInfoList.BuildDriverInfoList(deviceData, setupapi.SPDIT_COMPATDRIVER) if err != nil { return nil, fmt.Errorf("SetupDiBuildDriverInfoList failed: %v", err) -- cgit v1.2.3