aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-09-03 10:54:05 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2019-09-03 10:54:05 -0600
commitd7eabfff063e286b5545226668e18857da00442f (patch)
tree6aba164269a36a6b83e43ba72b56cded79e79515
parentbuild: bump mingw toolchains (diff)
downloadwireguard-windows-d7eabfff063e286b5545226668e18857da00442f.tar.xz
wireguard-windows-d7eabfff063e286b5545226668e18857da00442f.zip
winipcfg: [BEGINNINGS] import undocumented iphlpapi functionjd/undocumented-dns-setter
-rw-r--r--tunnel/winipcfg/types.go25
-rw-r--r--tunnel/winipcfg/winipcfg.go3
-rw-r--r--tunnel/winipcfg/zwinipcfg_windows.go9
3 files changed, 37 insertions, 0 deletions
diff --git a/tunnel/winipcfg/types.go b/tunnel/winipcfg/types.go
index 684a6c77..b7c49029 100644
--- a/tunnel/winipcfg/types.go
+++ b/tunnel/winipcfg/types.go
@@ -950,3 +950,28 @@ func (tab *mibIPforwardTable2) get() []MibIPforwardRow2 {
func (tab *mibIPforwardTable2) free() {
freeMibTable(unsafe.Pointer(tab))
}
+
+type DnsInterfaceSettings struct {
+ Version uint32
+ Flags uint64
+ Domain *uint16
+ NameServer *uint16
+ SearchList *uint16
+ RegistrationEnabled uint32
+ RegisterAdapterName uint32
+ EnableLLMNR uint32
+ QueryAdapterName uint32
+ ProfileNameServer *uint16
+}
+
+const (
+ DisVersion = 1
+
+ DisFlagsHaveNameServer = 2 << iota
+ DisFlagsHaveSearchList
+ DisFlagsHaveRegistrationEnabled
+ DisFlagsHaveDomain
+ DisFlagsHaveEnableLLMNR
+ DisFlagsHaveQueryAdapterName
+ DisFlagsHaveProfileNameServer
+) \ No newline at end of file
diff --git a/tunnel/winipcfg/winipcfg.go b/tunnel/winipcfg/winipcfg.go
index 2fc0c875..90a96bb5 100644
--- a/tunnel/winipcfg/winipcfg.go
+++ b/tunnel/winipcfg/winipcfg.go
@@ -166,3 +166,6 @@ func GetIPForwardTable2(family AddressFamily) ([]MibIPforwardRow2, error) {
// https://docs.microsoft.com/en-us/windows/desktop/api/netioapi/nf-netioapi-cancelmibchangenotify2
//sys cancelMibChangeNotify2(notificationHandle windows.Handle) (ret error) = iphlpapi.CancelMibChangeNotify2
+
+// Undocumented
+//sys setInterfaceDnsSettings(guid *windows.GUID, settings *DnsInterfaceSettings) (ret error) = iphlpapi.SetInterfaceDnsSettings \ No newline at end of file
diff --git a/tunnel/winipcfg/zwinipcfg_windows.go b/tunnel/winipcfg/zwinipcfg_windows.go
index 8f37ac26..cc4c3f70 100644
--- a/tunnel/winipcfg/zwinipcfg_windows.go
+++ b/tunnel/winipcfg/zwinipcfg_windows.go
@@ -68,6 +68,7 @@ var (
procNotifyUnicastIpAddressChange = modiphlpapi.NewProc("NotifyUnicastIpAddressChange")
procNotifyRouteChange2 = modiphlpapi.NewProc("NotifyRouteChange2")
procCancelMibChangeNotify2 = modiphlpapi.NewProc("CancelMibChangeNotify2")
+ procSetInterfaceDnsSettings = modiphlpapi.NewProc("SetInterfaceDnsSettings")
)
func freeMibTable(memory unsafe.Pointer) {
@@ -307,3 +308,11 @@ func cancelMibChangeNotify2(notificationHandle windows.Handle) (ret error) {
}
return
}
+
+func setInterfaceDnsSettings(guid *windows.GUID, settings *DnsInterfaceSettings) (ret error) {
+ r0, _, _ := syscall.Syscall(procSetInterfaceDnsSettings.Addr(), 2, uintptr(unsafe.Pointer(guid)), uintptr(unsafe.Pointer(settings)), 0)
+ if r0 != 0 {
+ ret = syscall.Errno(r0)
+ }
+ return
+}