wintun: match suffix numbers

This commit is contained in:
Jason A. Donenfeld 2019-08-26 14:46:43 -06:00
parent f8198c0428
commit d9008ac35c

View file

@ -121,8 +121,15 @@ func GetInterface(ifname string) (*Wintun, error) {
if err != nil { if err != nil {
continue 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) err = devInfoList.BuildDriverInfoList(deviceData, setupapi.SPDIT_COMPATDRIVER)
if err != nil { if err != nil {
return nil, fmt.Errorf("SetupDiBuildDriverInfoList failed: %v", err) return nil, fmt.Errorf("SetupDiBuildDriverInfoList failed: %v", err)