wintun: make description consistent across fields

This commit is contained in:
Jason A. Donenfeld 2019-08-24 12:29:17 +02:00
parent 3cedc22d7b
commit 0c540ad60e
2 changed files with 10 additions and 13 deletions

View file

@ -108,7 +108,7 @@ func CreateTUNWithRequestedGUID(ifname string, requestedGUID *windows.GUID) (Dev
} else if err == windows.ERROR_ALREADY_EXISTS { } else if err == windows.ERROR_ALREADY_EXISTS {
return nil, fmt.Errorf("Foreign network interface with the same name exists") return nil, fmt.Errorf("Foreign network interface with the same name exists")
} }
wt, _, err = wintun.CreateInterface("WireGuard Tunnel Adapter", requestedGUID) wt, _, err = wintun.CreateInterface(requestedGUID)
if err != nil { if err != nil {
return nil, fmt.Errorf("Unable to create Wintun interface: %v", err) return nil, fmt.Errorf("Unable to create Wintun interface: %v", err)
} }

View file

@ -157,17 +157,14 @@ func GetInterface(ifname string) (*Wintun, error) {
return nil, windows.ERROR_OBJECT_NOT_FOUND return nil, windows.ERROR_OBJECT_NOT_FOUND
} }
// CreateInterface creates a Wintun interface. description is a string that // CreateInterface creates a Wintun interface. requestedGUID is the GUID of the
// supplies the text description of the device. The description is optional // created network interface, which then influences NLA generation
// and can be "". requestedGUID is the GUID of the created network interface, // deterministically. If it is set to nil, the GUID is chosen by the system at
// which then influences NLA generation deterministically. If it is set to nil, // random, and hence a new NLA entry is created for each new interface. It is
// the GUID is chosen by the system at random, and hence a new NLA entry is // called "requested" GUID because the API it uses is completely undocumented,
// created for each new interface. It is called "requested" GUID because the // and so there could be minor interesting complications with its usage. This
// API it uses is completely undocumented, and so there could be minor // function returns the network interface ID and a flag if reboot is required.
// interesting complications with its usage. This function returns the network func CreateInterface(requestedGUID *windows.GUID) (wintun *Wintun, rebootRequired bool, err error) {
// interface ID and a flag if reboot is required.
//
func CreateInterface(description string, requestedGUID *windows.GUID) (wintun *Wintun, rebootRequired bool, err error) {
// Create an empty device info set for network adapter device class. // Create an empty device info set for network adapter device class.
devInfoList, err := setupapi.SetupDiCreateDeviceInfoListEx(&deviceClassNetGUID, 0, "") devInfoList, err := setupapi.SetupDiCreateDeviceInfoListEx(&deviceClassNetGUID, 0, "")
if err != nil { if err != nil {
@ -184,7 +181,7 @@ func CreateInterface(description string, requestedGUID *windows.GUID) (wintun *W
} }
// Create a new device info element and add it to the device info set. // Create a new device info element and add it to the device info set.
deviceData, err := devInfoList.CreateDeviceInfo(className, &deviceClassNetGUID, description, 0, setupapi.DICD_GENERATE_ID) deviceData, err := devInfoList.CreateDeviceInfo(className, &deviceClassNetGUID, deviceTypeName, 0, setupapi.DICD_GENERATE_ID)
if err != nil { if err != nil {
err = fmt.Errorf("SetupDiCreateDeviceInfo failed: %v", err) err = fmt.Errorf("SetupDiCreateDeviceInfo failed: %v", err)
return return