mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-28 09:58:52 +03:00
201ef10de6
Merge in DNS/adguard-home from 3987-fix-nil-deref to master Updates #3987. Updates #2846. Squashed commit of the following: commit d653e09ce88a8b10b2a17fea1563c419895c714c Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Dec 23 20:08:51 2021 +0300 all: log changes commit c47a4eeacf76fa7df2d01af166dee9d52528ac58 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Dec 23 19:22:39 2021 +0300 aghnet: fix windows tests commit 9c91f14ccfe967ada3c00ddb86d673238e52c12d Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Dec 23 19:09:49 2021 +0300 aghnet: imp code readability, docs commit d3df15d1892e4ebfe7f8ea7144e39a0c712fce52 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Dec 23 18:47:28 2021 +0300 aghnet: fix nil pointer dereference
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
//go:build !(linux || darwin || freebsd || openbsd)
|
|
// +build !linux,!darwin,!freebsd,!openbsd
|
|
|
|
package aghnet
|
|
|
|
import (
|
|
"io"
|
|
"syscall"
|
|
"time"
|
|
|
|
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
|
|
"github.com/AdguardTeam/golibs/errors"
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
func canBindPrivilegedPorts() (can bool, err error) {
|
|
return aghos.HaveAdminRights()
|
|
}
|
|
|
|
func ifaceHasStaticIP(string) (ok bool, err error) {
|
|
return false, aghos.Unsupported("checking static ip")
|
|
}
|
|
|
|
func ifaceSetStaticIP(string) (err error) {
|
|
return aghos.Unsupported("setting static ip")
|
|
}
|
|
|
|
// closePortChecker closes c. c must be non-nil.
|
|
func closePortChecker(c io.Closer) (err error) {
|
|
if err = c.Close(); err != nil {
|
|
return err
|
|
}
|
|
|
|
// It seems that net.Listener.Close() doesn't close file descriptors right
|
|
// away. We wait for some time and hope that this fd will be closed.
|
|
//
|
|
// TODO(e.burkov): Investigate the purpose of the line and perhaps use more
|
|
// reliable approach.
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
return nil
|
|
}
|
|
|
|
func isAddrInUse(err syscall.Errno) (ok bool) {
|
|
return errors.Is(err, windows.WSAEADDRINUSE)
|
|
}
|