all: sync with master
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/dhcpd"
|
||||
"github.com/AdguardTeam/golibs/testutil"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -203,9 +203,9 @@ var config = &configuration{
|
||||
Port: defaultPortDNS,
|
||||
StatsInterval: 1,
|
||||
FilteringConfig: dnsforward.FilteringConfig{
|
||||
ProtectionEnabled: true, // whether or not use any of filtering features
|
||||
BlockingMode: "default", // mode how to answer filtered requests
|
||||
BlockedResponseTTL: 10, // in seconds
|
||||
ProtectionEnabled: true, // whether or not use any of filtering features
|
||||
BlockingMode: dnsforward.BlockingModeDefault,
|
||||
BlockedResponseTTL: 10, // in seconds
|
||||
Ratelimit: 20,
|
||||
RefuseAny: true,
|
||||
AllServers: false,
|
||||
|
||||
@@ -281,10 +281,10 @@ func newDNSCrypt(hosts []net.IP, tlsConf tlsConfigSettings) (dnscc dnsforward.DN
|
||||
}
|
||||
|
||||
return dnsforward.DNSCryptConfig{
|
||||
UDPListenAddrs: ipsToUDPAddrs(hosts, tlsConf.PortDNSCrypt),
|
||||
TCPListenAddrs: ipsToTCPAddrs(hosts, tlsConf.PortDNSCrypt),
|
||||
ResolverCert: cert,
|
||||
ProviderName: rc.ProviderName,
|
||||
UDPListenAddrs: ipsToUDPAddrs(hosts, tlsConf.PortDNSCrypt),
|
||||
TCPListenAddrs: ipsToTCPAddrs(hosts, tlsConf.PortDNSCrypt),
|
||||
Enabled: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -267,7 +267,8 @@ func (f *Filtering) periodicallyRefreshFilters() {
|
||||
// Refresh filters
|
||||
// flags: filterRefresh*
|
||||
// important:
|
||||
// TRUE: ignore the fact that we're currently updating the filters
|
||||
//
|
||||
// TRUE: ignore the fact that we're currently updating the filters
|
||||
func (f *Filtering) refreshFilters(flags int, important bool) (int, error) {
|
||||
set := atomic.CompareAndSwapUint32(&f.refreshStatus, 0, 1)
|
||||
if !important && !set {
|
||||
@@ -363,25 +364,24 @@ const (
|
||||
filterRefreshBlocklists = 4 // update block-lists
|
||||
)
|
||||
|
||||
// Checks filters updates if necessary
|
||||
// If force is true, it ignores the filter.LastUpdated field value
|
||||
// flags: filterRefresh*
|
||||
// refreshFiltersIfNecessary checks filters and updates them if necessary. If
|
||||
// force is true, it ignores the filter.LastUpdated field value.
|
||||
//
|
||||
// Algorithm:
|
||||
// . Get the list of filters to be updated
|
||||
// . For each filter run the download and checksum check operation
|
||||
// . Store downloaded data in a temporary file inside data/filters directory
|
||||
// . For each filter:
|
||||
// . If filter data hasn't changed, just set new update time on file
|
||||
// . If filter data has changed:
|
||||
// . rename the temporary file (<temp> -> 1.txt)
|
||||
// Note that this method works only on UNIX.
|
||||
// On Windows we don't pass files to filtering - we pass the whole data.
|
||||
// . Pass new filters to filtering object - it analyzes new data while the old filters are still active
|
||||
// . filtering activates new filters
|
||||
//
|
||||
// Return the number of updated filters
|
||||
// Return TRUE - there was a network error and nothing could be updated
|
||||
// 1. Get the list of filters to be updated. For each filter, run the download
|
||||
// and checksum check operation. Store downloaded data in a temporary file
|
||||
// inside data/filters directory
|
||||
//
|
||||
// 2. For each filter, if filter data hasn't changed, just set new update time
|
||||
// on file. Otherwise, rename the temporary file (<temp> -> 1.txt). Note
|
||||
// that this method works only on Unix systems. On Windows, don't pass
|
||||
// files to filtering, pass the whole data.
|
||||
//
|
||||
// refreshFiltersIfNecessary returns the number of updated filters. It also
|
||||
// returns true if there was a network error and nothing could be updated.
|
||||
//
|
||||
// TODO(a.garipov, e.burkov): What the hell?
|
||||
func (f *Filtering) refreshFiltersIfNecessary(flags int) (int, bool) {
|
||||
log.Debug("Filters: updating...")
|
||||
|
||||
|
||||
@@ -741,11 +741,10 @@ func loadOptions() options {
|
||||
|
||||
// printWebAddrs prints addresses built from proto, addr, and an appropriate
|
||||
// port. At least one address is printed with the value of port. If the value
|
||||
// of betaPort is 0, the second address is not printed. The output example:
|
||||
//
|
||||
// Go to http://127.0.0.1:80
|
||||
// Go to http://127.0.0.1:3000 (BETA)
|
||||
// of betaPort is 0, the second address is not printed. Output example:
|
||||
//
|
||||
// Go to http://127.0.0.1:80
|
||||
// Go to http://127.0.0.1:3000 (BETA)
|
||||
func printWebAddrs(proto, addr string, port, betaPort int) {
|
||||
const (
|
||||
hostMsg = "Go to %s://%s"
|
||||
|
||||
@@ -159,15 +159,16 @@ func sendSigReload() {
|
||||
}
|
||||
|
||||
// handleServiceControlAction one of the possible control actions:
|
||||
// install -- installs a service/daemon
|
||||
// uninstall -- uninstalls it
|
||||
// status -- prints the service status
|
||||
// start -- starts the previously installed service
|
||||
// stop -- stops the previously installed service
|
||||
// restart - restarts the previously installed service
|
||||
// run - this is a special command that is not supposed to be used directly
|
||||
// it is specified when we register a service, and it indicates to the app
|
||||
// that it is being run as a service/daemon.
|
||||
//
|
||||
// - install: Installs a service/daemon.
|
||||
// - uninstall: Uninstalls it.
|
||||
// - status: Prints the service status.
|
||||
// - start: Starts the previously installed service.
|
||||
// - stop: Stops the previously installed service.
|
||||
// - restart: Restarts the previously installed service.
|
||||
// - run: This is a special command that is not supposed to be used directly
|
||||
// it is specified when we register a service, and it indicates to the app
|
||||
// that it is being run as a service/daemon.
|
||||
func handleServiceControlAction(opts options, clientBuildFS fs.FS) {
|
||||
// Call chooseSystem explicitly to introduce OpenBSD support for service
|
||||
// package. It's a noop for other GOOS values.
|
||||
@@ -397,12 +398,11 @@ var launchdConfig = `<?xml version='1.0' encoding='UTF-8'?>
|
||||
// the systemdScript constant in file service_systemd_linux.go in module
|
||||
// github.com/kardianos/service. The following changes have been made:
|
||||
//
|
||||
// 1. The RestartSec setting is set to a lower value of 10 to make sure we
|
||||
// 1. The RestartSec setting is set to a lower value of 10 to make sure we
|
||||
// always restart quickly.
|
||||
//
|
||||
// 2. The ExecStartPre setting is added to make sure that the log directory is
|
||||
// 2. The ExecStartPre setting is added to make sure that the log directory is
|
||||
// always created to prevent the 209/STDOUT errors.
|
||||
//
|
||||
const systemdScript = `[Unit]
|
||||
Description={{.Description}}
|
||||
ConditionFileIsExecutable={{.Path|cmdEscape}}
|
||||
|
||||
@@ -569,10 +569,9 @@ func validatePkey(data *tlsConfigStatus, pkey string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Process certificate data and its private key.
|
||||
// All parameters are optional.
|
||||
// On error, return partially set object
|
||||
// with 'WarningValidation' field containing error description.
|
||||
// validateCertificates processes certificate data and its private key. All
|
||||
// parameters are optional. On error, validateCertificates returns a partially
|
||||
// set object with field WarningValidation containing error description.
|
||||
func validateCertificates(certChain, pkey, serverName string) tlsConfigStatus {
|
||||
var data tlsConfigStatus
|
||||
|
||||
|
||||
@@ -240,8 +240,9 @@ func upgradeSchema3to4(diskConf yobj) error {
|
||||
|
||||
// Replace "auth_name", "auth_pass" string settings with an array:
|
||||
// users:
|
||||
// - name: "..."
|
||||
// password: "..."
|
||||
// - name: "..."
|
||||
// password: "..."
|
||||
//
|
||||
// ...
|
||||
func upgradeSchema4to5(diskConf yobj) error {
|
||||
log.Printf("%s(): called", funcName())
|
||||
@@ -288,16 +289,18 @@ func upgradeSchema4to5(diskConf yobj) error {
|
||||
|
||||
// clients:
|
||||
// ...
|
||||
// ip: 127.0.0.1
|
||||
// mac: ...
|
||||
//
|
||||
// ip: 127.0.0.1
|
||||
// mac: ...
|
||||
//
|
||||
// ->
|
||||
//
|
||||
// clients:
|
||||
// ...
|
||||
// ids:
|
||||
// - 127.0.0.1
|
||||
// - ...
|
||||
//
|
||||
// ids:
|
||||
// - 127.0.0.1
|
||||
// - ...
|
||||
func upgradeSchema5to6(diskConf yobj) error {
|
||||
log.Printf("%s(): called", funcName())
|
||||
|
||||
@@ -355,19 +358,21 @@ func upgradeSchema5to6(diskConf yobj) error {
|
||||
}
|
||||
|
||||
// dhcp:
|
||||
// enabled: false
|
||||
// interface_name: vboxnet0
|
||||
// gateway_ip: 192.168.56.1
|
||||
// ...
|
||||
//
|
||||
// enabled: false
|
||||
// interface_name: vboxnet0
|
||||
// gateway_ip: 192.168.56.1
|
||||
// ...
|
||||
//
|
||||
// ->
|
||||
//
|
||||
// dhcp:
|
||||
// enabled: false
|
||||
// interface_name: vboxnet0
|
||||
// dhcpv4:
|
||||
// gateway_ip: 192.168.56.1
|
||||
// ...
|
||||
//
|
||||
// enabled: false
|
||||
// interface_name: vboxnet0
|
||||
// dhcpv4:
|
||||
// gateway_ip: 192.168.56.1
|
||||
// ...
|
||||
func upgradeSchema6to7(diskConf yobj) error {
|
||||
log.Printf("Upgrade yaml: 6 to 7")
|
||||
|
||||
@@ -443,15 +448,14 @@ func upgradeSchema6to7(diskConf yobj) error {
|
||||
|
||||
// upgradeSchema7to8 performs the following changes:
|
||||
//
|
||||
// # BEFORE:
|
||||
// 'dns':
|
||||
// 'bind_host': '127.0.0.1'
|
||||
//
|
||||
// # AFTER:
|
||||
// 'dns':
|
||||
// 'bind_hosts':
|
||||
// - '127.0.0.1'
|
||||
// # BEFORE:
|
||||
// 'dns':
|
||||
// 'bind_host': '127.0.0.1'
|
||||
//
|
||||
// # AFTER:
|
||||
// 'dns':
|
||||
// 'bind_hosts':
|
||||
// - '127.0.0.1'
|
||||
func upgradeSchema7to8(diskConf yobj) (err error) {
|
||||
log.Printf("Upgrade yaml: 7 to 8")
|
||||
|
||||
@@ -481,14 +485,13 @@ func upgradeSchema7to8(diskConf yobj) (err error) {
|
||||
|
||||
// upgradeSchema8to9 performs the following changes:
|
||||
//
|
||||
// # BEFORE:
|
||||
// 'dns':
|
||||
// 'autohost_tld': 'lan'
|
||||
//
|
||||
// # AFTER:
|
||||
// 'dns':
|
||||
// 'local_domain_name': 'lan'
|
||||
// # BEFORE:
|
||||
// 'dns':
|
||||
// 'autohost_tld': 'lan'
|
||||
//
|
||||
// # AFTER:
|
||||
// 'dns':
|
||||
// 'local_domain_name': 'lan'
|
||||
func upgradeSchema8to9(diskConf yobj) (err error) {
|
||||
log.Printf("Upgrade yaml: 8 to 9")
|
||||
|
||||
@@ -564,16 +567,15 @@ func addQUICPort(ups string, port int) (withPort string) {
|
||||
|
||||
// upgradeSchema9to10 performs the following changes:
|
||||
//
|
||||
// # BEFORE:
|
||||
// 'dns':
|
||||
// 'upstream_dns':
|
||||
// - 'quic://some-upstream.com'
|
||||
//
|
||||
// # AFTER:
|
||||
// 'dns':
|
||||
// 'upstream_dns':
|
||||
// - 'quic://some-upstream.com:784'
|
||||
// # BEFORE:
|
||||
// 'dns':
|
||||
// 'upstream_dns':
|
||||
// - 'quic://some-upstream.com'
|
||||
//
|
||||
// # AFTER:
|
||||
// 'dns':
|
||||
// 'upstream_dns':
|
||||
// - 'quic://some-upstream.com:784'
|
||||
func upgradeSchema9to10(diskConf yobj) (err error) {
|
||||
log.Printf("Upgrade yaml: 9 to 10")
|
||||
|
||||
@@ -623,15 +625,14 @@ func upgradeSchema9to10(diskConf yobj) (err error) {
|
||||
|
||||
// upgradeSchema10to11 performs the following changes:
|
||||
//
|
||||
// # BEFORE:
|
||||
// 'rlimit_nofile': 42
|
||||
//
|
||||
// # AFTER:
|
||||
// 'os':
|
||||
// 'group': ''
|
||||
// 'rlimit_nofile': 42
|
||||
// 'user': ''
|
||||
// # BEFORE:
|
||||
// 'rlimit_nofile': 42
|
||||
//
|
||||
// # AFTER:
|
||||
// 'os':
|
||||
// 'group': ''
|
||||
// 'rlimit_nofile': 42
|
||||
// 'user': ''
|
||||
func upgradeSchema10to11(diskConf yobj) (err error) {
|
||||
log.Printf("Upgrade yaml: 10 to 11")
|
||||
|
||||
@@ -658,12 +659,11 @@ func upgradeSchema10to11(diskConf yobj) (err error) {
|
||||
|
||||
// upgradeSchema11to12 performs the following changes:
|
||||
//
|
||||
// # BEFORE:
|
||||
// 'querylog_interval': 90
|
||||
//
|
||||
// # AFTER:
|
||||
// 'querylog_interval': '2160h'
|
||||
// # BEFORE:
|
||||
// 'querylog_interval': 90
|
||||
//
|
||||
// # AFTER:
|
||||
// 'querylog_interval': '2160h'
|
||||
func upgradeSchema11to12(diskConf yobj) (err error) {
|
||||
log.Printf("Upgrade yaml: 11 to 12")
|
||||
diskConf["schema_version"] = 12
|
||||
@@ -698,16 +698,15 @@ func upgradeSchema11to12(diskConf yobj) (err error) {
|
||||
|
||||
// upgradeSchema12to13 performs the following changes:
|
||||
//
|
||||
// # BEFORE:
|
||||
// 'dns':
|
||||
// # …
|
||||
// 'local_domain_name': 'lan'
|
||||
//
|
||||
// # AFTER:
|
||||
// 'dhcp':
|
||||
// # …
|
||||
// 'local_domain_name': 'lan'
|
||||
// # BEFORE:
|
||||
// 'dns':
|
||||
// # …
|
||||
// 'local_domain_name': 'lan'
|
||||
//
|
||||
// # AFTER:
|
||||
// 'dhcp':
|
||||
// # …
|
||||
// 'local_domain_name': 'lan'
|
||||
func upgradeSchema12to13(diskConf yobj) (err error) {
|
||||
log.Printf("Upgrade yaml: 12 to 13")
|
||||
diskConf["schema_version"] = 13
|
||||
@@ -744,23 +743,22 @@ func upgradeSchema12to13(diskConf yobj) (err error) {
|
||||
|
||||
// upgradeSchema13to14 performs the following changes:
|
||||
//
|
||||
// # BEFORE:
|
||||
// 'clients':
|
||||
// - 'name': 'client-name'
|
||||
// # …
|
||||
//
|
||||
// # AFTER:
|
||||
// 'clients':
|
||||
// 'persistent':
|
||||
// - 'name': 'client-name'
|
||||
// # …
|
||||
// 'runtime_sources':
|
||||
// 'whois': true
|
||||
// 'arp': true
|
||||
// 'rdns': true
|
||||
// 'dhcp': true
|
||||
// 'hosts': true
|
||||
// # BEFORE:
|
||||
// 'clients':
|
||||
// - 'name': 'client-name'
|
||||
// # …
|
||||
//
|
||||
// # AFTER:
|
||||
// 'clients':
|
||||
// 'persistent':
|
||||
// - 'name': 'client-name'
|
||||
// # …
|
||||
// 'runtime_sources':
|
||||
// 'whois': true
|
||||
// 'arp': true
|
||||
// 'rdns': true
|
||||
// 'dhcp': true
|
||||
// 'hosts': true
|
||||
func upgradeSchema13to14(diskConf yobj) (err error) {
|
||||
log.Printf("Upgrade yaml: 13 to 14")
|
||||
diskConf["schema_version"] = 14
|
||||
|
||||
Reference in New Issue
Block a user