mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-16 11:52:58 +03:00
6a8f6357e2
Updates #2829. Squashed commit of the following: commit a284a26ba5df101c78e6f866d1bdfa540d205666 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 8 20:34:20 2021 +0300 aghos: fix darwin commit 9dbd42d75ebb048c83dbd06a1f09d950b3d12181 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 8 20:11:56 2021 +0300 all: mv IsOpenWrt
47 lines
838 B
Go
47 lines
838 B
Go
// +build windows
|
|
|
|
package aghos
|
|
|
|
import (
|
|
"fmt"
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
func canBindPrivilegedPorts() (can bool, err error) {
|
|
return HaveAdminRights()
|
|
}
|
|
|
|
func setRlimit(val uint) {
|
|
}
|
|
|
|
func haveAdminRights() (bool, error) {
|
|
var token windows.Token
|
|
h := windows.CurrentProcess()
|
|
err := windows.OpenProcessToken(h, windows.TOKEN_QUERY, &token)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
info := make([]byte, 4)
|
|
var returnedLen uint32
|
|
err = windows.GetTokenInformation(token, windows.TokenElevation, &info[0], uint32(len(info)), &returnedLen)
|
|
token.Close()
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
if info[0] == 0 {
|
|
return false, nil
|
|
}
|
|
return true, nil
|
|
}
|
|
|
|
func sendProcessSignal(pid int, sig syscall.Signal) error {
|
|
return fmt.Errorf("not supported on Windows")
|
|
}
|
|
|
|
func isOpenWrt() (ok bool) {
|
|
return false
|
|
}
|