Add windnsapi

This commit is contained in:
世界 2022-09-29 08:02:16 +08:00
parent 7209937cc2
commit 9a83e35b71
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 24 additions and 3 deletions

View file

@ -0,0 +1,21 @@
package windnsapi
import (
"os"
"syscall"
"golang.org/x/sys/windows"
)
var (
moddnsapi = windows.NewLazySystemDLL("dnsapi.dll")
procDnsFlushResolverCache = moddnsapi.NewProc("DnsFlushResolverCache")
)
func FlushResolverCache() error {
r0, _, err := syscall.SyscallN(procDnsFlushResolverCache.Addr())
if r0 == 0 {
return os.NewSyscallError("DnsFlushResolverCache", err)
}
return nil
}

2
go.mod
View file

@ -2,4 +2,4 @@ module github.com/sagernet/sing
go 1.18
require golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8
require golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec

4
go.sum
View file

@ -1,2 +1,2 @@
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 h1:h+EGohizhe9XlX18rfpa8k8RAc5XyaeamM+0VHRd4lc=
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI=
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=