mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-05-02 14:10:29 +03:00
Pull request: create aghnet package
Merge in DNS/adguard-home from mk-aghnet to master
Updates #2829.
Squashed commit of the following:
commit 519806c04b8d0517aacce9c31f2d06ab56631937
Merge: 92376c86 97361234
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Tue Mar 16 19:13:56 2021 +0300
Merge branch 'master' into mk-aghnet
commit 92376c8665e529191aa482432f9d5e3e2e3afdc8
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Tue Mar 16 18:37:22 2021 +0300
aghnet: fix linux
commit 7f36d19b0e650d4e4fc5cf9ea4b501a7f636abeb
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Tue Mar 16 18:08:30 2021 +0300
aghnet: mv network utils from util
commit aa68c70c1146b8c32303c6e037953a41aa7d72f9
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Tue Mar 16 17:30:06 2021 +0300
aghnet: mv ipDetector here
commit b033657f5c5ee91f869c36508a5eb15976a174a0
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Tue Mar 16 17:24:07 2021 +0300
all: mk aghnet package, rename sysutil package
This commit is contained in:
parent
9736123483
commit
3a67cc2c45
26 changed files with 135 additions and 148 deletions
internal/home
|
@ -22,12 +22,13 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/agherr"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/dhcpd"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/dnsfilter"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/dnsforward"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/querylog"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/stats"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/sysutil"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/updater"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/util"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/version"
|
||||
|
@ -60,7 +61,7 @@ type homeContext struct {
|
|||
autoHosts util.AutoHosts // IP-hostname pairs taken from system configuration (e.g. /etc/hosts) files
|
||||
updater *updater.Updater
|
||||
|
||||
ipDetector *ipDetector
|
||||
ipDetector *aghnet.IPDetector
|
||||
|
||||
// mux is our custom http.ServeMux.
|
||||
mux *http.ServeMux
|
||||
|
@ -204,7 +205,7 @@ func setupConfig(args options) {
|
|||
|
||||
if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") &&
|
||||
config.RlimitNoFile != 0 {
|
||||
sysutil.SetRlimit(config.RlimitNoFile)
|
||||
aghos.SetRlimit(config.RlimitNoFile)
|
||||
}
|
||||
|
||||
// override bind host/port from the console
|
||||
|
@ -304,7 +305,7 @@ func run(args options) {
|
|||
log.Fatalf("Can't initialize Web module")
|
||||
}
|
||||
|
||||
Context.ipDetector, err = newIPDetector()
|
||||
Context.ipDetector, err = aghnet.NewIPDetector()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -361,7 +362,7 @@ func checkPermissions() {
|
|||
if runtime.GOOS == "windows" {
|
||||
// On Windows we need to have admin rights to run properly
|
||||
|
||||
admin, _ := sysutil.HaveAdminRights()
|
||||
admin, _ := aghos.HaveAdminRights()
|
||||
if admin {
|
||||
return
|
||||
}
|
||||
|
@ -370,7 +371,7 @@ func checkPermissions() {
|
|||
}
|
||||
|
||||
// We should check if AdGuard Home is able to bind to port 53
|
||||
ok, err := util.CanBindPort(53)
|
||||
ok, err := aghnet.CanBindPort(53)
|
||||
|
||||
if ok {
|
||||
log.Info("AdGuard Home can bind to port 53")
|
||||
|
@ -481,7 +482,7 @@ func configureLogger(args options) {
|
|||
|
||||
if ls.LogFile == configSyslog {
|
||||
// Use syslog where it is possible and eventlog on Windows
|
||||
err := sysutil.ConfigureSyslog(serviceName)
|
||||
err := aghos.ConfigureSyslog(serviceName)
|
||||
if err != nil {
|
||||
log.Fatalf("cannot initialize syslog: %s", err)
|
||||
}
|
||||
|
@ -592,7 +593,7 @@ func printHTTPAddresses(proto string) {
|
|||
}
|
||||
} else if config.BindHost.IsUnspecified() {
|
||||
log.Println("AdGuard Home is available on the following addresses:")
|
||||
ifaces, err := util.GetValidNetInterfacesForWeb()
|
||||
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
|
||||
if err != nil {
|
||||
// That's weird, but we'll ignore it
|
||||
hostStr = config.BindHost.String()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue