init
Some checks failed
Build and Release / release (push) Failing after 26s

This commit is contained in:
2025-12-12 17:37:34 +07:00
commit 9d769ed08c
32 changed files with 895 additions and 0 deletions

43
system_proxy_windows.go Normal file
View File

@@ -0,0 +1,43 @@
//go:build windows
// +build windows
package main
import (
"fmt"
"syscall"
"golang.org/x/sys/windows/registry"
)
func setProxy(enable bool, host string, port string) error {
k, _, err := registry.CreateKey(
registry.CURRENT_USER,
`Software\Microsoft\Windows\CurrentVersion\Internet Settings`,
registry.SET_VALUE,
)
if err != nil {
return err
}
if enable {
k.SetDWordValue("ProxyEnable", 1)
addr := fmt.Sprintf("%s:%s", host, port)
val := fmt.Sprintf("http=%s;https=%s", addr, addr)
k.SetStringValue("ProxyServer", val)
} else {
k.SetDWordValue("ProxyEnable", 0)
}
k.Close()
d := syscall.NewLazyDLL("wininet.dll")
o := d.NewProc("InternetSetOptionW")
o.Call(0, 39, 0, 0)
o.Call(0, 37, 0, 0)
return nil
}