-(global): fixing the installation flow on windows
There could be a bug caused by the lack of SO_REUSEPORT
This commit is contained in:
parent
c5537968b1
commit
abbf8fb87b
|
@ -7,6 +7,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/AdguardTeam/golibs/log"
|
"github.com/AdguardTeam/golibs/log"
|
||||||
|
@ -117,6 +118,10 @@ func handleInstallCheckConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// Check if DNSStubListener is active
|
// Check if DNSStubListener is active
|
||||||
func checkDNSStubListener() bool {
|
func checkDNSStubListener() bool {
|
||||||
|
if runtime.GOOS != "linux" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
cmd := exec.Command("systemctl", "is-enabled", "systemd-resolved")
|
cmd := exec.Command("systemctl", "is-enabled", "systemd-resolved")
|
||||||
log.Tracef("executing %s %v", cmd.Path, cmd.Args)
|
log.Tracef("executing %s %v", cmd.Path, cmd.Args)
|
||||||
_, err := cmd.Output()
|
_, err := cmd.Output()
|
||||||
|
|
|
@ -242,6 +242,10 @@ func checkPortAvailable(host string, port int) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
ln.Close()
|
ln.Close()
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,6 +255,10 @@ func checkPacketPortAvailable(host string, port int) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
ln.Close()
|
ln.Close()
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/AdguardTeam/AdGuardHome/isdelve"
|
||||||
|
|
||||||
"github.com/AdguardTeam/AdGuardHome/dhcpd"
|
"github.com/AdguardTeam/AdGuardHome/dhcpd"
|
||||||
"github.com/AdguardTeam/AdGuardHome/dnsfilter"
|
"github.com/AdguardTeam/AdGuardHome/dnsfilter"
|
||||||
"github.com/AdguardTeam/AdGuardHome/dnsforward"
|
"github.com/AdguardTeam/AdGuardHome/dnsforward"
|
||||||
|
@ -284,7 +286,8 @@ func httpServerLoop() {
|
||||||
// and if not, ask and try to run as root
|
// and if not, ask and try to run as root
|
||||||
func requireAdminRights() {
|
func requireAdminRights() {
|
||||||
admin, _ := haveAdminRights()
|
admin, _ := haveAdminRights()
|
||||||
if admin {
|
if //noinspection ALL
|
||||||
|
admin || isdelve.Enabled {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
// +build delve
|
||||||
|
|
||||||
|
package isdelve
|
||||||
|
|
||||||
|
const Enabled = true
|
|
@ -0,0 +1,3 @@
|
||||||
|
// Package isdelve is for checking if we're debugging:
|
||||||
|
// https://stackoverflow.com/questions/47879070/how-can-i-see-if-the-goland-debugger-is-running-in-the-program
|
||||||
|
package isdelve
|
|
@ -0,0 +1,5 @@
|
||||||
|
// +build !delve
|
||||||
|
|
||||||
|
package isdelve
|
||||||
|
|
||||||
|
const Enabled = false
|
Loading…
Reference in New Issue