aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-08-22 10:38:50 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-08-22 10:38:50 +0200
commit162ddfbe6468e095d7f38e68800270f7dc8a49e1 (patch)
tree961d73d8ae61c645372e3483cda439f75e4c7c6a
parentwintun: try multiple names until one isn't a duplicate (diff)
downloadwireguard-go-jd/regkeytoo.tar.xz
wireguard-go-jd/regkeytoo.zip
wintun: write registry key with original name if adding duplicatejd/regkeytoo
-rw-r--r--tun/wintun/wintun_windows.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go
index 1caa4a1..b1a3f8d 100644
--- a/tun/wintun/wintun_windows.go
+++ b/tun/wintun/wintun_windows.go
@@ -535,6 +535,19 @@ func (wintun *Wintun) SetInterfaceName(ifname string) error {
availableIfname = fmt.Sprintf("%s %d", ifname, i+1)
}
+ if availableIfname != ifname {
+ // TODO: This is a pretty bad workaround, and we really should start interacting directly with NetSetup2
+ netRegKey, err := registry.OpenKey(registry.LOCAL_MACHINE, wintun.netRegKeyName(), registry.SET_VALUE)
+ if err != nil {
+ return fmt.Errorf("Network-specific registry key open failed: %v", err)
+ }
+ defer netRegKey.Close()
+ err = netRegKey.SetStringValue("Name", ifname)
+ if err != nil {
+ return fmt.Errorf("SetStringValue(NetRegKey, Name) failed: %v", err)
+ }
+ }
+
// TODO: This should use NetSetup2 so that it doesn't get unset.
deviceRegKey, err := registry.OpenKey(registry.LOCAL_MACHINE, wintun.deviceRegKeyName(), registry.SET_VALUE)
if err != nil {
@@ -558,6 +571,11 @@ func (wintun *Wintun) deviceRegKeyName() string {
return fmt.Sprintf("SYSTEM\\CurrentControlSet\\Enum\\%v", wintun.devInstanceID)
}
+// netRegKeyName returns the interface-specific network registry key name.
+func (wintun *Wintun) netRegKeyName() string {
+ return fmt.Sprintf("SYSTEM\\CurrentControlSet\\Control\\Network\\%v\\%v\\Connection", deviceClassNetGUID, wintun.cfgInstanceID)
+}
+
// tcpipInterfaceRegKeyName returns the interface-specific TCP/IP network registry key name.
func (wintun *Wintun) tcpipInterfaceRegKeyName() (path string, err error) {
key, err := registry.OpenKey(registry.LOCAL_MACHINE, wintun.tcpipAdapterRegKeyName(), registry.QUERY_VALUE)