code_before
stringlengths
16
1.81M
edits
stringlengths
4
328k
next_edit
stringlengths
0
76.5k
code_after
stringlengths
3
49.9M
label_window
sequencelengths
4
1.81k
instruction
stringlengths
20
51.9k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
func canBindPrivilegedPorts() (can bool, err error) { return HaveAdminRights() } func setRlimit(val uint) { } func haveAdminRights() (bool, error) { var token windows.Token h := windows.CurrentProcess()
</s> remove func setRlimit(val uint) { </s> add func setRlimit(val uint64) (err error) { </s> remove func setRlimit(val uint) { </s> add func setRlimit(val uint64) (err error) { </s> remove err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) if err != nil { log.Error("Setrlimit() failed: %v", err) } </s> add return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) </s> remove // SetRlimit sets user-specified limit of how many fd's we can use // https://github.com/AdguardTeam/AdGuardHome/internal/issues/659. func SetRlimit(val uint) { setRlimit(val) </s> add // SetRlimit sets user-specified limit of how many fd's we can use. // // See https://github.com/AdguardTeam/AdGuardHome/internal/issues/659. func SetRlimit(val uint64) (err error) { return setRlimit(val) </s> remove "github.com/AdguardTeam/golibs/log" </s> add
func setRlimit(val uint64) (err error) { return ErrUnsupported
func canBindPrivilegedPorts() (can bool, err error) { return HaveAdminRights() } func setRlimit(val uint64) (err error) { return ErrUnsupported } func haveAdminRights() (bool, error) { var token windows.Token h := windows.CurrentProcess()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/aghos/os_windows.go
// attempts after AuthAttempts unsuccessful login attempts. AuthBlockMin uint `yaml:"block_auth_min"` ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client Language string `yaml:"language"` // two-letter ISO 639-1 language code RlimitNoFile uint `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default) DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060 // TTL for a web session (in hours) // An active session is automatically refreshed once a day. WebSessionTTLHours uint32 `yaml:"web_session_ttl"`
</s> remove log.Fatalf("can't initialize dhcp module") </s> add return fmt.Errorf("initing dhcp: %w", err) </s> remove // SetRlimit sets user-specified limit of how many fd's we can use // https://github.com/AdguardTeam/AdGuardHome/internal/issues/659. func SetRlimit(val uint) { setRlimit(val) </s> add // SetRlimit sets user-specified limit of how many fd's we can use. // // See https://github.com/AdguardTeam/AdGuardHome/internal/issues/659. func SetRlimit(val uint64) (err error) { return setRlimit(val)
RlimitNoFile uint64 `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default)
// attempts after AuthAttempts unsuccessful login attempts. AuthBlockMin uint `yaml:"block_auth_min"` ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client Language string `yaml:"language"` // two-letter ISO 639-1 language code RlimitNoFile uint64 `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default) DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060 // TTL for a web session (in hours) // An active session is automatically refreshed once a day. WebSessionTTLHours uint32 `yaml:"web_session_ttl"`
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/config.go
}() if args.serviceControlAction != "" { handleServiceControlAction(args, clientBuildFS) return }
</s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err) </s> remove log.Fatal(serr) </s> add fatalOnError(serr) </s> remove err := os.MkdirAll(Context.getDataDir(), 0o755) </s> add err = os.MkdirAll(Context.getDataDir(), 0o755) </s> remove if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") && config.RlimitNoFile != 0 { aghos.SetRlimit(config.RlimitNoFile) </s> add if config.RlimitNoFile != 0 { err = aghos.SetRlimit(config.RlimitNoFile) if err != nil && !errors.Is(err, aghos.ErrUnsupported) { return fmt.Errorf("setting rlimit: %w", err) } </s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err)
// TODO(a.garipov): github.com/kardianos/service doesn't seem to // support OpenBSD currently. Either patch it to do so or make // our own implementation of the service.System interface. if runtime.GOOS == "openbsd" { log.Fatal("service actions are not supported on openbsd") }
}() if args.serviceControlAction != "" { // TODO(a.garipov): github.com/kardianos/service doesn't seem to // support OpenBSD currently. Either patch it to do so or make // our own implementation of the service.System interface. if runtime.GOOS == "openbsd" { log.Fatal("service actions are not supported on openbsd") } handleServiceControlAction(args, clientBuildFS) return }
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/home.go
Context.mux = http.NewServeMux() } func setupConfig(args options) { config.DHCP.WorkDir = Context.workDir config.DHCP.HTTPRegister = httpRegister config.DHCP.ConfigModified = onConfigModified Context.dhcpServer = dhcpd.Create(config.DHCP)
</s> remove log.Fatal(serr) </s> add fatalOnError(serr) </s> remove rlim.Max = uint64(val) rlim.Cur = uint64(val) err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) if err != nil { log.Error("Setrlimit() failed: %v", err) } </s> add rlim.Max = val rlim.Cur = val return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) </s> remove rlim.Max = uint64(val) rlim.Cur = uint64(val) err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) if err != nil { log.Error("Setrlimit() failed: %v", err) } </s> add rlim.Max = val rlim.Cur = val return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) </s> remove err := config.write() if err != nil { log.Fatal(err) } </s> add err = config.write() fatalOnError(err) </s> remove func setRlimit(val uint) { </s> add func setRlimit(val uint64) (err error) {
func setupConfig(args options) (err error) {
Context.mux = http.NewServeMux() } func setupConfig(args options) (err error) { config.DHCP.WorkDir = Context.workDir config.DHCP.HTTPRegister = httpRegister config.DHCP.ConfigModified = onConfigModified Context.dhcpServer = dhcpd.Create(config.DHCP)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/home.go
// TODO(a.garipov): There are a lot of places in the code right // now which assume that the DHCP server can be nil despite this // condition. Inspect them and perhaps rewrite them to use // Enabled() instead. log.Fatalf("can't initialize dhcp module") } Context.updater = updater.NewUpdater(&updater.Config{ Client: Context.client, Version: version.Version(),
</s> remove // SetRlimit sets user-specified limit of how many fd's we can use // https://github.com/AdguardTeam/AdGuardHome/internal/issues/659. func SetRlimit(val uint) { setRlimit(val) </s> add // SetRlimit sets user-specified limit of how many fd's we can use. // // See https://github.com/AdguardTeam/AdGuardHome/internal/issues/659. func SetRlimit(val uint64) (err error) { return setRlimit(val) </s> remove RlimitNoFile uint `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default) </s> add RlimitNoFile uint64 `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default) </s> remove setupConfig(args) </s> add err = setupConfig(args) fatalOnError(err)
return fmt.Errorf("initing dhcp: %w", err)
// TODO(a.garipov): There are a lot of places in the code right // now which assume that the DHCP server can be nil despite this // condition. Inspect them and perhaps rewrite them to use // Enabled() instead. return fmt.Errorf("initing dhcp: %w", err) } Context.updater = updater.NewUpdater(&updater.Config{ Client: Context.client, Version: version.Version(),
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/home.go
} Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts) config.Clients = nil if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") && config.RlimitNoFile != 0 { aghos.SetRlimit(config.RlimitNoFile) } // override bind host/port from the console if args.bindHost != nil { config.BindHost = args.bindHost
</s> remove func setRlimit(val uint) { </s> add func setRlimit(val uint64) (err error) { </s> remove err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) if err != nil { log.Error("Setrlimit() failed: %v", err) } </s> add return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) </s> remove rlim.Max = uint64(val) rlim.Cur = uint64(val) err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) if err != nil { log.Error("Setrlimit() failed: %v", err) } </s> add rlim.Max = val rlim.Cur = val return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) </s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err) </s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err)
if config.RlimitNoFile != 0 { err = aghos.SetRlimit(config.RlimitNoFile) if err != nil && !errors.Is(err, aghos.ErrUnsupported) { return fmt.Errorf("setting rlimit: %w", err) }
} Context.clients.Init(config.Clients, Context.dhcpServer, Context.etcHosts) config.Clients = nil if config.RlimitNoFile != 0 { err = aghos.SetRlimit(config.RlimitNoFile) if err != nil && !errors.Is(err, aghos.ErrUnsupported) { return fmt.Errorf("setting rlimit: %w", err) } if config.RlimitNoFile != 0 { err = aghos.SetRlimit(config.RlimitNoFile) if err != nil && !errors.Is(err, aghos.ErrUnsupported) { return fmt.Errorf("setting rlimit: %w", err) } if config.RlimitNoFile != 0 { err = aghos.SetRlimit(config.RlimitNoFile) if err != nil && !errors.Is(err, aghos.ErrUnsupported) { return fmt.Errorf("setting rlimit: %w", err) } } // override bind host/port from the console if args.bindHost != nil { config.BindHost = args.bindHost
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/home.go
Context.pidFileName = args.pidFile } } func initWeb(args options, clientBuildFS fs.FS) (web *Web, err error) { var clientFS, clientBetaFS fs.FS if args.localFrontend { log.Info("warning: using local frontend files")
</s> remove func setRlimit(val uint) { </s> add func setRlimit(val uint64) (err error) { </s> remove func setRlimit(val uint) { </s> add func setRlimit(val uint64) (err error) { </s> remove rlim.Max = uint64(val) rlim.Cur = uint64(val) err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) if err != nil { log.Error("Setrlimit() failed: %v", err) } </s> add rlim.Max = val rlim.Cur = val return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim)
return nil
Context.pidFileName = args.pidFile } return nil } func initWeb(args options, clientBuildFS fs.FS) (web *Web, err error) { var clientFS, clientBetaFS fs.FS if args.localFrontend { log.Info("warning: using local frontend files")
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/home.go
return web, nil } // run performs configurating and starts AdGuard Home. func run(args options, clientBuildFS fs.FS) { var err error // configure config filename
</s> remove rlim.Max = uint64(val) rlim.Cur = uint64(val) err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) if err != nil { log.Error("Setrlimit() failed: %v", err) } </s> add rlim.Max = val rlim.Cur = val return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) </s> remove err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) if err != nil { log.Error("Setrlimit() failed: %v", err) } </s> add return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim)
func fatalOnError(err error) { if err != nil { log.Fatal(err) } }
return web, nil } func fatalOnError(err error) { if err != nil { log.Fatal(err) } } // run performs configurating and starts AdGuard Home. func run(args options, clientBuildFS fs.FS) { var err error // configure config filename
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/home.go
// run performs configurating and starts AdGuard Home. func run(args options, clientBuildFS fs.FS) { // configure config filename initConfigFilename(args) // configure working dir and config path initWorkingDir(args)
</s> remove err := config.write() if err != nil { log.Fatal(err) } </s> add err = config.write() fatalOnError(err) </s> remove setupConfig(args) </s> add err = setupConfig(args) fatalOnError(err)
var err error
// run performs configurating and starts AdGuard Home. func run(args options, clientBuildFS fs.FS) { var err error // configure config filename initConfigFilename(args) // configure working dir and config path initWorkingDir(args)
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/home.go
// so we have to initialize filtering's static data first, // but also avoid relying on automatic Go init() function filtering.InitModule() setupConfig(args) if !Context.firstRun { // Save the updated config err := config.write() if err != nil {
</s> remove err := config.write() if err != nil { log.Fatal(err) } </s> add err = config.write() fatalOnError(err) </s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err) </s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err) </s> remove if err != nil { log.Fatalf("%s", err) } </s> add fatalOnError(err)
err = setupConfig(args) fatalOnError(err)
// so we have to initialize filtering's static data first, // but also avoid relying on automatic Go init() function filtering.InitModule() err = setupConfig(args) fatalOnError(err) if !Context.firstRun { // Save the updated config err := config.write() if err != nil {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/home.go
setupConfig(args) if !Context.firstRun { // Save the updated config err := config.write() if err != nil { log.Fatal(err) } if config.DebugPProf { mux := http.NewServeMux() mux.HandleFunc("/debug/pprof/", pprof.Index) mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
</s> remove setupConfig(args) </s> add err = setupConfig(args) fatalOnError(err) </s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err) </s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err) </s> remove if err != nil { log.Fatalf("%s", err) } </s> add fatalOnError(err)
err = config.write() fatalOnError(err)
setupConfig(args) if !Context.firstRun { // Save the updated config err = config.write() fatalOnError(err) err = config.write() fatalOnError(err) err = config.write() fatalOnError(err) err = config.write() fatalOnError(err) if config.DebugPProf { mux := http.NewServeMux() mux.HandleFunc("/debug/pprof/", pprof.Index) mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/home.go
}() } } err := os.MkdirAll(Context.getDataDir(), 0o755) if err != nil { log.Fatalf("Cannot create DNS data dir at %s: %s", Context.getDataDir(), err) } sessFilename := filepath.Join(Context.getDataDir(), "sessions.db")
</s> remove log.Fatal(serr) </s> add fatalOnError(serr) </s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err) </s> remove if err != nil { log.Fatalf("%s", err) } </s> add fatalOnError(err) </s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err) </s> remove err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim) if err != nil { log.Error("Setrlimit() failed: %v", err) } </s> add return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim)
err = os.MkdirAll(Context.getDataDir(), 0o755)
}() } } err = os.MkdirAll(Context.getDataDir(), 0o755) if err != nil { log.Fatalf("Cannot create DNS data dir at %s: %s", Context.getDataDir(), err) } sessFilename := filepath.Join(Context.getDataDir(), "sessions.db")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/home.go
log.Fatalf("Can't initialize TLS module") } Context.web, err = initWeb(args, clientBuildFS) if err != nil { log.Fatal(err) } Context.subnetDetector, err = aghnet.NewSubnetDetector() if err != nil { log.Fatal(err) }
</s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err) </s> remove err := config.write() if err != nil { log.Fatal(err) } </s> add err = config.write() fatalOnError(err) </s> remove if err != nil { log.Fatalf("%s", err) } </s> add fatalOnError(err) </s> remove if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") && config.RlimitNoFile != 0 { aghos.SetRlimit(config.RlimitNoFile) </s> add if config.RlimitNoFile != 0 { err = aghos.SetRlimit(config.RlimitNoFile) if err != nil && !errors.Is(err, aghos.ErrUnsupported) { return fmt.Errorf("setting rlimit: %w", err) }
fatalOnError(err)
log.Fatalf("Can't initialize TLS module") } Context.web, err = initWeb(args, clientBuildFS) fatalOnError(err) fatalOnError(err) fatalOnError(err) Context.subnetDetector, err = aghnet.NewSubnetDetector() if err != nil { log.Fatal(err) }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/home.go
log.Fatal(err) } Context.subnetDetector, err = aghnet.NewSubnetDetector() if err != nil { log.Fatal(err) } if !Context.firstRun { err = initDNSServer() if err != nil { log.Fatalf("%s", err)
</s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err) </s> remove if err != nil { log.Fatalf("%s", err) } </s> add fatalOnError(err) </s> remove err := config.write() if err != nil { log.Fatal(err) } </s> add err = config.write() fatalOnError(err) </s> remove if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") && config.RlimitNoFile != 0 { aghos.SetRlimit(config.RlimitNoFile) </s> add if config.RlimitNoFile != 0 { err = aghos.SetRlimit(config.RlimitNoFile) if err != nil && !errors.Is(err, aghos.ErrUnsupported) { return fmt.Errorf("setting rlimit: %w", err) }
fatalOnError(err)
log.Fatal(err) } Context.subnetDetector, err = aghnet.NewSubnetDetector() fatalOnError(err) fatalOnError(err) fatalOnError(err) if !Context.firstRun { err = initDNSServer() if err != nil { log.Fatalf("%s", err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/home.go
} if !Context.firstRun { err = initDNSServer() if err != nil { log.Fatalf("%s", err) } Context.tls.Start() Context.etcHosts.Start() go func() {
</s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err) </s> remove log.Fatal(serr) </s> add fatalOnError(serr) </s> remove err := config.write() if err != nil { log.Fatal(err) } </s> add err = config.write() fatalOnError(err) </s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err) </s> remove if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") && config.RlimitNoFile != 0 { aghos.SetRlimit(config.RlimitNoFile) </s> add if config.RlimitNoFile != 0 { err = aghos.SetRlimit(config.RlimitNoFile) if err != nil && !errors.Is(err, aghos.ErrUnsupported) { return fmt.Errorf("setting rlimit: %w", err) }
fatalOnError(err)
} if !Context.firstRun { err = initDNSServer() fatalOnError(err) fatalOnError(err) fatalOnError(err) Context.tls.Start() Context.etcHosts.Start() go func() {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/home.go
go func() { serr := startDNSServer() if serr != nil { closeDNSServer() log.Fatal(serr) } }() if Context.dhcpServer != nil { err = Context.dhcpServer.Start()
</s> remove if err != nil { log.Fatalf("%s", err) } </s> add fatalOnError(err) </s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err) </s> remove if err != nil { log.Fatal(err) } </s> add fatalOnError(err) </s> remove err := os.MkdirAll(Context.getDataDir(), 0o755) </s> add err = os.MkdirAll(Context.getDataDir(), 0o755) </s> remove if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") && config.RlimitNoFile != 0 { aghos.SetRlimit(config.RlimitNoFile) </s> add if config.RlimitNoFile != 0 { err = aghos.SetRlimit(config.RlimitNoFile) if err != nil && !errors.Is(err, aghos.ErrUnsupported) { return fmt.Errorf("setting rlimit: %w", err) }
fatalOnError(serr)
go func() { serr := startDNSServer() if serr != nil { closeDNSServer() fatalOnError(serr) } }() if Context.dhcpServer != nil { err = Context.dhcpServer.Start()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: openbsd support Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <[email protected]> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
https://github.com/AdguardTeam/AdGuardHome/commit/3b87478470ff49fbfe850c8f12492265a3c9491b
internal/home/home.go
} address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(config.TLS) if data.WarningValidation != "" { log.Fatal(data.WarningValidation) os.Exit(1) } config.TLS = data // update warnings
</s> remove if data.WarningValidation == "" { </s> add if data.usable {
if !data.usable {
} address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(config.TLS) if !data.usable { log.Fatal(data.WarningValidation) os.Exit(1) } config.TLS = data // update warnings
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
/tls/ -- add internal usable flag to simplify logic when https needs to be booted up
https://github.com/AdguardTeam/AdGuardHome/commit/3c374b594000a47bef40c2d5d20d7ba677c74b31
app.go
ValidKey bool `yaml:"-" json:"valid_key"` KeyType string `yaml:"-" json:"key_type,omitempty"` // warnings Warning string `yaml:"-" json:"warning,omitempty"` WarningValidation string `yaml:"-" json:"warning_validation,omitempty"` }
</s> remove if data.WarningValidation == "" { </s> add if data.usable { </s> remove if data.WarningValidation != "" { </s> add if !data.usable {
// is usable? set by validator usable bool
ValidKey bool `yaml:"-" json:"valid_key"` KeyType string `yaml:"-" json:"key_type,omitempty"` // is usable? set by validator usable bool // warnings Warning string `yaml:"-" json:"warning,omitempty"` WarningValidation string `yaml:"-" json:"warning_validation,omitempty"` }
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
/tls/ -- add internal usable flag to simplify logic when https needs to be booted up
https://github.com/AdguardTeam/AdGuardHome/commit/3c374b594000a47bef40c2d5d20d7ba677c74b31
config.go
} restartHTTPS := false data = validateCertificates(data) if data.WarningValidation == "" { if !reflect.DeepEqual(config.TLS.tlsConfigSettings, data.tlsConfigSettings) { log.Printf("tls config settings have changed, will restart HTTPS server") restartHTTPS = true } config.TLS = data
</s> remove if data.WarningValidation != "" { </s> add if !data.usable {
if data.usable {
} restartHTTPS := false data = validateCertificates(data) if data.usable { if !reflect.DeepEqual(config.TLS.tlsConfigSettings, data.tlsConfigSettings) { log.Printf("tls config settings have changed, will restart HTTPS server") restartHTTPS = true } config.TLS = data
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
/tls/ -- add internal usable flag to simplify logic when https needs to be booted up
https://github.com/AdguardTeam/AdGuardHome/commit/3c374b594000a47bef40c2d5d20d7ba677c74b31
control.go
if err != nil { data.WarningValidation = fmt.Sprintf("Invalid certificate or key: %s", err) return data } } return data }
</s> remove if data.WarningValidation == "" { </s> add if data.usable { </s> remove if data.WarningValidation != "" { </s> add if !data.usable {
data.usable = true
if err != nil { data.WarningValidation = fmt.Sprintf("Invalid certificate or key: %s", err) return data } data.usable = true } return data }
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
/tls/ -- add internal usable flag to simplify logic when https needs to be booted up
https://github.com/AdguardTeam/AdGuardHome/commit/3c374b594000a47bef40c2d5d20d7ba677c74b31
control.go
if err != nil { return false, fmt.Errorf("couldn't find interface by name %s: %w", ifaceName, err) } // get ipv4 address of an interface ifaceIPNet := getIfaceIPv4(*iface) if len(ifaceIPNet) == 0 { return false, fmt.Errorf("couldn't find IPv4 address of interface %s %+v", ifaceName, iface) } if runtime.GOOS == "darwin" {
</s> remove return false, fmt.Errorf("couldn't find IPv4 address of interface %s %+v", ifaceName, iface) </s> add return false, fmt.Errorf("interface %s has no ipv4 addresses", ifaceName) </s> remove ifaceIPNet := getIfaceIPv6(*iface) </s> add ifaceIPNet, err := ifaceIPv6Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv6 addrs for iface %s: %w", ifaceName, err) } </s> remove return false, fmt.Errorf("dhcpv6: couldn't find IPv6 address of interface %s %+v", ifaceName, iface) </s> add return false, fmt.Errorf("interface %s has no ipv6 addresses", ifaceName) </s> remove return fmt.Errorf("dhcpv4: Couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv4: finding interface %s by name: %w", ifaceName, err) </s> remove iface, err := net.InterfaceByName(s.conf.InterfaceName) </s> add ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) if err != nil { return fmt.Errorf("dhcpv6: finding interface %s by name: %w", ifaceName, err) } log.Debug("dhcpv4: starting...") dnsIPAddrs, err := ifaceIPv6Addrs(iface)
ifaceIPNet, err := ifaceIPv4Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv4 addrs for iface %s: %w", ifaceName, err) }
if err != nil { return false, fmt.Errorf("couldn't find interface by name %s: %w", ifaceName, err) } ifaceIPNet, err := ifaceIPv4Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv4 addrs for iface %s: %w", ifaceName, err) } ifaceIPNet, err := ifaceIPv4Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv4 addrs for iface %s: %w", ifaceName, err) } if len(ifaceIPNet) == 0 { return false, fmt.Errorf("couldn't find IPv4 address of interface %s %+v", ifaceName, iface) } if runtime.GOOS == "darwin" {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/check_other_dhcp.go
// get ipv4 address of an interface ifaceIPNet := getIfaceIPv4(*iface) if len(ifaceIPNet) == 0 { return false, fmt.Errorf("couldn't find IPv4 address of interface %s %+v", ifaceName, iface) } if runtime.GOOS == "darwin" { return false, fmt.Errorf("can't find DHCP server: not supported on macOS") }
</s> remove // get ipv4 address of an interface ifaceIPNet := getIfaceIPv4(*iface) </s> add ifaceIPNet, err := ifaceIPv4Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv4 addrs for iface %s: %w", ifaceName, err) } </s> remove return false, fmt.Errorf("dhcpv6: couldn't find IPv6 address of interface %s %+v", ifaceName, iface) </s> add return false, fmt.Errorf("interface %s has no ipv6 addresses", ifaceName) </s> remove ifaceIPNet := getIfaceIPv6(*iface) </s> add ifaceIPNet, err := ifaceIPv6Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv6 addrs for iface %s: %w", ifaceName, err) } </s> remove return fmt.Errorf("dhcpv4: Couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv4: finding interface %s by name: %w", ifaceName, err)
return false, fmt.Errorf("interface %s has no ipv4 addresses", ifaceName)
// get ipv4 address of an interface ifaceIPNet := getIfaceIPv4(*iface) if len(ifaceIPNet) == 0 { return false, fmt.Errorf("interface %s has no ipv4 addresses", ifaceName) } if runtime.GOOS == "darwin" { return false, fmt.Errorf("can't find DHCP server: not supported on macOS") }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/check_other_dhcp.go
return false, fmt.Errorf("interface %s has no ipv4 addresses", ifaceName) } if runtime.GOOS == "darwin" { return false, fmt.Errorf("can't find DHCP server: not supported on macOS") }
</s> remove return false, fmt.Errorf("couldn't find IPv4 address of interface %s %+v", ifaceName, iface) </s> add return false, fmt.Errorf("interface %s has no ipv4 addresses", ifaceName) </s> remove return false, fmt.Errorf("dhcpv6: couldn't find IPv6 address of interface %s %+v", ifaceName, iface) </s> add return false, fmt.Errorf("interface %s has no ipv6 addresses", ifaceName) </s> remove // get ipv4 address of an interface ifaceIPNet := getIfaceIPv4(*iface) </s> add ifaceIPNet, err := ifaceIPv4Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv4 addrs for iface %s: %w", ifaceName, err) } </s> remove ifaceIPNet := getIfaceIPv6(*iface) </s> add ifaceIPNet, err := ifaceIPv6Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv6 addrs for iface %s: %w", ifaceName, err) } </s> remove // wait for answer log.Tracef("Waiting %v for an answer", defaultDiscoverTime) // TODO: replicate dhclient's behaviour of retrying several times with progressively bigger timeouts b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if isTimeout(err) { // timed out -- no DHCP servers log.Debug("DHCPv4: didn't receive DHCP response") return false, nil </s> add ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil
// TODO(a.garipov): Find out what this is about. Perhaps this // information is outdated or at least incomplete.
return false, fmt.Errorf("interface %s has no ipv4 addresses", ifaceName) } // TODO(a.garipov): Find out what this is about. Perhaps this // information is outdated or at least incomplete. if runtime.GOOS == "darwin" { return false, fmt.Errorf("can't find DHCP server: not supported on macOS") }
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/check_other_dhcp.go
return false, fmt.Errorf("couldn't send a packet to %s: %w", dst, err) } for { // wait for answer log.Tracef("Waiting %v for an answer", defaultDiscoverTime) // TODO: replicate dhclient's behaviour of retrying several times with progressively bigger timeouts b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if isTimeout(err) { // timed out -- no DHCP servers log.Debug("DHCPv4: didn't receive DHCP response") return false, nil } if err != nil { return false, fmt.Errorf("couldn't receive packet: %w", err) }
</s> remove log.Tracef("Received packet (%v bytes)", n) </s> add // TODO(a.garipov): Refactor further. Inspect error handling, remove the next // parameter, address the TODO, etc. func tryConn(req *dhcpv4.DHCPv4, c net.PacketConn, iface *net.Interface) (ok, next bool, err error) { // TODO: replicate dhclient's behavior of retrying several times with // progressively longer timeouts. log.Tracef("waiting %v for an answer", defaultDiscoverTime) </s> remove response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("DHCPv4: dhcpv4.FromBytes: %s", err) continue </s> add b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if err != nil { if isTimeout(err) { log.Debug("dhcpv4: didn't receive dhcp response") return false, false, nil </s> remove return false, fmt.Errorf("couldn't receive packet: %w", err) </s> add log.Debug("%s", err) </s> remove // get ipv4 address of an interface ifaceIPNet := getIfaceIPv4(*iface) </s> add ifaceIPNet, err := ifaceIPv4Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv4 addrs for iface %s: %w", ifaceName, err) }
ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil
return false, fmt.Errorf("couldn't send a packet to %s: %w", dst, err) } for { ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil } if err != nil { return false, fmt.Errorf("couldn't receive packet: %w", err) }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/check_other_dhcp.go
log.Debug("DHCPv4: didn't receive DHCP response") return false, nil } if err != nil { return false, fmt.Errorf("couldn't receive packet: %w", err) } log.Tracef("Received packet (%v bytes)", n) response, err := dhcpv4.FromBytes(b[:n])
</s> remove response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("DHCPv4: dhcpv4.FromBytes: %s", err) continue </s> add b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if err != nil { if isTimeout(err) { log.Debug("dhcpv4: didn't receive dhcp response") return false, false, nil </s> remove log.Tracef("Received packet (%v bytes)", n) </s> add // TODO(a.garipov): Refactor further. Inspect error handling, remove the next // parameter, address the TODO, etc. func tryConn(req *dhcpv4.DHCPv4, c net.PacketConn, iface *net.Interface) (ok, next bool, err error) { // TODO: replicate dhclient's behavior of retrying several times with // progressively longer timeouts. log.Tracef("waiting %v for an answer", defaultDiscoverTime) </s> remove // wait for answer log.Tracef("Waiting %v for an answer", defaultDiscoverTime) // TODO: replicate dhclient's behaviour of retrying several times with progressively bigger timeouts b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if isTimeout(err) { // timed out -- no DHCP servers log.Debug("DHCPv4: didn't receive DHCP response") return false, nil </s> add ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil </s> remove log.Tracef("The packet is from an active DHCP server") // that's a DHCP server there return true, nil </s> add response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("dhcpv4: encoding: %s", err) return false, true, err </s> remove // get ipv4 address of an interface ifaceIPNet := getIfaceIPv4(*iface) </s> add ifaceIPNet, err := ifaceIPv4Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv4 addrs for iface %s: %w", ifaceName, err) }
log.Debug("%s", err)
log.Debug("DHCPv4: didn't receive DHCP response") return false, nil } if err != nil { log.Debug("%s", err) } log.Tracef("Received packet (%v bytes)", n) response, err := dhcpv4.FromBytes(b[:n])
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/check_other_dhcp.go
if err != nil { log.Debug("%s", err) } // TODO(a.garipov): Refactor further. Inspect error handling, remove the next // parameter, address the TODO, etc. func tryConn(req *dhcpv4.DHCPv4, c net.PacketConn, iface *net.Interface) (ok, next bool, err error) { // TODO: replicate dhclient's behavior of retrying several times with
</s> remove log.Tracef("Received packet (%v bytes)", n) </s> add // TODO(a.garipov): Refactor further. Inspect error handling, remove the next // parameter, address the TODO, etc. func tryConn(req *dhcpv4.DHCPv4, c net.PacketConn, iface *net.Interface) (ok, next bool, err error) { // TODO: replicate dhclient's behavior of retrying several times with // progressively longer timeouts. log.Tracef("waiting %v for an answer", defaultDiscoverTime) </s> remove // wait for answer log.Tracef("Waiting %v for an answer", defaultDiscoverTime) // TODO: replicate dhclient's behaviour of retrying several times with progressively bigger timeouts b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if isTimeout(err) { // timed out -- no DHCP servers log.Debug("DHCPv4: didn't receive DHCP response") return false, nil </s> add ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil </s> remove // Get IPv6 address list func getIfaceIPv6(iface net.Interface) []net.IP { </s> add // ifaceIPv6Addrs returns the interface's IPv6 addresses. func ifaceIPv6Addrs(iface *net.Interface) (ips []net.IP, err error) { </s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server. </s> remove return res </s> add return ips, nil
} }
if err != nil { log.Debug("%s", err) } } } // TODO(a.garipov): Refactor further. Inspect error handling, remove the next // parameter, address the TODO, etc. func tryConn(req *dhcpv4.DHCPv4, c net.PacketConn, iface *net.Interface) (ok, next bool, err error) { // TODO: replicate dhclient's behavior of retrying several times with
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/check_other_dhcp.go
if err != nil { return false, fmt.Errorf("couldn't receive packet: %w", err) } log.Tracef("Received packet (%v bytes)", n) response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("DHCPv4: dhcpv4.FromBytes: %s", err) continue
</s> remove return false, fmt.Errorf("couldn't receive packet: %w", err) </s> add log.Debug("%s", err) </s> remove response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("DHCPv4: dhcpv4.FromBytes: %s", err) continue </s> add b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if err != nil { if isTimeout(err) { log.Debug("dhcpv4: didn't receive dhcp response") return false, false, nil </s> remove // wait for answer log.Tracef("Waiting %v for an answer", defaultDiscoverTime) // TODO: replicate dhclient's behaviour of retrying several times with progressively bigger timeouts b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if isTimeout(err) { // timed out -- no DHCP servers log.Debug("DHCPv4: didn't receive DHCP response") return false, nil </s> add ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil </s> remove log.Tracef("The packet is from an active DHCP server") // that's a DHCP server there return true, nil </s> add response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("dhcpv4: encoding: %s", err) return false, true, err </s> remove // get ipv4 address of an interface ifaceIPNet := getIfaceIPv4(*iface) </s> add ifaceIPNet, err := ifaceIPv4Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv4 addrs for iface %s: %w", ifaceName, err) }
// TODO(a.garipov): Refactor further. Inspect error handling, remove the next // parameter, address the TODO, etc. func tryConn(req *dhcpv4.DHCPv4, c net.PacketConn, iface *net.Interface) (ok, next bool, err error) { // TODO: replicate dhclient's behavior of retrying several times with // progressively longer timeouts. log.Tracef("waiting %v for an answer", defaultDiscoverTime)
if err != nil { return false, fmt.Errorf("couldn't receive packet: %w", err) } // TODO(a.garipov): Refactor further. Inspect error handling, remove the next // parameter, address the TODO, etc. func tryConn(req *dhcpv4.DHCPv4, c net.PacketConn, iface *net.Interface) (ok, next bool, err error) { // TODO: replicate dhclient's behavior of retrying several times with // progressively longer timeouts. log.Tracef("waiting %v for an answer", defaultDiscoverTime) response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("DHCPv4: dhcpv4.FromBytes: %s", err) continue
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/check_other_dhcp.go
} log.Tracef("Received packet (%v bytes)", n) response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("DHCPv4: dhcpv4.FromBytes: %s", err) continue } log.Debug("DHCPv4: received message from server: %s", response.Summary()) if !(response.OpCode == dhcpv4.OpcodeBootReply &&
</s> remove log.Debug("DHCPv4: received message from server: %s", response.Summary()) </s> add return false, false, fmt.Errorf("receiving packet: %w", err) } </s> remove if !(response.OpCode == dhcpv4.OpcodeBootReply && response.HWType == iana.HWTypeEthernet && bytes.Equal(response.ClientHWAddr, iface.HardwareAddr) && bytes.Equal(response.TransactionID[:], req.TransactionID[:]) && response.Options.Has(dhcpv4.OptionDHCPMessageType)) { log.Debug("DHCPv4: received message from server doesn't match our request") continue } </s> add log.Tracef("received packet, %d bytes", n) </s> remove return false, fmt.Errorf("couldn't receive packet: %w", err) </s> add log.Debug("%s", err) </s> remove log.Tracef("Received packet (%v bytes)", n) </s> add // TODO(a.garipov): Refactor further. Inspect error handling, remove the next // parameter, address the TODO, etc. func tryConn(req *dhcpv4.DHCPv4, c net.PacketConn, iface *net.Interface) (ok, next bool, err error) { // TODO: replicate dhclient's behavior of retrying several times with // progressively longer timeouts. log.Tracef("waiting %v for an answer", defaultDiscoverTime) </s> remove log.Tracef("The packet is from an active DHCP server") // that's a DHCP server there return true, nil </s> add response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("dhcpv4: encoding: %s", err) return false, true, err
b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if err != nil { if isTimeout(err) { log.Debug("dhcpv4: didn't receive dhcp response") return false, false, nil
} log.Tracef("Received packet (%v bytes)", n) b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if err != nil { if isTimeout(err) { log.Debug("dhcpv4: didn't receive dhcp response") return false, false, nil b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if err != nil { if isTimeout(err) { log.Debug("dhcpv4: didn't receive dhcp response") return false, false, nil b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if err != nil { if isTimeout(err) { log.Debug("dhcpv4: didn't receive dhcp response") return false, false, nil b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if err != nil { if isTimeout(err) { log.Debug("dhcpv4: didn't receive dhcp response") return false, false, nil } log.Debug("DHCPv4: received message from server: %s", response.Summary()) if !(response.OpCode == dhcpv4.OpcodeBootReply &&
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/check_other_dhcp.go
log.Debug("DHCPv4: dhcpv4.FromBytes: %s", err) continue } log.Debug("DHCPv4: received message from server: %s", response.Summary()) if !(response.OpCode == dhcpv4.OpcodeBootReply && response.HWType == iana.HWTypeEthernet && bytes.Equal(response.ClientHWAddr, iface.HardwareAddr) && bytes.Equal(response.TransactionID[:], req.TransactionID[:]) &&
</s> remove if !(response.OpCode == dhcpv4.OpcodeBootReply && response.HWType == iana.HWTypeEthernet && bytes.Equal(response.ClientHWAddr, iface.HardwareAddr) && bytes.Equal(response.TransactionID[:], req.TransactionID[:]) && response.Options.Has(dhcpv4.OptionDHCPMessageType)) { log.Debug("DHCPv4: received message from server doesn't match our request") continue } </s> add log.Tracef("received packet, %d bytes", n) </s> remove response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("DHCPv4: dhcpv4.FromBytes: %s", err) continue </s> add b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if err != nil { if isTimeout(err) { log.Debug("dhcpv4: didn't receive dhcp response") return false, false, nil </s> remove log.Tracef("The packet is from an active DHCP server") // that's a DHCP server there return true, nil </s> add response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("dhcpv4: encoding: %s", err) return false, true, err </s> remove log.Tracef("Received packet (%v bytes)", n) </s> add // TODO(a.garipov): Refactor further. Inspect error handling, remove the next // parameter, address the TODO, etc. func tryConn(req *dhcpv4.DHCPv4, c net.PacketConn, iface *net.Interface) (ok, next bool, err error) { // TODO: replicate dhclient's behavior of retrying several times with // progressively longer timeouts. log.Tracef("waiting %v for an answer", defaultDiscoverTime) </s> remove return false, fmt.Errorf("couldn't receive packet: %w", err) </s> add log.Debug("%s", err)
return false, false, fmt.Errorf("receiving packet: %w", err) }
log.Debug("DHCPv4: dhcpv4.FromBytes: %s", err) continue } return false, false, fmt.Errorf("receiving packet: %w", err) } if !(response.OpCode == dhcpv4.OpcodeBootReply && response.HWType == iana.HWTypeEthernet && bytes.Equal(response.ClientHWAddr, iface.HardwareAddr) && bytes.Equal(response.TransactionID[:], req.TransactionID[:]) &&
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/check_other_dhcp.go
} log.Debug("DHCPv4: received message from server: %s", response.Summary()) if !(response.OpCode == dhcpv4.OpcodeBootReply && response.HWType == iana.HWTypeEthernet && bytes.Equal(response.ClientHWAddr, iface.HardwareAddr) && bytes.Equal(response.TransactionID[:], req.TransactionID[:]) && response.Options.Has(dhcpv4.OptionDHCPMessageType)) { log.Debug("DHCPv4: received message from server doesn't match our request") continue } log.Tracef("The packet is from an active DHCP server") // that's a DHCP server there return true, nil }
</s> remove log.Debug("DHCPv4: received message from server: %s", response.Summary()) </s> add return false, false, fmt.Errorf("receiving packet: %w", err) } </s> remove log.Tracef("The packet is from an active DHCP server") // that's a DHCP server there return true, nil </s> add response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("dhcpv4: encoding: %s", err) return false, true, err </s> remove response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("DHCPv4: dhcpv4.FromBytes: %s", err) continue </s> add b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if err != nil { if isTimeout(err) { log.Debug("dhcpv4: didn't receive dhcp response") return false, false, nil </s> remove // wait for answer log.Tracef("Waiting %v for an answer", defaultDiscoverTime) // TODO: replicate dhclient's behaviour of retrying several times with progressively bigger timeouts b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if isTimeout(err) { // timed out -- no DHCP servers log.Debug("DHCPv4: didn't receive DHCP response") return false, nil </s> add ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil </s> remove // Start - start server </s> add // Start starts the IPv6 DHCP server.
log.Tracef("received packet, %d bytes", n)
} log.Debug("DHCPv4: received message from server: %s", response.Summary()) log.Tracef("received packet, %d bytes", n) log.Tracef("received packet, %d bytes", n) log.Tracef("received packet, %d bytes", n) log.Tracef("received packet, %d bytes", n) log.Tracef("received packet, %d bytes", n) log.Tracef("received packet, %d bytes", n) log.Tracef("received packet, %d bytes", n) log.Tracef("received packet, %d bytes", n) log.Tracef("The packet is from an active DHCP server") // that's a DHCP server there return true, nil }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/check_other_dhcp.go
log.Debug("DHCPv4: received message from server doesn't match our request") continue } log.Tracef("The packet is from an active DHCP server") // that's a DHCP server there return true, nil } } // CheckIfOtherDHCPServersPresentV6 sends a DHCP request to the specified network interface, // and waits for a response for a period defined by defaultDiscoverTime
</s> remove if !(response.OpCode == dhcpv4.OpcodeBootReply && response.HWType == iana.HWTypeEthernet && bytes.Equal(response.ClientHWAddr, iface.HardwareAddr) && bytes.Equal(response.TransactionID[:], req.TransactionID[:]) && response.Options.Has(dhcpv4.OptionDHCPMessageType)) { log.Debug("DHCPv4: received message from server doesn't match our request") continue } </s> add log.Tracef("received packet, %d bytes", n) </s> remove // wait for answer log.Tracef("Waiting %v for an answer", defaultDiscoverTime) // TODO: replicate dhclient's behaviour of retrying several times with progressively bigger timeouts b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if isTimeout(err) { // timed out -- no DHCP servers log.Debug("DHCPv4: didn't receive DHCP response") return false, nil </s> add ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil </s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server. </s> remove // Start - start server </s> add // Start starts the IPv6 DHCP server.
response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("dhcpv4: encoding: %s", err) return false, true, err
log.Debug("DHCPv4: received message from server doesn't match our request") continue } response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("dhcpv4: encoding: %s", err) return false, true, err response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("dhcpv4: encoding: %s", err) return false, true, err response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("dhcpv4: encoding: %s", err) return false, true, err } } // CheckIfOtherDHCPServersPresentV6 sends a DHCP request to the specified network interface, // and waits for a response for a period defined by defaultDiscoverTime
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/check_other_dhcp.go
if err != nil { return false, fmt.Errorf("dhcpv6: net.InterfaceByName: %s: %w", ifaceName, err) } ifaceIPNet := getIfaceIPv6(*iface) if len(ifaceIPNet) == 0 { return false, fmt.Errorf("dhcpv6: couldn't find IPv6 address of interface %s %+v", ifaceName, iface) } srcIP := ifaceIPNet[0]
</s> remove return false, fmt.Errorf("dhcpv6: couldn't find IPv6 address of interface %s %+v", ifaceName, iface) </s> add return false, fmt.Errorf("interface %s has no ipv6 addresses", ifaceName) </s> remove // get ipv4 address of an interface ifaceIPNet := getIfaceIPv4(*iface) </s> add ifaceIPNet, err := ifaceIPv4Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv4 addrs for iface %s: %w", ifaceName, err) } </s> remove return false, fmt.Errorf("couldn't find IPv4 address of interface %s %+v", ifaceName, iface) </s> add return false, fmt.Errorf("interface %s has no ipv4 addresses", ifaceName) </s> remove return fmt.Errorf("couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv6: getting ipv6 addrs for iface %s: %w", ifaceName, err) </s> remove iface, err := net.InterfaceByName(s.conf.InterfaceName) </s> add ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) if err != nil { return fmt.Errorf("dhcpv6: finding interface %s by name: %w", ifaceName, err) } log.Debug("dhcpv4: starting...") dnsIPAddrs, err := ifaceIPv6Addrs(iface)
ifaceIPNet, err := ifaceIPv6Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv6 addrs for iface %s: %w", ifaceName, err) }
if err != nil { return false, fmt.Errorf("dhcpv6: net.InterfaceByName: %s: %w", ifaceName, err) } ifaceIPNet, err := ifaceIPv6Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv6 addrs for iface %s: %w", ifaceName, err) } if len(ifaceIPNet) == 0 { return false, fmt.Errorf("dhcpv6: couldn't find IPv6 address of interface %s %+v", ifaceName, iface) } srcIP := ifaceIPNet[0]
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/check_other_dhcp.go
} ifaceIPNet := getIfaceIPv6(*iface) if len(ifaceIPNet) == 0 { return false, fmt.Errorf("dhcpv6: couldn't find IPv6 address of interface %s %+v", ifaceName, iface) } srcIP := ifaceIPNet[0] src := net.JoinHostPort(srcIP.String(), "546") dst := "[ff02::1:2]:547"
</s> remove ifaceIPNet := getIfaceIPv6(*iface) </s> add ifaceIPNet, err := ifaceIPv6Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv6 addrs for iface %s: %w", ifaceName, err) } </s> remove return false, fmt.Errorf("couldn't find IPv4 address of interface %s %+v", ifaceName, iface) </s> add return false, fmt.Errorf("interface %s has no ipv4 addresses", ifaceName) </s> remove // get ipv4 address of an interface ifaceIPNet := getIfaceIPv4(*iface) </s> add ifaceIPNet, err := ifaceIPv4Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv4 addrs for iface %s: %w", ifaceName, err) } </s> remove iface, err := net.InterfaceByName(s.conf.InterfaceName) </s> add ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) if err != nil { return fmt.Errorf("dhcpv6: finding interface %s by name: %w", ifaceName, err) } log.Debug("dhcpv4: starting...") dnsIPAddrs, err := ifaceIPv6Addrs(iface) </s> remove return fmt.Errorf("couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv6: getting ipv6 addrs for iface %s: %w", ifaceName, err)
return false, fmt.Errorf("interface %s has no ipv6 addresses", ifaceName)
} ifaceIPNet := getIfaceIPv6(*iface) if len(ifaceIPNet) == 0 { return false, fmt.Errorf("interface %s has no ipv6 addresses", ifaceName) } srcIP := ifaceIPNet[0] src := net.JoinHostPort(srcIP.String(), "546") dst := "[ff02::1:2]:547"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/check_other_dhcp.go
othSrv := map[string]interface{}{} foundVal := "no" if found4 { foundVal = "yes" } else if err != nil { foundVal = "error" othSrv["error"] = err4.Error() } othSrv["found"] = foundVal v4["other_server"] = othSrv
</s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server. </s> remove iface, err := net.InterfaceByName(s.conf.InterfaceName) </s> add ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) if err != nil { return fmt.Errorf("dhcpv6: finding interface %s by name: %w", ifaceName, err) } log.Debug("dhcpv4: starting...") dnsIPAddrs, err := ifaceIPv6Addrs(iface) </s> remove // Get IPv4 address list func getIfaceIPv4(iface net.Interface) []net.IP { addrs, err := iface.Addrs() if err != nil { return nil } var res []net.IP for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ipnet.IP.To4() != nil { res = append(res, ipnet.IP.To4()) } } return res } </s> add </s> remove if ipnet.IP.To4() == nil { res = append(res, ipnet.IP) </s> add if ip := ipnet.IP.To16(); ip != nil { ips = append(ips, ip) </s> remove var res []net.IP </s> add
} else if err4 != nil {
othSrv := map[string]interface{}{} foundVal := "no" if found4 { foundVal = "yes" } else if err4 != nil { foundVal = "error" othSrv["error"] = err4.Error() } othSrv["found"] = foundVal v4["other_server"] = othSrv
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/dhcp_http.go
} return operr.Timeout() } // Get IPv4 address list func getIfaceIPv4(iface net.Interface) []net.IP { addrs, err := iface.Addrs() if err != nil { return nil } var res []net.IP for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ipnet.IP.To4() != nil { res = append(res, ipnet.IP.To4()) } } return res } func parseIPv4(text string) (net.IP, error) { result := net.ParseIP(text) if result == nil { return nil, fmt.Errorf("%s is not an IP address", text) }
</s> remove return nil </s> add return nil, err </s> remove var res []net.IP </s> add </s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server. </s> remove if ipnet.IP.To4() == nil { res = append(res, ipnet.IP) </s> add if ip := ipnet.IP.To16(); ip != nil { ips = append(ips, ip) </s> remove // Get IPv6 address list func getIfaceIPv6(iface net.Interface) []net.IP { </s> add // ifaceIPv6Addrs returns the interface's IPv6 addresses. func ifaceIPv6Addrs(iface *net.Interface) (ips []net.IP, err error) {
} return operr.Timeout() } func parseIPv4(text string) (net.IP, error) { result := net.ParseIP(text) if result == nil { return nil, fmt.Errorf("%s is not an IP address", text) }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/helpers.go
func (s *v4Server) WriteDiskConfig6(c *V6ServerConf) { } // Return TRUE if IP address is within range [start..stop] func ip4InRange(start net.IP, stop net.IP, ip net.IP) bool { if len(start) != 4 || len(stop) != 4 { return false } from := binary.BigEndian.Uint32(start) to := binary.BigEndian.Uint32(stop)
</s> remove func (s *v4Server) processRequest(req *dhcpv4.DHCPv4, resp *dhcpv4.DHCPv4) (*Lease, bool) { </s> add func (s *v4Server) processRequest(req, resp *dhcpv4.DHCPv4) (*Lease, bool) { </s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server. </s> remove // Get IPv4 address list func getIfaceIPv4(iface net.Interface) []net.IP { addrs, err := iface.Addrs() if err != nil { return nil } var res []net.IP for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ipnet.IP.To4() != nil { res = append(res, ipnet.IP.To4()) } } return res } </s> add </s> remove return nil </s> add return nil, err </s> remove if ipnet.IP.To4() == nil { res = append(res, ipnet.IP) </s> add if ip := ipnet.IP.To16(); ip != nil { ips = append(ips, ip)
func ip4InRange(start, stop, ip net.IP) bool {
func (s *v4Server) WriteDiskConfig6(c *V6ServerConf) { } // Return TRUE if IP address is within range [start..stop] func ip4InRange(start, stop, ip net.IP) bool { if len(start) != 4 || len(stop) != 4 { return false } from := binary.BigEndian.Uint32(start) to := binary.BigEndian.Uint32(stop)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v4.go
s.conf.notify(LeaseChangedAdded) } // Process Discover request and return lease func (s *v4Server) processDiscover(req *dhcpv4.DHCPv4, resp *dhcpv4.DHCPv4) *Lease { mac := req.ClientHWAddr s.leasesLock.Lock() defer s.leasesLock.Unlock()
</s> remove func (s *v4Server) processRequest(req *dhcpv4.DHCPv4, resp *dhcpv4.DHCPv4) (*Lease, bool) { </s> add func (s *v4Server) processRequest(req, resp *dhcpv4.DHCPv4) (*Lease, bool) { </s> remove func (s *v4Server) process(req *dhcpv4.DHCPv4, resp *dhcpv4.DHCPv4) int { </s> add func (s *v4Server) process(req, resp *dhcpv4.DHCPv4) int { </s> remove func ip4InRange(start net.IP, stop net.IP, ip net.IP) bool { </s> add func ip4InRange(start, stop, ip net.IP) bool { </s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server. </s> remove log.Tracef("The packet is from an active DHCP server") // that's a DHCP server there return true, nil </s> add response, err := dhcpv4.FromBytes(b[:n]) if err != nil { log.Debug("dhcpv4: encoding: %s", err) return false, true, err
func (s *v4Server) processDiscover(req, resp *dhcpv4.DHCPv4) *Lease {
s.conf.notify(LeaseChangedAdded) } // Process Discover request and return lease func (s *v4Server) processDiscover(req, resp *dhcpv4.DHCPv4) *Lease { mac := req.ClientHWAddr s.leasesLock.Lock() defer s.leasesLock.Unlock()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v4.go
} // Process Request request and return lease // Return false if we don't need to reply func (s *v4Server) processRequest(req *dhcpv4.DHCPv4, resp *dhcpv4.DHCPv4) (*Lease, bool) { var lease *Lease mac := req.ClientHWAddr hostname := req.Options.Get(dhcpv4.OptionHostName) reqIP := req.Options.Get(dhcpv4.OptionRequestedIPAddress) if reqIP == nil {
</s> remove func (s *v4Server) processDiscover(req *dhcpv4.DHCPv4, resp *dhcpv4.DHCPv4) *Lease { </s> add func (s *v4Server) processDiscover(req, resp *dhcpv4.DHCPv4) *Lease { </s> remove func (s *v4Server) process(req *dhcpv4.DHCPv4, resp *dhcpv4.DHCPv4) int { </s> add func (s *v4Server) process(req, resp *dhcpv4.DHCPv4) int { </s> remove func ip4InRange(start net.IP, stop net.IP, ip net.IP) bool { </s> add func ip4InRange(start, stop, ip net.IP) bool { </s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server. </s> remove // Get IPv4 address list func getIfaceIPv4(iface net.Interface) []net.IP { addrs, err := iface.Addrs() if err != nil { return nil } var res []net.IP for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ipnet.IP.To4() != nil { res = append(res, ipnet.IP.To4()) } } return res } </s> add
func (s *v4Server) processRequest(req, resp *dhcpv4.DHCPv4) (*Lease, bool) {
} // Process Request request and return lease // Return false if we don't need to reply func (s *v4Server) processRequest(req, resp *dhcpv4.DHCPv4) (*Lease, bool) { var lease *Lease mac := req.ClientHWAddr hostname := req.Options.Get(dhcpv4.OptionHostName) reqIP := req.Options.Get(dhcpv4.OptionRequestedIPAddress) if reqIP == nil {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v4.go
// Find a lease associated with MAC and prepare response // Return 1: OK // Return 0: error; reply with Nak // Return -1: error; don't reply func (s *v4Server) process(req *dhcpv4.DHCPv4, resp *dhcpv4.DHCPv4) int { var lease *Lease resp.UpdateOption(dhcpv4.OptServerIdentifier(s.conf.dnsIPAddrs[0])) switch req.MessageType() {
</s> remove func (s *v4Server) processRequest(req *dhcpv4.DHCPv4, resp *dhcpv4.DHCPv4) (*Lease, bool) { </s> add func (s *v4Server) processRequest(req, resp *dhcpv4.DHCPv4) (*Lease, bool) { </s> remove func (s *v4Server) processDiscover(req *dhcpv4.DHCPv4, resp *dhcpv4.DHCPv4) *Lease { </s> add func (s *v4Server) processDiscover(req, resp *dhcpv4.DHCPv4) *Lease { </s> remove func ip4InRange(start net.IP, stop net.IP, ip net.IP) bool { </s> add func ip4InRange(start, stop, ip net.IP) bool { </s> remove log.Tracef("Received packet (%v bytes)", n) </s> add // TODO(a.garipov): Refactor further. Inspect error handling, remove the next // parameter, address the TODO, etc. func tryConn(req *dhcpv4.DHCPv4, c net.PacketConn, iface *net.Interface) (ok, next bool, err error) { // TODO: replicate dhclient's behavior of retrying several times with // progressively longer timeouts. log.Tracef("waiting %v for an answer", defaultDiscoverTime)
func (s *v4Server) process(req, resp *dhcpv4.DHCPv4) int {
// Find a lease associated with MAC and prepare response // Return 1: OK // Return 0: error; reply with Nak // Return -1: error; don't reply func (s *v4Server) process(req, resp *dhcpv4.DHCPv4) int { var lease *Lease resp.UpdateOption(dhcpv4.OptServerIdentifier(s.conf.dnsIPAddrs[0])) switch req.MessageType() {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v4.go
return } } // Start - start server func (s *v4Server) Start() error { if !s.conf.Enabled { return nil }
</s> remove // Start - start server </s> add // Start starts the IPv6 DHCP server. </s> remove return res </s> add return ips, nil </s> remove func (s *v4Server) processRequest(req *dhcpv4.DHCPv4, resp *dhcpv4.DHCPv4) (*Lease, bool) { </s> add func (s *v4Server) processRequest(req, resp *dhcpv4.DHCPv4) (*Lease, bool) { </s> remove func (s *v4Server) processDiscover(req *dhcpv4.DHCPv4, resp *dhcpv4.DHCPv4) *Lease { </s> add func (s *v4Server) processDiscover(req, resp *dhcpv4.DHCPv4) *Lease { </s> remove func ip4InRange(start net.IP, stop net.IP, ip net.IP) bool { </s> add func ip4InRange(start, stop, ip net.IP) bool {
// ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server.
return } } // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server. func (s *v4Server) Start() error { if !s.conf.Enabled { return nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v4.go
if !s.conf.Enabled { return nil } iface, err := net.InterfaceByName(s.conf.InterfaceName) if err != nil { return fmt.Errorf("dhcpv4: Couldn't find interface by name %s: %w", s.conf.InterfaceName, err) } log.Debug("dhcpv4: starting...")
</s> remove return fmt.Errorf("dhcpv4: Couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv4: finding interface %s by name: %w", ifaceName, err) </s> remove iface, err := net.InterfaceByName(s.conf.InterfaceName) </s> add ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) if err != nil { return fmt.Errorf("dhcpv6: finding interface %s by name: %w", ifaceName, err) } log.Debug("dhcpv4: starting...") dnsIPAddrs, err := ifaceIPv6Addrs(iface) </s> remove s.conf.dnsIPAddrs = getIfaceIPv4(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("dhcpv4: no IPv6 address for interface %s", iface.Name) </s> add dnsIPAddrs, err := ifaceIPv4Addrs(iface) if err != nil { return fmt.Errorf("dhcpv4: getting ipv4 addrs for iface %s: %w", ifaceName, err) } switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv4: no ipv4 address for interface %s", iface.Name) </s> remove return fmt.Errorf("couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv6: getting ipv6 addrs for iface %s: %w", ifaceName, err) </s> remove s.conf.dnsIPAddrs = getIfaceIPv6(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("DHCPv6: no IPv6 address for interface %s", iface.Name) </s> add switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv6: no ipv6 address for interface %s", iface.Name)
ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName)
if !s.conf.Enabled { return nil } ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) if err != nil { return fmt.Errorf("dhcpv4: Couldn't find interface by name %s: %w", s.conf.InterfaceName, err) } log.Debug("dhcpv4: starting...")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v4.go
} iface, err := net.InterfaceByName(s.conf.InterfaceName) if err != nil { return fmt.Errorf("dhcpv4: Couldn't find interface by name %s: %w", s.conf.InterfaceName, err) } log.Debug("dhcpv4: starting...") s.conf.dnsIPAddrs = getIfaceIPv4(*iface) if len(s.conf.dnsIPAddrs) == 0 {
</s> remove iface, err := net.InterfaceByName(s.conf.InterfaceName) </s> add ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) </s> remove s.conf.dnsIPAddrs = getIfaceIPv4(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("dhcpv4: no IPv6 address for interface %s", iface.Name) </s> add dnsIPAddrs, err := ifaceIPv4Addrs(iface) if err != nil { return fmt.Errorf("dhcpv4: getting ipv4 addrs for iface %s: %w", ifaceName, err) } switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv4: no ipv4 address for interface %s", iface.Name) </s> remove iface, err := net.InterfaceByName(s.conf.InterfaceName) </s> add ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) if err != nil { return fmt.Errorf("dhcpv6: finding interface %s by name: %w", ifaceName, err) } log.Debug("dhcpv4: starting...") dnsIPAddrs, err := ifaceIPv6Addrs(iface) </s> remove return fmt.Errorf("couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv6: getting ipv6 addrs for iface %s: %w", ifaceName, err) </s> remove s.conf.dnsIPAddrs = getIfaceIPv6(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("DHCPv6: no IPv6 address for interface %s", iface.Name) </s> add switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv6: no ipv6 address for interface %s", iface.Name)
return fmt.Errorf("dhcpv4: finding interface %s by name: %w", ifaceName, err)
} iface, err := net.InterfaceByName(s.conf.InterfaceName) if err != nil { return fmt.Errorf("dhcpv4: finding interface %s by name: %w", ifaceName, err) } log.Debug("dhcpv4: starting...") s.conf.dnsIPAddrs = getIfaceIPv4(*iface) if len(s.conf.dnsIPAddrs) == 0 {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v4.go
return fmt.Errorf("dhcpv4: Couldn't find interface by name %s: %w", s.conf.InterfaceName, err) } log.Debug("dhcpv4: starting...") s.conf.dnsIPAddrs = getIfaceIPv4(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("dhcpv4: no IPv6 address for interface %s", iface.Name) return nil } laddr := &net.UDPAddr{ IP: net.ParseIP("0.0.0.0"),
</s> remove return fmt.Errorf("dhcpv4: Couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv4: finding interface %s by name: %w", ifaceName, err) </s> remove iface, err := net.InterfaceByName(s.conf.InterfaceName) </s> add ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) </s> remove return fmt.Errorf("couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv6: getting ipv6 addrs for iface %s: %w", ifaceName, err) </s> remove s.conf.dnsIPAddrs = getIfaceIPv6(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("DHCPv6: no IPv6 address for interface %s", iface.Name) </s> add switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv6: no ipv6 address for interface %s", iface.Name)
dnsIPAddrs, err := ifaceIPv4Addrs(iface) if err != nil { return fmt.Errorf("dhcpv4: getting ipv4 addrs for iface %s: %w", ifaceName, err) } switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv4: no ipv4 address for interface %s", iface.Name)
return fmt.Errorf("dhcpv4: Couldn't find interface by name %s: %w", s.conf.InterfaceName, err) } log.Debug("dhcpv4: starting...") dnsIPAddrs, err := ifaceIPv4Addrs(iface) if err != nil { return fmt.Errorf("dhcpv4: getting ipv4 addrs for iface %s: %w", ifaceName, err) } switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv4: no ipv4 address for interface %s", iface.Name) dnsIPAddrs, err := ifaceIPv4Addrs(iface) if err != nil { return fmt.Errorf("dhcpv4: getting ipv4 addrs for iface %s: %w", ifaceName, err) } switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv4: no ipv4 address for interface %s", iface.Name) dnsIPAddrs, err := ifaceIPv4Addrs(iface) if err != nil { return fmt.Errorf("dhcpv4: getting ipv4 addrs for iface %s: %w", ifaceName, err) } switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv4: no ipv4 address for interface %s", iface.Name) return nil } laddr := &net.UDPAddr{ IP: net.ParseIP("0.0.0.0"),
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v4.go
case 0: log.Debug("dhcpv4: no ipv4 address for interface %s", iface.Name) return nil } s.conf.dnsIPAddrs = dnsIPAddrs laddr := &net.UDPAddr{ IP: net.ParseIP("0.0.0.0"),
</s> remove s.conf.dnsIPAddrs = getIfaceIPv4(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("dhcpv4: no IPv6 address for interface %s", iface.Name) </s> add dnsIPAddrs, err := ifaceIPv4Addrs(iface) if err != nil { return fmt.Errorf("dhcpv4: getting ipv4 addrs for iface %s: %w", ifaceName, err) } switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv4: no ipv4 address for interface %s", iface.Name) </s> remove s.conf.dnsIPAddrs = getIfaceIPv6(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("DHCPv6: no IPv6 address for interface %s", iface.Name) </s> add switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv6: no ipv6 address for interface %s", iface.Name) </s> remove return fmt.Errorf("couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv6: getting ipv6 addrs for iface %s: %w", ifaceName, err)
case 1: // Some Android devices use 8.8.8.8 if there is no secondary DNS // server. Fix that by setting the secondary DNS address to our // address as well. // // See https://github.com/AdguardTeam/AdGuardHome/issues/1708. log.Debug("dhcpv4: setting secondary dns ip to iself for interface %s", iface.Name) dnsIPAddrs = append(dnsIPAddrs, dnsIPAddrs[0]) default: // Go on.
case 0: log.Debug("dhcpv4: no ipv4 address for interface %s", iface.Name) return nil case 1: // Some Android devices use 8.8.8.8 if there is no secondary DNS // server. Fix that by setting the secondary DNS address to our // address as well. // // See https://github.com/AdguardTeam/AdGuardHome/issues/1708. log.Debug("dhcpv4: setting secondary dns ip to iself for interface %s", iface.Name) dnsIPAddrs = append(dnsIPAddrs, dnsIPAddrs[0]) default: // Go on. } s.conf.dnsIPAddrs = dnsIPAddrs laddr := &net.UDPAddr{ IP: net.ParseIP("0.0.0.0"),
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v4.go
default: // Go on. } laddr := &net.UDPAddr{ IP: net.ParseIP("0.0.0.0"), Port: dhcpv4.ServerPort, } s.srv, err = server4.NewServer(iface.Name, laddr, s.packetHandler, server4.WithDebugLogger())
</s> remove s.conf.dnsIPAddrs = getIfaceIPv4(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("dhcpv4: no IPv6 address for interface %s", iface.Name) </s> add dnsIPAddrs, err := ifaceIPv4Addrs(iface) if err != nil { return fmt.Errorf("dhcpv4: getting ipv4 addrs for iface %s: %w", ifaceName, err) } switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv4: no ipv4 address for interface %s", iface.Name) </s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server.
s.conf.dnsIPAddrs = dnsIPAddrs
default: // Go on. } s.conf.dnsIPAddrs = dnsIPAddrs laddr := &net.UDPAddr{ IP: net.ParseIP("0.0.0.0"), Port: dhcpv4.ServerPort, } s.srv, err = server4.NewServer(iface.Name, laddr, s.packetHandler, server4.WithDebugLogger())
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v4.go
return } } // Get IPv6 address list func getIfaceIPv6(iface net.Interface) []net.IP { addrs, err := iface.Addrs() if err != nil { return nil }
</s> remove return nil </s> add return nil, err </s> remove // Get IPv4 address list func getIfaceIPv4(iface net.Interface) []net.IP { addrs, err := iface.Addrs() if err != nil { return nil } var res []net.IP for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ipnet.IP.To4() != nil { res = append(res, ipnet.IP.To4()) } } return res } </s> add </s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server. </s> remove var res []net.IP </s> add </s> remove ifaceIPNet := getIfaceIPv6(*iface) </s> add ifaceIPNet, err := ifaceIPv6Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv6 addrs for iface %s: %w", ifaceName, err) }
// ifaceIPv6Addrs returns the interface's IPv6 addresses. func ifaceIPv6Addrs(iface *net.Interface) (ips []net.IP, err error) {
return } } // ifaceIPv6Addrs returns the interface's IPv6 addresses. func ifaceIPv6Addrs(iface *net.Interface) (ips []net.IP, err error) { // ifaceIPv6Addrs returns the interface's IPv6 addresses. func ifaceIPv6Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v6.go
// Get IPv6 address list func getIfaceIPv6(iface net.Interface) []net.IP { addrs, err := iface.Addrs() if err != nil { return nil } var res []net.IP for _, a := range addrs { ipnet, ok := a.(*net.IPNet)
</s> remove // Get IPv4 address list func getIfaceIPv4(iface net.Interface) []net.IP { addrs, err := iface.Addrs() if err != nil { return nil } var res []net.IP for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ipnet.IP.To4() != nil { res = append(res, ipnet.IP.To4()) } } return res } </s> add </s> remove var res []net.IP </s> add </s> remove // Get IPv6 address list func getIfaceIPv6(iface net.Interface) []net.IP { </s> add // ifaceIPv6Addrs returns the interface's IPv6 addresses. func ifaceIPv6Addrs(iface *net.Interface) (ips []net.IP, err error) { </s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server. </s> remove if ipnet.IP.To4() == nil { res = append(res, ipnet.IP) </s> add if ip := ipnet.IP.To16(); ip != nil { ips = append(ips, ip)
return nil, err
// Get IPv6 address list func getIfaceIPv6(iface net.Interface) []net.IP { addrs, err := iface.Addrs() if err != nil { return nil, err } var res []net.IP for _, a := range addrs { ipnet, ok := a.(*net.IPNet)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v6.go
if err != nil { return nil } var res []net.IP for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue }
</s> remove return nil </s> add return nil, err </s> remove // Get IPv4 address list func getIfaceIPv4(iface net.Interface) []net.IP { addrs, err := iface.Addrs() if err != nil { return nil } var res []net.IP for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ipnet.IP.To4() != nil { res = append(res, ipnet.IP.To4()) } } return res } </s> add </s> remove if ipnet.IP.To4() == nil { res = append(res, ipnet.IP) </s> add if ip := ipnet.IP.To16(); ip != nil { ips = append(ips, ip) </s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server. </s> remove // wait for answer log.Tracef("Waiting %v for an answer", defaultDiscoverTime) // TODO: replicate dhclient's behaviour of retrying several times with progressively bigger timeouts b := make([]byte, 1500) _ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime)) n, _, err := c.ReadFrom(b) if isTimeout(err) { // timed out -- no DHCP servers log.Debug("DHCPv4: didn't receive DHCP response") return false, nil </s> add ok, next, err := tryConn(req, c, iface) if next { continue } if ok { return true, nil
if err != nil { return nil } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v6.go
ipnet, ok := a.(*net.IPNet) if !ok { continue } if ipnet.IP.To4() == nil { res = append(res, ipnet.IP) } } return res }
</s> remove // Get IPv4 address list func getIfaceIPv4(iface net.Interface) []net.IP { addrs, err := iface.Addrs() if err != nil { return nil } var res []net.IP for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ipnet.IP.To4() != nil { res = append(res, ipnet.IP.To4()) } } return res } </s> add </s> remove var res []net.IP </s> add </s> remove return res </s> add return ips, nil </s> remove return nil </s> add return nil, err </s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server.
if ip := ipnet.IP.To16(); ip != nil { ips = append(ips, ip)
ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To16(); ip != nil { ips = append(ips, ip) if ip := ipnet.IP.To16(); ip != nil { ips = append(ips, ip) } } return res }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v6.go
if ipnet.IP.To4() == nil { res = append(res, ipnet.IP) } } return res } // initialize RA module func (s *v6Server) initRA(iface *net.Interface) error { // choose the source IP address - should be link-local-unicast
</s> remove if ipnet.IP.To4() == nil { res = append(res, ipnet.IP) </s> add if ip := ipnet.IP.To16(); ip != nil { ips = append(ips, ip) </s> remove // Get IPv4 address list func getIfaceIPv4(iface net.Interface) []net.IP { addrs, err := iface.Addrs() if err != nil { return nil } var res []net.IP for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ipnet.IP.To4() != nil { res = append(res, ipnet.IP.To4()) } } return res } </s> add </s> remove // Start - start server </s> add // Start starts the IPv6 DHCP server. </s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server. </s> remove // Get IPv6 address list func getIfaceIPv6(iface net.Interface) []net.IP { </s> add // ifaceIPv6Addrs returns the interface's IPv6 addresses. func ifaceIPv6Addrs(iface *net.Interface) (ips []net.IP, err error) {
return ips, nil
if ipnet.IP.To4() == nil { res = append(res, ipnet.IP) } } return ips, nil } // initialize RA module func (s *v6Server) initRA(iface *net.Interface) error { // choose the source IP address - should be link-local-unicast
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v6.go
s.ra.packetSendPeriod = 1 * time.Second return s.ra.Init() } // Start - start server func (s *v6Server) Start() error { if !s.conf.Enabled { return nil }
</s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server. </s> remove return res </s> add return ips, nil </s> remove // Get IPv4 address list func getIfaceIPv4(iface net.Interface) []net.IP { addrs, err := iface.Addrs() if err != nil { return nil } var res []net.IP for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ipnet.IP.To4() != nil { res = append(res, ipnet.IP.To4()) } } return res } </s> add </s> remove iface, err := net.InterfaceByName(s.conf.InterfaceName) </s> add ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) </s> remove iface, err := net.InterfaceByName(s.conf.InterfaceName) </s> add ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) if err != nil { return fmt.Errorf("dhcpv6: finding interface %s by name: %w", ifaceName, err) } log.Debug("dhcpv4: starting...") dnsIPAddrs, err := ifaceIPv6Addrs(iface)
// Start starts the IPv6 DHCP server.
s.ra.packetSendPeriod = 1 * time.Second return s.ra.Init() } // Start starts the IPv6 DHCP server. func (s *v6Server) Start() error { if !s.conf.Enabled { return nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v6.go
if !s.conf.Enabled { return nil } iface, err := net.InterfaceByName(s.conf.InterfaceName) if err != nil { return fmt.Errorf("couldn't find interface by name %s: %w", s.conf.InterfaceName, err) } s.conf.dnsIPAddrs = getIfaceIPv6(*iface)
</s> remove iface, err := net.InterfaceByName(s.conf.InterfaceName) </s> add ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) </s> remove return fmt.Errorf("couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv6: getting ipv6 addrs for iface %s: %w", ifaceName, err) </s> remove return fmt.Errorf("dhcpv4: Couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv4: finding interface %s by name: %w", ifaceName, err) </s> remove s.conf.dnsIPAddrs = getIfaceIPv6(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("DHCPv6: no IPv6 address for interface %s", iface.Name) </s> add switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv6: no ipv6 address for interface %s", iface.Name) </s> remove // get ipv4 address of an interface ifaceIPNet := getIfaceIPv4(*iface) </s> add ifaceIPNet, err := ifaceIPv4Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv4 addrs for iface %s: %w", ifaceName, err) }
ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) if err != nil { return fmt.Errorf("dhcpv6: finding interface %s by name: %w", ifaceName, err) } log.Debug("dhcpv4: starting...") dnsIPAddrs, err := ifaceIPv6Addrs(iface)
if !s.conf.Enabled { return nil } ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) if err != nil { return fmt.Errorf("dhcpv6: finding interface %s by name: %w", ifaceName, err) } log.Debug("dhcpv4: starting...") dnsIPAddrs, err := ifaceIPv6Addrs(iface) if err != nil { return fmt.Errorf("couldn't find interface by name %s: %w", s.conf.InterfaceName, err) } s.conf.dnsIPAddrs = getIfaceIPv6(*iface)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v6.go
} iface, err := net.InterfaceByName(s.conf.InterfaceName) if err != nil { return fmt.Errorf("couldn't find interface by name %s: %w", s.conf.InterfaceName, err) } s.conf.dnsIPAddrs = getIfaceIPv6(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("DHCPv6: no IPv6 address for interface %s", iface.Name)
</s> remove s.conf.dnsIPAddrs = getIfaceIPv6(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("DHCPv6: no IPv6 address for interface %s", iface.Name) </s> add switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv6: no ipv6 address for interface %s", iface.Name) </s> remove return fmt.Errorf("dhcpv4: Couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv4: finding interface %s by name: %w", ifaceName, err) </s> remove iface, err := net.InterfaceByName(s.conf.InterfaceName) </s> add ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) if err != nil { return fmt.Errorf("dhcpv6: finding interface %s by name: %w", ifaceName, err) } log.Debug("dhcpv4: starting...") dnsIPAddrs, err := ifaceIPv6Addrs(iface) </s> remove s.conf.dnsIPAddrs = getIfaceIPv4(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("dhcpv4: no IPv6 address for interface %s", iface.Name) </s> add dnsIPAddrs, err := ifaceIPv4Addrs(iface) if err != nil { return fmt.Errorf("dhcpv4: getting ipv4 addrs for iface %s: %w", ifaceName, err) } switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv4: no ipv4 address for interface %s", iface.Name) </s> remove iface, err := net.InterfaceByName(s.conf.InterfaceName) </s> add ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName)
return fmt.Errorf("dhcpv6: getting ipv6 addrs for iface %s: %w", ifaceName, err)
} iface, err := net.InterfaceByName(s.conf.InterfaceName) if err != nil { return fmt.Errorf("dhcpv6: getting ipv6 addrs for iface %s: %w", ifaceName, err) } s.conf.dnsIPAddrs = getIfaceIPv6(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("DHCPv6: no IPv6 address for interface %s", iface.Name)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v6.go
if err != nil { return fmt.Errorf("couldn't find interface by name %s: %w", s.conf.InterfaceName, err) } s.conf.dnsIPAddrs = getIfaceIPv6(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("DHCPv6: no IPv6 address for interface %s", iface.Name) return nil } err = s.initRA(iface) if err != nil {
</s> remove return fmt.Errorf("couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv6: getting ipv6 addrs for iface %s: %w", ifaceName, err) </s> remove s.conf.dnsIPAddrs = getIfaceIPv4(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("dhcpv4: no IPv6 address for interface %s", iface.Name) </s> add dnsIPAddrs, err := ifaceIPv4Addrs(iface) if err != nil { return fmt.Errorf("dhcpv4: getting ipv4 addrs for iface %s: %w", ifaceName, err) } switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv4: no ipv4 address for interface %s", iface.Name) </s> remove iface, err := net.InterfaceByName(s.conf.InterfaceName) </s> add ifaceName := s.conf.InterfaceName iface, err := net.InterfaceByName(ifaceName) if err != nil { return fmt.Errorf("dhcpv6: finding interface %s by name: %w", ifaceName, err) } log.Debug("dhcpv4: starting...") dnsIPAddrs, err := ifaceIPv6Addrs(iface) </s> remove return fmt.Errorf("dhcpv4: Couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv4: finding interface %s by name: %w", ifaceName, err) </s> remove // get ipv4 address of an interface ifaceIPNet := getIfaceIPv4(*iface) </s> add ifaceIPNet, err := ifaceIPv4Addrs(iface) if err != nil { return false, fmt.Errorf("getting ipv4 addrs for iface %s: %w", ifaceName, err) }
switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv6: no ipv6 address for interface %s", iface.Name)
if err != nil { return fmt.Errorf("couldn't find interface by name %s: %w", s.conf.InterfaceName, err) } switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv6: no ipv6 address for interface %s", iface.Name) switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv6: no ipv6 address for interface %s", iface.Name) switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv6: no ipv6 address for interface %s", iface.Name) return nil } err = s.initRA(iface) if err != nil {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v6.go
case 0: log.Debug("dhcpv6: no ipv6 address for interface %s", iface.Name) return nil } s.conf.dnsIPAddrs = dnsIPAddrs err = s.initRA(iface)
</s> remove s.conf.dnsIPAddrs = getIfaceIPv6(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("DHCPv6: no IPv6 address for interface %s", iface.Name) </s> add switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv6: no ipv6 address for interface %s", iface.Name) </s> remove s.conf.dnsIPAddrs = getIfaceIPv4(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("dhcpv4: no IPv6 address for interface %s", iface.Name) </s> add dnsIPAddrs, err := ifaceIPv4Addrs(iface) if err != nil { return fmt.Errorf("dhcpv4: getting ipv4 addrs for iface %s: %w", ifaceName, err) } switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv4: no ipv4 address for interface %s", iface.Name) </s> remove return fmt.Errorf("couldn't find interface by name %s: %w", s.conf.InterfaceName, err) </s> add return fmt.Errorf("dhcpv6: getting ipv6 addrs for iface %s: %w", ifaceName, err)
case 1: // See the comment in (*v4Server).Start. log.Debug("dhcpv6: setting secondary dns ip to iself for interface %s", iface.Name) dnsIPAddrs = append(dnsIPAddrs, dnsIPAddrs[0]) default: // Go on.
case 0: log.Debug("dhcpv6: no ipv6 address for interface %s", iface.Name) return nil case 1: // See the comment in (*v4Server).Start. log.Debug("dhcpv6: setting secondary dns ip to iself for interface %s", iface.Name) dnsIPAddrs = append(dnsIPAddrs, dnsIPAddrs[0]) default: // Go on. } s.conf.dnsIPAddrs = dnsIPAddrs err = s.initRA(iface)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v6.go
default: // Go on. } err = s.initRA(iface) if err != nil { return err }
</s> remove s.conf.dnsIPAddrs = getIfaceIPv6(*iface) if len(s.conf.dnsIPAddrs) == 0 { log.Debug("DHCPv6: no IPv6 address for interface %s", iface.Name) </s> add switch len(dnsIPAddrs) { case 0: log.Debug("dhcpv6: no ipv6 address for interface %s", iface.Name) </s> remove // Start - start server </s> add // ifaceIPv4Addrs returns the interface's IPv4 addresses. func ifaceIPv4Addrs(iface *net.Interface) (ips []net.IP, err error) { addrs, err := iface.Addrs() if err != nil { return nil, err } for _, a := range addrs { ipnet, ok := a.(*net.IPNet) if !ok { continue } if ip := ipnet.IP.To4(); ip != nil { ips = append(ips, ip) } } return ips, nil } // Start starts the IPv4 DHCP server. </s> remove // Get IPv6 address list func getIfaceIPv6(iface net.Interface) []net.IP { </s> add // ifaceIPv6Addrs returns the interface's IPv6 addresses. func ifaceIPv6Addrs(iface *net.Interface) (ips []net.IP, err error) {
s.conf.dnsIPAddrs = dnsIPAddrs
default: // Go on. } s.conf.dnsIPAddrs = dnsIPAddrs err = s.initRA(iface) if err != nil { return err }
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: * dhcpd: send secondary dns as well Merge in DNS/adguard-home from 1708-secondary-dns to master Updates #1708. Squashed commit of the following: commit 4529452e31131763f00c9c834cc95638f1a3d142 Author: Ainar Garipov <[email protected]> Date: Mon Nov 9 18:12:57 2020 +0300 * dhcpd: send secondary dns as well
https://github.com/AdguardTeam/AdGuardHome/commit/3cc5bf210d432ef1c75e25fba8f7bb20d8e213b9
internal/dhcpd/v6.go
if client == nil || serverInfo == nil || (serverInfo != nil && serverInfo.ServerCert.NotAfter < now) { p.Lock() // Using "udp" for DNSCrypt upstreams by default client = &dnscrypt.Client{Proto: "udp", Timeout: defaultTimeout} si, _, err := client.Dial(p.boot.address) if err != nil { p.Unlock() return nil, errorx.Decorate(err, "Failed to fetch certificate info from %s", p.Address())
</s> remove golang.org/x/net v0.0.0-20181213202711-891ebc4b82d6 </s> add golang.org/x/net v0.0.0-20181217023233-e147a9138326 golang.org/x/sys v0.0.0-20181217223516-dcdaa6325bcb // indirect </s> remove github.com/ameshkov/dnscrypt v0.0.0-20181217090431-1215bb8b150f </s> add github.com/ameshkov/dnscrypt v1.0.0
client = &dnscrypt.Client{Timeout: defaultTimeout, AdjustPayloadSize: true}
if client == nil || serverInfo == nil || (serverInfo != nil && serverInfo.ServerCert.NotAfter < now) { p.Lock() // Using "udp" for DNSCrypt upstreams by default client = &dnscrypt.Client{Timeout: defaultTimeout, AdjustPayloadSize: true} si, _, err := client.Dial(p.boot.address) if err != nil { p.Unlock() return nil, errorx.Decorate(err, "Failed to fetch certificate info from %s", p.Address())
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
upgrade dnscrypt client to v1.0.0
https://github.com/AdguardTeam/AdGuardHome/commit/3d179079661e3c97041a8448ec3aecea40199032
dnsforward/upstream.go
module github.com/AdguardTeam/AdGuardHome require ( github.com/StackExchange/wmi v0.0.0-20180725035823-b12b22c5341f // indirect github.com/ameshkov/dnscrypt v0.0.0-20181217090431-1215bb8b150f github.com/beefsack/go-rate v0.0.0-20180408011153-efa7637bb9b6 github.com/bluele/gcache v0.0.0-20171010155617-472614239ac7 github.com/go-ole/go-ole v1.2.1 // indirect github.com/go-test/deep v1.0.1 github.com/gobuffalo/packr v1.19.0
</s> remove golang.org/x/net v0.0.0-20181213202711-891ebc4b82d6 </s> add golang.org/x/net v0.0.0-20181217023233-e147a9138326 golang.org/x/sys v0.0.0-20181217223516-dcdaa6325bcb // indirect </s> remove client = &dnscrypt.Client{Proto: "udp", Timeout: defaultTimeout} </s> add client = &dnscrypt.Client{Timeout: defaultTimeout, AdjustPayloadSize: true}
github.com/ameshkov/dnscrypt v1.0.0
module github.com/AdguardTeam/AdGuardHome require ( github.com/StackExchange/wmi v0.0.0-20180725035823-b12b22c5341f // indirect github.com/ameshkov/dnscrypt v1.0.0 github.com/beefsack/go-rate v0.0.0-20180408011153-efa7637bb9b6 github.com/bluele/gcache v0.0.0-20171010155617-472614239ac7 github.com/go-ole/go-ole v1.2.1 // indirect github.com/go-test/deep v1.0.1 github.com/gobuffalo/packr v1.19.0
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
upgrade dnscrypt client to v1.0.0
https://github.com/AdguardTeam/AdGuardHome/commit/3d179079661e3c97041a8448ec3aecea40199032
go.mod
github.com/shirou/gopsutil v2.18.10+incompatible github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect go.uber.org/goleak v0.10.0 golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 golang.org/x/net v0.0.0-20181213202711-891ebc4b82d6 gopkg.in/asaskevich/govalidator.v4 v4.0.0-20160518190739-766470278477 gopkg.in/yaml.v2 v2.2.1 )
</s> remove github.com/ameshkov/dnscrypt v0.0.0-20181217090431-1215bb8b150f </s> add github.com/ameshkov/dnscrypt v1.0.0 </s> remove client = &dnscrypt.Client{Proto: "udp", Timeout: defaultTimeout} </s> add client = &dnscrypt.Client{Timeout: defaultTimeout, AdjustPayloadSize: true}
golang.org/x/net v0.0.0-20181217023233-e147a9138326 golang.org/x/sys v0.0.0-20181217223516-dcdaa6325bcb // indirect
github.com/shirou/gopsutil v2.18.10+incompatible github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect go.uber.org/goleak v0.10.0 golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 golang.org/x/net v0.0.0-20181217023233-e147a9138326 golang.org/x/sys v0.0.0-20181217223516-dcdaa6325bcb // indirect gopkg.in/asaskevich/govalidator.v4 v4.0.0-20160518190739-766470278477 gopkg.in/yaml.v2 v2.2.1 )
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ]
upgrade dnscrypt client to v1.0.0
https://github.com/AdguardTeam/AdGuardHome/commit/3d179079661e3c97041a8448ec3aecea40199032
go.mod
github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635/go.mod h1:lmLxL+FV291OopO93Bwf9fQLQeLyt33VJRUg5VJ30us= github.com/ameshkov/dnscrypt v0.0.0-20181217090431-1215bb8b150f h1:vOaSvI9B3wqzV1g8raDeVzRJnq5RHQxsz0MVXudxdNU= github.com/ameshkov/dnscrypt v0.0.0-20181217090431-1215bb8b150f/go.mod h1:EC7Z1GguyEEwhuLXrcgkRTE3GdyPDSWq2OXefhydGWo= github.com/beefsack/go-rate v0.0.0-20180408011153-efa7637bb9b6 h1:KXlsf+qt/X5ttPGEjR0tPH1xaWWoKBEg9Q1THAj2h3I= github.com/beefsack/go-rate v0.0.0-20180408011153-efa7637bb9b6/go.mod h1:6YNgTHLutezwnBvyneBbwvB8C82y3dcoOj5EQJIdGXA= github.com/bluele/gcache v0.0.0-20171010155617-472614239ac7 h1:NpQ+gkFOH27AyDypSCJ/LdsIi/b4rdnEb1N5+IpFfYs= github.com/bluele/gcache v0.0.0-20171010155617-472614239ac7/go.mod h1:8c4/i2VlovMO2gBnHGQPN5EJw+H0lx1u/5p+cgsXtCk= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
</s> remove github.com/ameshkov/dnscrypt v0.0.0-20181217090431-1215bb8b150f </s> add github.com/ameshkov/dnscrypt v1.0.0 </s> remove golang.org/x/net v0.0.0-20181213202711-891ebc4b82d6 </s> add golang.org/x/net v0.0.0-20181217023233-e147a9138326 golang.org/x/sys v0.0.0-20181217223516-dcdaa6325bcb // indirect </s> remove client = &dnscrypt.Client{Proto: "udp", Timeout: defaultTimeout} </s> add client = &dnscrypt.Client{Timeout: defaultTimeout, AdjustPayloadSize: true}
github.com/ameshkov/dnscrypt v1.0.0 h1:Y7YexPCxtVCTDXlXu9n17+1H5YS25vftx8vV8Dhuu+E= github.com/ameshkov/dnscrypt v1.0.0/go.mod h1:EC7Z1GguyEEwhuLXrcgkRTE3GdyPDSWq2OXefhydGWo=
github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635/go.mod h1:lmLxL+FV291OopO93Bwf9fQLQeLyt33VJRUg5VJ30us= github.com/ameshkov/dnscrypt v0.0.0-20181217090431-1215bb8b150f h1:vOaSvI9B3wqzV1g8raDeVzRJnq5RHQxsz0MVXudxdNU= github.com/ameshkov/dnscrypt v0.0.0-20181217090431-1215bb8b150f/go.mod h1:EC7Z1GguyEEwhuLXrcgkRTE3GdyPDSWq2OXefhydGWo= github.com/ameshkov/dnscrypt v1.0.0 h1:Y7YexPCxtVCTDXlXu9n17+1H5YS25vftx8vV8Dhuu+E= github.com/ameshkov/dnscrypt v1.0.0/go.mod h1:EC7Z1GguyEEwhuLXrcgkRTE3GdyPDSWq2OXefhydGWo= github.com/beefsack/go-rate v0.0.0-20180408011153-efa7637bb9b6 h1:KXlsf+qt/X5ttPGEjR0tPH1xaWWoKBEg9Q1THAj2h3I= github.com/beefsack/go-rate v0.0.0-20180408011153-efa7637bb9b6/go.mod h1:6YNgTHLutezwnBvyneBbwvB8C82y3dcoOj5EQJIdGXA= github.com/bluele/gcache v0.0.0-20171010155617-472614239ac7 h1:NpQ+gkFOH27AyDypSCJ/LdsIi/b4rdnEb1N5+IpFfYs= github.com/bluele/gcache v0.0.0-20171010155617-472614239ac7/go.mod h1:8c4/i2VlovMO2gBnHGQPN5EJw+H0lx1u/5p+cgsXtCk= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
upgrade dnscrypt client to v1.0.0
https://github.com/AdguardTeam/AdGuardHome/commit/3d179079661e3c97041a8448ec3aecea40199032
go.sum
golang.org/x/net v0.0.0-20181213202711-891ebc4b82d6 h1:gT0Y6H7hbVPUtvtk0YGxMXPgN+p8fYlqWkgJeUCZcaQ= golang.org/x/net v0.0.0-20181213202711-891ebc4b82d6/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20181213200352-4d1cda033e06 h1:0oC8rFnE+74kEmuHZ46F6KHsMr5Gx2gUQPuNz28iQZM=
</s> remove golang.org/x/net v0.0.0-20181213202711-891ebc4b82d6 </s> add golang.org/x/net v0.0.0-20181217023233-e147a9138326 golang.org/x/sys v0.0.0-20181217223516-dcdaa6325bcb // indirect </s> remove github.com/ameshkov/dnscrypt v0.0.0-20181217090431-1215bb8b150f </s> add github.com/ameshkov/dnscrypt v1.0.0 </s> remove client = &dnscrypt.Client{Proto: "udp", Timeout: defaultTimeout} </s> add client = &dnscrypt.Client{Timeout: defaultTimeout, AdjustPayloadSize: true}
golang.org/x/net v0.0.0-20181217023233-e147a9138326 h1:iCzOf0xz39Tstp+Tu/WwyGjUXCk34QhQORRxBeXXTA4= golang.org/x/net v0.0.0-20181217023233-e147a9138326/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181213202711-891ebc4b82d6 h1:gT0Y6H7hbVPUtvtk0YGxMXPgN+p8fYlqWkgJeUCZcaQ= golang.org/x/net v0.0.0-20181213202711-891ebc4b82d6/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181217023233-e147a9138326 h1:iCzOf0xz39Tstp+Tu/WwyGjUXCk34QhQORRxBeXXTA4= golang.org/x/net v0.0.0-20181217023233-e147a9138326/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20181213200352-4d1cda033e06 h1:0oC8rFnE+74kEmuHZ46F6KHsMr5Gx2gUQPuNz28iQZM=
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
upgrade dnscrypt client to v1.0.0
https://github.com/AdguardTeam/AdGuardHome/commit/3d179079661e3c97041a8448ec3aecea40199032
go.sum
golang.org/x/sys v0.0.0-20181213200352-4d1cda033e06 h1:0oC8rFnE+74kEmuHZ46F6KHsMr5Gx2gUQPuNz28iQZM= golang.org/x/sys v0.0.0-20181213200352-4d1cda033e06/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= gopkg.in/asaskevich/govalidator.v4 v4.0.0-20160518190739-766470278477 h1:5xUJw+lg4zao9W4HIDzlFbMYgSgtvNVHh00MEHvbGpQ= gopkg.in/asaskevich/govalidator.v4 v4.0.0-20160518190739-766470278477/go.mod h1:QDV1vrFSrowdoOba0UM8VJPUZONT7dnfdLsM+GG53Z8= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
</s> remove golang.org/x/net v0.0.0-20181213202711-891ebc4b82d6 </s> add golang.org/x/net v0.0.0-20181217023233-e147a9138326 golang.org/x/sys v0.0.0-20181217223516-dcdaa6325bcb // indirect </s> remove github.com/ameshkov/dnscrypt v0.0.0-20181217090431-1215bb8b150f </s> add github.com/ameshkov/dnscrypt v1.0.0 </s> remove client = &dnscrypt.Client{Proto: "udp", Timeout: defaultTimeout} </s> add client = &dnscrypt.Client{Timeout: defaultTimeout, AdjustPayloadSize: true}
golang.org/x/sys v0.0.0-20181217223516-dcdaa6325bcb h1:zzdd4xkMwu/GRxhSUJaCPh4/jil9kAbsU7AUmXboO+A= golang.org/x/sys v0.0.0-20181217223516-dcdaa6325bcb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181213200352-4d1cda033e06 h1:0oC8rFnE+74kEmuHZ46F6KHsMr5Gx2gUQPuNz28iQZM= golang.org/x/sys v0.0.0-20181213200352-4d1cda033e06/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181217223516-dcdaa6325bcb h1:zzdd4xkMwu/GRxhSUJaCPh4/jil9kAbsU7AUmXboO+A= golang.org/x/sys v0.0.0-20181217223516-dcdaa6325bcb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= gopkg.in/asaskevich/govalidator.v4 v4.0.0-20160518190739-766470278477 h1:5xUJw+lg4zao9W4HIDzlFbMYgSgtvNVHh00MEHvbGpQ= gopkg.in/asaskevich/govalidator.v4 v4.0.0-20160518190739-766470278477/go.mod h1:QDV1vrFSrowdoOba0UM8VJPUZONT7dnfdLsM+GG53Z8= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
upgrade dnscrypt client to v1.0.0
https://github.com/AdguardTeam/AdGuardHome/commit/3d179079661e3c97041a8448ec3aecea40199032
go.sum
log.Debug("Clients: set WHOIS info for auto-client %s: %v", ch.Host, ch.WhoisInfo) return } ch = &ClientHost{ Source: ClientSourceWHOIS, } ch.WhoisInfo = info clients.ipHost[ip] = ch log.Debug("Clients: set WHOIS info for auto-client with IP %s: %v", ip, ch.WhoisInfo)
</s> remove IDs: []string{"1.1.1.1", "1:2:3::4", "aa:aa:aa:aa:aa:aa"}, </s> add IDs: []string{"1.1.1.1", "1:2:3::4", "aa:aa:aa:aa:aa:aa", "2.2.2.0/24"},
// Create a ClientHost implicitly so that we don't do this check again
log.Debug("Clients: set WHOIS info for auto-client %s: %v", ch.Host, ch.WhoisInfo) return } // Create a ClientHost implicitly so that we don't do this check again ch = &ClientHost{ Source: ClientSourceWHOIS, } ch.WhoisInfo = info clients.ipHost[ip] = ch log.Debug("Clients: set WHOIS info for auto-client with IP %s: %v", ip, ch.WhoisInfo)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
-: add one more test
https://github.com/AdguardTeam/AdGuardHome/commit/3dd91cf17962b4b5d39f31424adeeab579416666
home/clients.go
testIP := "1.2.3.4" // add a client c = Client{ IDs: []string{"1.1.1.1", "1:2:3::4", "aa:aa:aa:aa:aa:aa"}, Name: "client1", } ok, err := clients.Add(c) assert.True(t, ok) assert.Nil(t, err)
</s>
IDs: []string{"1.1.1.1", "1:2:3::4", "aa:aa:aa:aa:aa:aa", "2.2.2.0/24"},
testIP := "1.2.3.4" // add a client c = Client{ IDs: []string{"1.1.1.1", "1:2:3::4", "aa:aa:aa:aa:aa:aa", "2.2.2.0/24"}, Name: "client1", } ok, err := clients.Add(c) assert.True(t, ok) assert.Nil(t, err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
-: add one more test
https://github.com/AdguardTeam/AdGuardHome/commit/3dd91cf17962b4b5d39f31424adeeab579416666
home/clients_test.go
// try adding a duplicate IP which for a Mac-based client ok, err = clients.AddHost(testIP, "test", ClientSourceRDNS) assert.False(t, ok) assert.Nil(t, err) }
</s> remove IDs: []string{"1.1.1.1", "1:2:3::4", "aa:aa:aa:aa:aa:aa"}, </s> add IDs: []string{"1.1.1.1", "1:2:3::4", "aa:aa:aa:aa:aa:aa", "2.2.2.0/24"},
// don't allow duplicates by CIDR ok, err = clients.AddHost("2.2.2.2", "test", ClientSourceRDNS) assert.False(t, ok) assert.Nil(t, err)
// try adding a duplicate IP which for a Mac-based client ok, err = clients.AddHost(testIP, "test", ClientSourceRDNS) assert.False(t, ok) assert.Nil(t, err) // don't allow duplicates by CIDR ok, err = clients.AddHost("2.2.2.2", "test", ClientSourceRDNS) assert.False(t, ok) assert.Nil(t, err) }
[ "keep", "keep", "keep", "add", "keep" ]
-: add one more test
https://github.com/AdguardTeam/AdGuardHome/commit/3dd91cf17962b4b5d39f31424adeeab579416666
home/clients_test.go
// Package dnsforward contains a DNS forwarding server. package dnsforward import ( "fmt" "net" "net/http" "os" "runtime"
</s> remove // ipset cannot be initialized in a Snap version (and maybe - without root) // this needs to be handled properly // TODO: Handle this properly log.Info("Cannot initialize ipset module due to %v", err) </s> add if !errors.Is(err, os.ErrPermission) { return fmt.Errorf("cannot initialize ipset: %w", err) } // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions. // // Log and go on. log.Error("cannot initialize ipset: %s", err)
"errors"
// Package dnsforward contains a DNS forwarding server. package dnsforward import ( "errors" "fmt" "net" "net/http" "os" "runtime"
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: dnsforward: imp ipset caching, logging, and eperm handling Merge in DNS/adguard-home from ipset-fix to master Updates #2619. Squashed commit of the following: commit 6939c823598b1e74cb3d991aad1b928547fd26a9 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 16:55:14 2021 +0300 dnsforward: imp code commit 99e3a7c30b79d7929ddd9b700d7dd3d2683ec6d2 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 15:52:12 2021 +0300 dnsforward: imp ipset caching, logging, and eperm handling
https://github.com/AdguardTeam/AdGuardHome/commit/3e0238aa99c18fe5eae1a4a122f43daf8918bd75
internal/dnsforward/dnsforward.go
"errors" "fmt" "net" "net/http" "runtime" "sync" "time" "github.com/AdguardTeam/AdGuardHome/internal/dhcpd" "github.com/AdguardTeam/AdGuardHome/internal/dnsfilter"
</s> remove var err error </s> add
"os"
"errors" "fmt" "net" "net/http" "os" "runtime" "sync" "time" "github.com/AdguardTeam/AdGuardHome/internal/dhcpd" "github.com/AdguardTeam/AdGuardHome/internal/dnsfilter"
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: dnsforward: imp ipset caching, logging, and eperm handling Merge in DNS/adguard-home from ipset-fix to master Updates #2619. Squashed commit of the following: commit 6939c823598b1e74cb3d991aad1b928547fd26a9 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 16:55:14 2021 +0300 dnsforward: imp code commit 99e3a7c30b79d7929ddd9b700d7dd3d2683ec6d2 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 15:52:12 2021 +0300 dnsforward: imp ipset caching, logging, and eperm handling
https://github.com/AdguardTeam/AdGuardHome/commit/3e0238aa99c18fe5eae1a4a122f43daf8918bd75
internal/dnsforward/dnsforward.go
// Initialize IPSET configuration // -- err := s.ipset.init(s.conf.IPSETList) if err != nil { // ipset cannot be initialized in a Snap version (and maybe - without root) // this needs to be handled properly // TODO: Handle this properly log.Info("Cannot initialize ipset module due to %v", err) } // Prepare DNS servers settings // -- err = s.prepareUpstreamSettings()
</s> remove var err error </s> add
if !errors.Is(err, os.ErrPermission) { return fmt.Errorf("cannot initialize ipset: %w", err) } // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions. // // Log and go on. log.Error("cannot initialize ipset: %s", err)
// Initialize IPSET configuration // -- err := s.ipset.init(s.conf.IPSETList) if err != nil { if !errors.Is(err, os.ErrPermission) { return fmt.Errorf("cannot initialize ipset: %w", err) } // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions. // // Log and go on. log.Error("cannot initialize ipset: %s", err) if !errors.Is(err, os.ErrPermission) { return fmt.Errorf("cannot initialize ipset: %w", err) } // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions. // // Log and go on. log.Error("cannot initialize ipset: %s", err) if !errors.Is(err, os.ErrPermission) { return fmt.Errorf("cannot initialize ipset: %w", err) } // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions. // // Log and go on. log.Error("cannot initialize ipset: %s", err) if !errors.Is(err, os.ErrPermission) { return fmt.Errorf("cannot initialize ipset: %w", err) } // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions. // // Log and go on. log.Error("cannot initialize ipset: %s", err) } // Prepare DNS servers settings // -- err = s.prepareUpstreamSettings()
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: dnsforward: imp ipset caching, logging, and eperm handling Merge in DNS/adguard-home from ipset-fix to master Updates #2619. Squashed commit of the following: commit 6939c823598b1e74cb3d991aad1b928547fd26a9 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 16:55:14 2021 +0300 dnsforward: imp code commit 99e3a7c30b79d7929ddd9b700d7dd3d2683ec6d2 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 15:52:12 2021 +0300 dnsforward: imp ipset caching, logging, and eperm handling
https://github.com/AdguardTeam/AdGuardHome/commit/3e0238aa99c18fe5eae1a4a122f43daf8918bd75
internal/dnsforward/dnsforward.go
nameToIpset map[string]ipsetProps domainToIpsets map[string][]ipsetProps addedIPs map[[16]byte]struct{} ipv4Conn *ipset.Conn ipv6Conn *ipset.Conn
</s> remove var err error </s> add
// TODO(a.garipov): Currently, the ipset list is static, and we don't // read the IPs already in sets, so we can assume that all incoming IPs // are either added to all corresponding ipsets or not. When that stops // being the case, for example if we add dynamic reconfiguration of // ipsets, this map will need to become a per-ipset-name one.
nameToIpset map[string]ipsetProps domainToIpsets map[string][]ipsetProps // TODO(a.garipov): Currently, the ipset list is static, and we don't // read the IPs already in sets, so we can assume that all incoming IPs // are either added to all corresponding ipsets or not. When that stops // being the case, for example if we add dynamic reconfiguration of // ipsets, this map will need to become a per-ipset-name one. addedIPs map[[16]byte]struct{} ipv4Conn *ipset.Conn ipv6Conn *ipset.Conn
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: dnsforward: imp ipset caching, logging, and eperm handling Merge in DNS/adguard-home from ipset-fix to master Updates #2619. Squashed commit of the following: commit 6939c823598b1e74cb3d991aad1b928547fd26a9 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 16:55:14 2021 +0300 dnsforward: imp code commit 99e3a7c30b79d7929ddd9b700d7dd3d2683ec6d2 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 15:52:12 2021 +0300 dnsforward: imp ipset caching, logging, and eperm handling
https://github.com/AdguardTeam/AdGuardHome/commit/3e0238aa99c18fe5eae1a4a122f43daf8918bd75
internal/dnsforward/ipset_linux.go
// process adds the resolved IP addresses to the domain's ipsets, if any. func (c *ipsetCtx) process(ctx *dnsContext) (rc resultCode) { if c == nil { return resultCodeSuccess }
</s> remove // ipset cannot be initialized in a Snap version (and maybe - without root) // this needs to be handled properly // TODO: Handle this properly log.Info("Cannot initialize ipset module due to %v", err) </s> add if !errors.Is(err, os.ErrPermission) { return fmt.Errorf("cannot initialize ipset: %w", err) } // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions. // // Log and go on. log.Error("cannot initialize ipset: %s", err)
var err error
// process adds the resolved IP addresses to the domain's ipsets, if any. func (c *ipsetCtx) process(ctx *dnsContext) (rc resultCode) { var err error if c == nil { return resultCodeSuccess }
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: dnsforward: imp ipset caching, logging, and eperm handling Merge in DNS/adguard-home from ipset-fix to master Updates #2619. Squashed commit of the following: commit 6939c823598b1e74cb3d991aad1b928547fd26a9 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 16:55:14 2021 +0300 dnsforward: imp code commit 99e3a7c30b79d7929ddd9b700d7dd3d2683ec6d2 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 15:52:12 2021 +0300 dnsforward: imp ipset caching, logging, and eperm handling
https://github.com/AdguardTeam/AdGuardHome/commit/3e0238aa99c18fe5eae1a4a122f43daf8918bd75
internal/dnsforward/ipset_linux.go
} c.mu.Lock() defer c.mu.Unlock() if c.skipIpsetProcessing(ctx) { log.Debug("ipset: skipped processing for request")
</s> remove var err error </s> add </s> remove // ipset cannot be initialized in a Snap version (and maybe - without root) // this needs to be handled properly // TODO: Handle this properly log.Info("Cannot initialize ipset module due to %v", err) </s> add if !errors.Is(err, os.ErrPermission) { return fmt.Errorf("cannot initialize ipset: %w", err) } // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions. // // Log and go on. log.Error("cannot initialize ipset: %s", err)
log.Debug("ipset: starting processing")
} log.Debug("ipset: starting processing") c.mu.Lock() defer c.mu.Unlock() if c.skipIpsetProcessing(ctx) { log.Debug("ipset: skipped processing for request")
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: dnsforward: imp ipset caching, logging, and eperm handling Merge in DNS/adguard-home from ipset-fix to master Updates #2619. Squashed commit of the following: commit 6939c823598b1e74cb3d991aad1b928547fd26a9 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 16:55:14 2021 +0300 dnsforward: imp code commit 99e3a7c30b79d7929ddd9b700d7dd3d2683ec6d2 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 15:52:12 2021 +0300 dnsforward: imp ipset caching, logging, and eperm handling
https://github.com/AdguardTeam/AdGuardHome/commit/3e0238aa99c18fe5eae1a4a122f43daf8918bd75
internal/dnsforward/ipset_linux.go
host = strings.TrimSuffix(host, ".") host = strings.ToLower(host) sets := c.lookupHost(host) if len(sets) == 0 { return resultCodeSuccess } log.Debug("ipset: found ipsets %+v for host %s", sets, host)
</s> remove var err error </s> add
log.Debug("ipset: no ipsets for host %s", host)
host = strings.TrimSuffix(host, ".") host = strings.ToLower(host) sets := c.lookupHost(host) if len(sets) == 0 { log.Debug("ipset: no ipsets for host %s", host) return resultCodeSuccess } log.Debug("ipset: found ipsets %+v for host %s", sets, host)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: dnsforward: imp ipset caching, logging, and eperm handling Merge in DNS/adguard-home from ipset-fix to master Updates #2619. Squashed commit of the following: commit 6939c823598b1e74cb3d991aad1b928547fd26a9 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 16:55:14 2021 +0300 dnsforward: imp code commit 99e3a7c30b79d7929ddd9b700d7dd3d2683ec6d2 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 15:52:12 2021 +0300 dnsforward: imp ipset caching, logging, and eperm handling
https://github.com/AdguardTeam/AdGuardHome/commit/3e0238aa99c18fe5eae1a4a122f43daf8918bd75
internal/dnsforward/ipset_linux.go
v4s = append(v4s, ip) } var err error setLoop: for _, set := range sets { switch set.family { case netfilter.ProtoIPv4: err = c.addIPs(host, set, v4s)
</s> remove // ipset cannot be initialized in a Snap version (and maybe - without root) // this needs to be handled properly // TODO: Handle this properly log.Info("Cannot initialize ipset module due to %v", err) </s> add if !errors.Is(err, os.ErrPermission) { return fmt.Errorf("cannot initialize ipset: %w", err) } // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions. // // Log and go on. log.Error("cannot initialize ipset: %s", err)
v4s = append(v4s, ip) } setLoop: for _, set := range sets { switch set.family { case netfilter.ProtoIPv4: err = c.addIPs(host, set, v4s)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: dnsforward: imp ipset caching, logging, and eperm handling Merge in DNS/adguard-home from ipset-fix to master Updates #2619. Squashed commit of the following: commit 6939c823598b1e74cb3d991aad1b928547fd26a9 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 16:55:14 2021 +0300 dnsforward: imp code commit 99e3a7c30b79d7929ddd9b700d7dd3d2683ec6d2 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 15:52:12 2021 +0300 dnsforward: imp ipset caching, logging, and eperm handling
https://github.com/AdguardTeam/AdGuardHome/commit/3e0238aa99c18fe5eae1a4a122f43daf8918bd75
internal/dnsforward/ipset_linux.go
} if err != nil { log.Error("ipset: adding host ips: %s", err) } return resultCodeSuccess }
</s> remove // ipset cannot be initialized in a Snap version (and maybe - without root) // this needs to be handled properly // TODO: Handle this properly log.Info("Cannot initialize ipset module due to %v", err) </s> add if !errors.Is(err, os.ErrPermission) { return fmt.Errorf("cannot initialize ipset: %w", err) } // ipset cannot currently be initialized if the server was // installed from Snap or when the user or the binary doesn't // have the required permissions. // // Log and go on. log.Error("cannot initialize ipset: %s", err) </s> remove var err error </s> add
} else { log.Debug("ipset: processed %d new ips", len(v4s)+len(v6s)) } for _, ip := range v4s { var iparr [16]byte copy(iparr[:], ip.To16()) c.addedIPs[iparr] = struct{}{} } for _, ip := range v6s { var iparr [16]byte copy(iparr[:], ip.To16()) c.addedIPs[iparr] = struct{}{}
} if err != nil { log.Error("ipset: adding host ips: %s", err) } else { log.Debug("ipset: processed %d new ips", len(v4s)+len(v6s)) } for _, ip := range v4s { var iparr [16]byte copy(iparr[:], ip.To16()) c.addedIPs[iparr] = struct{}{} } for _, ip := range v6s { var iparr [16]byte copy(iparr[:], ip.To16()) c.addedIPs[iparr] = struct{}{} } return resultCodeSuccess }
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: dnsforward: imp ipset caching, logging, and eperm handling Merge in DNS/adguard-home from ipset-fix to master Updates #2619. Squashed commit of the following: commit 6939c823598b1e74cb3d991aad1b928547fd26a9 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 16:55:14 2021 +0300 dnsforward: imp code commit 99e3a7c30b79d7929ddd9b700d7dd3d2683ec6d2 Author: Ainar Garipov <[email protected]> Date: Mon Feb 1 15:52:12 2021 +0300 dnsforward: imp ipset caching, logging, and eperm handling
https://github.com/AdguardTeam/AdGuardHome/commit/3e0238aa99c18fe5eae1a4a122f43daf8918bd75
internal/dnsforward/ipset_linux.go
// Respond with results func (s *Server) handleDHCPFindActiveServer(w http.ResponseWriter, r *http.Request) { body, err := ioutil.ReadAll(r.Body) if err != nil { errorText := fmt.Sprintf("failed to read request body: %s", err) log.Error(errorText) http.Error(w, errorText, http.StatusBadRequest) return } interfaceName := strings.TrimSpace(string(body)) if interfaceName == "" {
</s> remove errorText := fmt.Sprintf("failed to read request body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> add msg := fmt.Sprintf("failed to read request body: %s", err) log.Println(msg) http.Error(w, msg, http.StatusBadRequest) </s> remove errorText := fmt.Sprintf("empty interface name specified") log.Error(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> add msg := "empty interface name specified" log.Error(msg) http.Error(w, msg, http.StatusBadRequest) </s> remove errorText := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> add msg := fmt.Sprintf("Unable to write response json: %s", err) log.Println(msg) http.Error(w, msg, http.StatusInternalServerError) </s> remove errorText := fmt.Sprintf("empty language specified") log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> add msg := "empty language specified" log.Println(msg) http.Error(w, msg, http.StatusBadRequest) </s> remove errorText := fmt.Sprintf("unknown language specified: %s", language) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> add msg := fmt.Sprintf("unknown language specified: %s", language) log.Println(msg) http.Error(w, msg, http.StatusBadRequest)
msg := fmt.Sprintf("failed to read request body: %s", err) log.Error(msg) http.Error(w, msg, http.StatusBadRequest)
// Respond with results func (s *Server) handleDHCPFindActiveServer(w http.ResponseWriter, r *http.Request) { body, err := ioutil.ReadAll(r.Body) if err != nil { msg := fmt.Sprintf("failed to read request body: %s", err) log.Error(msg) http.Error(w, msg, http.StatusBadRequest) msg := fmt.Sprintf("failed to read request body: %s", err) log.Error(msg) http.Error(w, msg, http.StatusBadRequest) msg := fmt.Sprintf("failed to read request body: %s", err) log.Error(msg) http.Error(w, msg, http.StatusBadRequest) return } interfaceName := strings.TrimSpace(string(body)) if interfaceName == "" {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dhcpd/dhcp_http.go
} interfaceName := strings.TrimSpace(string(body)) if interfaceName == "" { errorText := fmt.Sprintf("empty interface name specified") log.Error(errorText) http.Error(w, errorText, http.StatusBadRequest) return } found4, err4 := CheckIfOtherDHCPServersPresentV4(interfaceName)
</s> remove errorText := fmt.Sprintf("empty language specified") log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> add msg := "empty language specified" log.Println(msg) http.Error(w, msg, http.StatusBadRequest) </s> remove errorText := fmt.Sprintf("failed to read request body: %s", err) log.Error(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> add msg := fmt.Sprintf("failed to read request body: %s", err) log.Error(msg) http.Error(w, msg, http.StatusBadRequest) </s> remove errorText := fmt.Sprintf("failed to read request body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> add msg := fmt.Sprintf("failed to read request body: %s", err) log.Println(msg) http.Error(w, msg, http.StatusBadRequest) </s> remove errorText := fmt.Sprintf("unknown language specified: %s", language) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> add msg := fmt.Sprintf("unknown language specified: %s", language) log.Println(msg) http.Error(w, msg, http.StatusBadRequest) </s> remove errorText := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> add msg := fmt.Sprintf("Unable to write response json: %s", err) log.Println(msg) http.Error(w, msg, http.StatusInternalServerError)
msg := "empty interface name specified" log.Error(msg) http.Error(w, msg, http.StatusBadRequest)
} interfaceName := strings.TrimSpace(string(body)) if interfaceName == "" { msg := "empty interface name specified" log.Error(msg) http.Error(w, msg, http.StatusBadRequest) msg := "empty interface name specified" log.Error(msg) http.Error(w, msg, http.StatusBadRequest) msg := "empty interface name specified" log.Error(msg) http.Error(w, msg, http.StatusBadRequest) return } found4, err4 := CheckIfOtherDHCPServersPresentV4(interfaceName)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dhcpd/dhcp_http.go
"github.com/stretchr/testify/assert" ) func check(t *testing.T, result bool, msg string) { if !result { t.Fatal(msg) } } func testNotify(flags uint32) { } // Leases database store/load func TestDB(t *testing.T) {
</s> remove func UIntArrayEquals(a []uint64, b []uint64) bool { </s> add func UIntArrayEquals(a, b []uint64) bool { </s> remove // ContainsString checks if "v" is in the array "arr" func ContainsString(arr []string, v string) bool { for _, i := range arr { if i == v { </s> add // ContainsString checks if string is in the slice of strings. func ContainsString(strs []string, str string) bool { for _, s := range strs { if s == str { </s> remove func (d *Dnsfilter) checkMatchIP(t *testing.T, hostname string, ip string, qtype uint16) { </s> add func (d *Dnsfilter) checkMatchIP(t *testing.T, hostname, ip string, qtype uint16) { </s> remove // MinInt - return the minimum value func MinInt(a, b int) int { if a < b { return a } return b } // IsOpenWrt checks if OS is OpenWRT func IsOpenWrt() bool { </s> add // IsOpenWRT checks if OS is OpenWRT. func IsOpenWRT() bool { </s> remove // fileExists returns TRUE if file exists </s> add // FileExists returns true if file exists.
"github.com/stretchr/testify/assert" ) func testNotify(flags uint32) { } // Leases database store/load func TestDB(t *testing.T) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dhcpd/dhcpd_test.go
// ServerPort is the port that DHCP servers and relay agents listen on. ServerPort = 67 ) var ( // DefaultServers is the address of all link-local DHCP servers and // relay agents. DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, } ) var ( // ErrNoResponse is returned when no response packet is received. ErrNoResponse = errors.New("no matching response packet received")
</s> remove // matchHost is a low-level way to check only if hostname is filtered by rules, skipping expensive safebrowsing and parental lookups </s> add // matchHost is a low-level way to check only if hostname is filtered by rules, // skipping expensive safebrowsing and parental lookups. </s> remove func Main(version string, channel string, armVer string) { </s> add func Main(version, channel, armVer string) { </s> remove // nolint func withBufferCap(n int) ClientOpt { return func(c *Client) (err error) { c.bufferCap = n return } } </s> add </s> remove // ContainsString checks if "v" is in the array "arr" func ContainsString(arr []string, v string) bool { for _, i := range arr { if i == v { </s> add // ContainsString checks if string is in the slice of strings. func ContainsString(strs []string, str string) bool { for _, s := range strs { if s == str { </s> remove var blockingRules = "||example.org^\n" var whitelistRules = "||example.org^\n@@||test.example.org\n" var importantRules = "@@||example.org^\n||test.example.org^$important\n" var regexRules = "/example\\.org/\n@@||test.example.org^\n" var maskRules = "test*.example.org^\nexam*.com\n" </s> add const nl = "\n" const ( blockingRules = `||example.org^` + nl whitelistRules = `||example.org^` + nl + `@@||test.example.org` + nl importantRules = `@@||example.org^` + nl + `||test.example.org^$important` + nl regexRules = `/example\.org/` + nl + `@@||test.example.org^` + nl maskRules = `test*.example.org^` + nl + `exam*.com` + nl )
// DefaultServers is the address of all link-local DHCP servers and // relay agents. var DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, }
// ServerPort is the port that DHCP servers and relay agents listen on. ServerPort = 67 ) // DefaultServers is the address of all link-local DHCP servers and // relay agents. var DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, } // DefaultServers is the address of all link-local DHCP servers and // relay agents. var DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, } // DefaultServers is the address of all link-local DHCP servers and // relay agents. var DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, } // DefaultServers is the address of all link-local DHCP servers and // relay agents. var DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, } // DefaultServers is the address of all link-local DHCP servers and // relay agents. var DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, } // DefaultServers is the address of all link-local DHCP servers and // relay agents. var DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, } // DefaultServers is the address of all link-local DHCP servers and // relay agents. var DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, } // DefaultServers is the address of all link-local DHCP servers and // relay agents. var DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, } var ( // ErrNoResponse is returned when no response packet is received. ErrNoResponse = errors.New("no matching response packet received")
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dhcpd/nclient4/client.go
return } } // nolint func withBufferCap(n int) ClientOpt { return func(c *Client) (err error) { c.bufferCap = n return } } // WithRetry configures the number of retransmissions to attempt. // // Default is 3. func WithRetry(r int) ClientOpt { return func(c *Client) (err error) {
</s> remove // MinInt - return the minimum value func MinInt(a, b int) int { if a < b { return a } return b } // IsOpenWrt checks if OS is OpenWRT func IsOpenWrt() bool { </s> add // IsOpenWRT checks if OS is OpenWRT. func IsOpenWRT() bool { </s> remove func (w *Whois) query(target string, serverAddr string) (string, error) { </s> add func (w *Whois) query(target, serverAddr string) (string, error) { </s> remove // Process - get the list of IP addresses for the hostname // Return nil if not found </s> add // Process returns the list of IP addresses for the hostname or nil if nothing // found. </s> remove // ContainsString checks if "v" is in the array "arr" func ContainsString(arr []string, v string) bool { for _, i := range arr { if i == v { </s> add // ContainsString checks if string is in the slice of strings. func ContainsString(strs []string, str string) bool { for _, s := range strs { if s == str {
return } } // WithRetry configures the number of retransmissions to attempt. // // Default is 3. func WithRetry(r int) ClientOpt { return func(c *Client) (err error) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dhcpd/nclient4/client.go
p.ClientHWAddr = net.HardwareAddr{0xa, 0xb, 0xc, 0xd, 0xe, 0xf} return p } func TestSendAndRead(t *testing.T) { for _, tt := range []struct { desc string send *dhcpv4.DHCPv4 server []*dhcpv4.DHCPv4
</s> remove filters := []Filter{Filter{ </s> add filters := []Filter{{ </s> remove // ContainsString checks if "v" is in the array "arr" func ContainsString(arr []string, v string) bool { for _, i := range arr { if i == v { </s> add // ContainsString checks if string is in the slice of strings. func ContainsString(strs []string, str string) bool { for _, s := range strs { if s == str { </s> remove q += fmt.Sprintf("%s.", hex.EncodeToString(hash[0:2])) </s> add // Ignore errors, since strings.(*Buffer).Write never returns // errors. // // TODO(e.burkov, a.garipov): Find out and document why exactly // this slice. _, _ = encoder.Write(hash[0:2]) _, _ = b.WriteRune('.') </s> remove q := "" </s> add b := &strings.Builder{} encoder := hex.NewEncoder(b) </s> remove if !os.IsNotExist(err) { // do nothing, file exists return false } return true </s> add return os.IsNotExist(err)
func withBufferCap(n int) ClientOpt { return func(c *Client) (err error) { c.bufferCap = n return } }
p.ClientHWAddr = net.HardwareAddr{0xa, 0xb, 0xc, 0xd, 0xe, 0xf} return p } func withBufferCap(n int) ClientOpt { return func(c *Client) (err error) { c.bufferCap = n return } } func TestSendAndRead(t *testing.T) { for _, tt := range []struct { desc string send *dhcpv4.DHCPv4 server []*dhcpv4.DHCPv4
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dhcpd/nclient4/client_test.go
if err != nil { return nil } m := make(map[string]string, 0) matches := re.FindAllStringSubmatch(out, -1) for i := range matches { port := matches[i][1] device := matches[i][2]
</s> remove if err != nil { return false } return true </s> add return err == nil </s> remove units := []*unitDB{} //per-hour units </s> add // Per-hour units. units := []*unitDB{} </s> remove func UIntArrayEquals(a []uint64, b []uint64) bool { </s> add func UIntArrayEquals(a, b []uint64) bool { </s> remove // ContainsString checks if "v" is in the array "arr" func ContainsString(arr []string, v string) bool { for _, i := range arr { if i == v { </s> add // ContainsString checks if string is in the slice of strings. func ContainsString(strs []string, str string) bool { for _, s := range strs { if s == str { </s> remove // Initialize urlfilter objects </s> add // Initialize urlfilter objects.
m := make(map[string]string)
if err != nil { return nil } m := make(map[string]string) matches := re.FindAllStringSubmatch(out, -1) for i := range matches { port := matches[i][1] device := matches[i][2]
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dhcpd/network_utils.go
} // Return TRUE if IP address is within range [start..0xff] // nolint(staticcheck) func ip6InRange(start net.IP, ip net.IP) bool { if len(start) != 16 { return false } //lint:ignore SA1021 TODO(e.burkov): Ignore this for now, think about using masks. if !bytes.Equal(start[:15], ip[:15]) {
</s> remove if err != nil { return false } return true </s> add return err == nil </s> remove // Return TRUE if file exists </s> add // fileExists returns true if file exists. </s> remove // fileExists returns TRUE if file exists </s> add // FileExists returns true if file exists. </s> remove var ip string ip = <-w.ipChan </s> add ip := <-w.ipChan </s> remove var ip string ip = <-r.ipChannel </s> add ip := <-r.ipChannel
func ip6InRange(start, ip net.IP) bool {
} // Return TRUE if IP address is within range [start..0xff] // nolint(staticcheck) func ip6InRange(start, ip net.IP) bool { if len(start) != 16 { return false } //lint:ignore SA1021 TODO(e.burkov): Ignore this for now, think about using masks. if !bytes.Equal(start[:15], ip[:15]) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dhcpd/v6.go
case dhcpv6.MessageTypeSolicit: // case dhcpv6.MessageTypeConfirm: lifetime = lease.Expiry.Sub(time.Now()) case dhcpv6.MessageTypeRequest, dhcpv6.MessageTypeRenew, dhcpv6.MessageTypeRebind:
</s> remove func (s *v6Server) process(msg *dhcpv6.Message, req dhcpv6.DHCPv6, resp dhcpv6.DHCPv6) bool { </s> add func (s *v6Server) process(msg *dhcpv6.Message, req, resp dhcpv6.DHCPv6) bool { </s> remove case _ = <-a.watcher.Events: // skip this event </s> add case <-a.watcher.Events: // Skip this duplicating event </s> remove // skip duplicate events </s> add </s> remove // updateLoop - read static hosts from system files </s> add // updateLoop reads static hosts from system files. </s> remove for { select { case t := <-ticker.C: t.Second() log.Debug("Free OS memory") debug.FreeOSMemory() } </s> add for range ticker.C { log.Debug("free os memory") debug.FreeOSMemory()
lifetime = time.Until(lease.Expiry)
case dhcpv6.MessageTypeSolicit: // case dhcpv6.MessageTypeConfirm: lifetime = time.Until(lease.Expiry) case dhcpv6.MessageTypeRequest, dhcpv6.MessageTypeRenew, dhcpv6.MessageTypeRebind:
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dhcpd/v6.go
return lifetime } // Find a lease associated with MAC and prepare response func (s *v6Server) process(msg *dhcpv6.Message, req dhcpv6.DHCPv6, resp dhcpv6.DHCPv6) bool { switch msg.Type() { case dhcpv6.MessageTypeSolicit, dhcpv6.MessageTypeRequest, dhcpv6.MessageTypeConfirm, dhcpv6.MessageTypeRenew,
</s> remove lifetime = lease.Expiry.Sub(time.Now()) </s> add lifetime = time.Until(lease.Expiry) </s> remove return q </s> add // See comment above. _, _ = b.WriteString(pcTXTSuffix) return b.String() </s> remove // MinInt - return the minimum value func MinInt(a, b int) int { if a < b { return a } return b } // IsOpenWrt checks if OS is OpenWRT func IsOpenWrt() bool { </s> add // IsOpenWRT checks if OS is OpenWRT. func IsOpenWRT() bool { </s> remove func (w *Whois) query(target string, serverAddr string) (string, error) { </s> add func (w *Whois) query(target, serverAddr string) (string, error) { </s> remove q += sbTXTSuffix } else { q += pcTXTSuffix </s> add // See comment above. _, _ = b.WriteString(sbTXTSuffix) return b.String()
func (s *v6Server) process(msg *dhcpv6.Message, req, resp dhcpv6.DHCPv6) bool {
return lifetime } // Find a lease associated with MAC and prepare response func (s *v6Server) process(msg *dhcpv6.Message, req, resp dhcpv6.DHCPv6) bool { switch msg.Type() { case dhcpv6.MessageTypeSolicit, dhcpv6.MessageTypeRequest, dhcpv6.MessageTypeConfirm, dhcpv6.MessageTypeRenew,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dhcpd/v6.go
// SetFilters - set new filters (synchronously or asynchronously) // When filters are set asynchronously, the old filters continue working until the new filters are ready. // In this case the caller must ensure that the old filter files are intact. func (d *Dnsfilter) SetFilters(blockFilters []Filter, allowFilters []Filter, async bool) error { if async { params := filtersInitializerParams{ allowFilters: allowFilters, blockFilters: blockFilters, }
</s> remove // Process - get the list of IP addresses for the hostname // Return nil if not found </s> add // Process returns the list of IP addresses for the hostname or nil if nothing // found. </s> remove for { select { case t := <-ticker.C: t.Second() log.Debug("Free OS memory") debug.FreeOSMemory() } </s> add for range ticker.C { log.Debug("free os memory") debug.FreeOSMemory() </s> remove filters := []Filter{Filter{ </s> add filters := []Filter{{ </s> remove filters := []Filter{Filter{ </s> add filters := []Filter{{ </s> remove // matchHost is a low-level way to check only if hostname is filtered by rules, skipping expensive safebrowsing and parental lookups </s> add // matchHost is a low-level way to check only if hostname is filtered by rules, // skipping expensive safebrowsing and parental lookups.
func (d *Dnsfilter) SetFilters(blockFilters, allowFilters []Filter, async bool) error {
// SetFilters - set new filters (synchronously or asynchronously) // When filters are set asynchronously, the old filters continue working until the new filters are ready. // In this case the caller must ensure that the old filter files are intact. func (d *Dnsfilter) SetFilters(blockFilters, allowFilters []Filter, async bool) error { if async { params := filtersInitializerParams{ allowFilters: allowFilters, blockFilters: blockFilters, }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter.go
// // Adding rule and matching against the rules // // Return TRUE if file exists func fileExists(fn string) bool { _, err := os.Stat(fn) if err != nil { return false }
</s> remove if err != nil { return false } return true </s> add return err == nil </s> remove // fileExists returns TRUE if file exists </s> add // FileExists returns true if file exists. </s> remove if err != nil { return false } return true </s> add return err == nil </s> remove func ip6InRange(start net.IP, ip net.IP) bool { </s> add func ip6InRange(start, ip net.IP) bool { </s> remove if !os.IsNotExist(err) { // do nothing, file exists return false } return true </s> add return os.IsNotExist(err)
// fileExists returns true if file exists.
// // Adding rule and matching against the rules // // fileExists returns true if file exists. func fileExists(fn string) bool { _, err := os.Stat(fn) if err != nil { return false }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter.go
// Return TRUE if file exists func fileExists(fn string) bool { _, err := os.Stat(fn) if err != nil { return false } return true } func createFilteringEngine(filters []Filter) (*filterlist.RuleStorage, *urlfilter.DNSEngine, error) { listArray := []filterlist.RuleList{} for _, f := range filters {
</s> remove // Return TRUE if file exists </s> add // fileExists returns true if file exists. </s> remove // fileExists returns TRUE if file exists </s> add // FileExists returns true if file exists. </s> remove if err != nil { return false } return true </s> add return err == nil </s> remove // ContainsString checks if "v" is in the array "arr" func ContainsString(arr []string, v string) bool { for _, i := range arr { if i == v { </s> add // ContainsString checks if string is in the slice of strings. func ContainsString(strs []string, str string) bool { for _, s := range strs { if s == str { </s> remove if !os.IsNotExist(err) { // do nothing, file exists return false } return true </s> add return os.IsNotExist(err)
return err == nil
// Return TRUE if file exists func fileExists(fn string) bool { _, err := os.Stat(fn) return err == nil return err == nil return err == nil return err == nil } func createFilteringEngine(filters []Filter) (*filterlist.RuleStorage, *urlfilter.DNSEngine, error) { listArray := []filterlist.RuleList{} for _, f := range filters {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter.go
IgnoreCosmetic: true, } } else if runtime.GOOS == "windows" { // On Windows we don't pass a file to urlfilter because // it's difficult to update this file while it's being used. data, err := ioutil.ReadFile(f.FilePath) if err != nil { return nil, nil, fmt.Errorf("ioutil.ReadFile(): %s: %w", f.FilePath, err) } list = &filterlist.StringRuleList{
</s> remove } else if util.IsFreeBSD() { </s> add } else if runtime.GOOS == "freebsd" { </s> remove // fileExists returns TRUE if file exists </s> add // FileExists returns true if file exists. </s> remove // On OpenWrt we're using a different type of sysvScript if util.IsOpenWrt() { </s> add // On OpenWrt we're using a different type of sysvScript. if util.IsOpenWRT() { </s> remove s.db, err = bolt.Open(s.conf.Filename, 0644, nil) </s> add s.db, err = bolt.Open(s.conf.Filename, 0o644, nil) </s> remove func (d *Dnsfilter) checkMatchIP(t *testing.T, hostname string, ip string, qtype uint16) { </s> add func (d *Dnsfilter) checkMatchIP(t *testing.T, hostname, ip string, qtype uint16) {
// it's difficult to update this file while it's being // used.
IgnoreCosmetic: true, } } else if runtime.GOOS == "windows" { // On Windows we don't pass a file to urlfilter because // it's difficult to update this file while it's being // used. data, err := ioutil.ReadFile(f.FilePath) if err != nil { return nil, nil, fmt.Errorf("ioutil.ReadFile(): %s: %w", f.FilePath, err) } list = &filterlist.StringRuleList{
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter.go
filteringEngine := urlfilter.NewDNSEngine(rulesStorage) return rulesStorage, filteringEngine, nil } // Initialize urlfilter objects func (d *Dnsfilter) initFiltering(allowFilters, blockFilters []Filter) error { rulesStorage, filteringEngine, err := createFilteringEngine(blockFilters) if err != nil { return err }
</s> remove if err != nil { return false } return true </s> add return err == nil </s> remove func (d *Dnsfilter) checkMatchIP(t *testing.T, hostname string, ip string, qtype uint16) { </s> add func (d *Dnsfilter) checkMatchIP(t *testing.T, hostname, ip string, qtype uint16) { </s> remove if err != nil { return false } return true </s> add return err == nil </s> remove // fileExists returns TRUE if file exists </s> add // FileExists returns true if file exists. </s> remove // New creates properly initialized DNS Filter that is ready to be used </s> add // New creates properly initialized DNS Filter that is ready to be used.
// Initialize urlfilter objects.
filteringEngine := urlfilter.NewDNSEngine(rulesStorage) return rulesStorage, filteringEngine, nil } // Initialize urlfilter objects. func (d *Dnsfilter) initFiltering(allowFilters, blockFilters []Filter) error { rulesStorage, filteringEngine, err := createFilteringEngine(blockFilters) if err != nil { return err }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter.go
return nil } // matchHost is a low-level way to check only if hostname is filtered by rules, skipping expensive safebrowsing and parental lookups func (d *Dnsfilter) matchHost(host string, qtype uint16, setts RequestFilteringSettings) (Result, error) { d.engineLock.RLock() // Keep in mind that this lock must be held no just when calling Match() // but also while using the rules returned by it. defer d.engineLock.RUnlock()
</s> remove func (d *Dnsfilter) checkMatchIP(t *testing.T, hostname string, ip string, qtype uint16) { </s> add func (d *Dnsfilter) checkMatchIP(t *testing.T, hostname, ip string, qtype uint16) { </s> remove var ( // DefaultServers is the address of all link-local DHCP servers and // relay agents. DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, } ) </s> add // DefaultServers is the address of all link-local DHCP servers and // relay agents. var DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, } </s> remove var ip string ip = <-r.ipChannel </s> add ip := <-r.ipChannel </s> remove // New creates properly initialized DNS Filter that is ready to be used </s> add // New creates properly initialized DNS Filter that is ready to be used. </s> remove // Process - get the list of IP addresses for the hostname // Return nil if not found </s> add // Process returns the list of IP addresses for the hostname or nil if nothing // found.
// matchHost is a low-level way to check only if hostname is filtered by rules, // skipping expensive safebrowsing and parental lookups.
return nil } // matchHost is a low-level way to check only if hostname is filtered by rules, // skipping expensive safebrowsing and parental lookups. func (d *Dnsfilter) matchHost(host string, qtype uint16, setts RequestFilteringSettings) (Result, error) { d.engineLock.RLock() // Keep in mind that this lock must be held no just when calling Match() // but also while using the rules returned by it. defer d.engineLock.RUnlock()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter.go
} return res } // InitModule() - manually initialize blocked services map func InitModule() { initBlockedServices() } // New creates properly initialized DNS Filter that is ready to be used
</s> remove // New creates properly initialized DNS Filter that is ready to be used </s> add // New creates properly initialized DNS Filter that is ready to be used. </s> remove // MinInt - return the minimum value func MinInt(a, b int) int { if a < b { return a } return b } // IsOpenWrt checks if OS is OpenWRT func IsOpenWrt() bool { </s> add // IsOpenWRT checks if OS is OpenWRT. func IsOpenWRT() bool { </s> remove // nolint func withBufferCap(n int) ClientOpt { return func(c *Client) (err error) { c.bufferCap = n return } } </s> add </s> remove // matchHost is a low-level way to check only if hostname is filtered by rules, skipping expensive safebrowsing and parental lookups </s> add // matchHost is a low-level way to check only if hostname is filtered by rules, // skipping expensive safebrowsing and parental lookups. </s> remove if !os.IsNotExist(err) { // do nothing, file exists return false } return true </s> add return os.IsNotExist(err)
// InitModule manually initializes blocked services map.
} return res } // InitModule manually initializes blocked services map. func InitModule() { initBlockedServices() } // New creates properly initialized DNS Filter that is ready to be used
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter.go
func InitModule() { initBlockedServices() } // New creates properly initialized DNS Filter that is ready to be used func New(c *Config, blockFilters []Filter) *Dnsfilter { if c != nil { cacheConf := cache.Config{ EnableLRU: true, }
</s> remove // InitModule() - manually initialize blocked services map </s> add // InitModule manually initializes blocked services map. </s> remove // initialize objects only once </s> add </s> remove func _Func() string { pc := make([]uintptr, 10) // at least 1 entry needed runtime.Callers(2, pc) f := runtime.FuncForPC(pc[0]) return path.Base(f.Name()) } </s> add </s> remove // Initialize urlfilter objects </s> add // Initialize urlfilter objects. </s> remove if err != nil { return false } return true </s> add return err == nil
// New creates properly initialized DNS Filter that is ready to be used.
func InitModule() { initBlockedServices() } // New creates properly initialized DNS Filter that is ready to be used. func New(c *Config, blockFilters []Filter) *Dnsfilter { if c != nil { cacheConf := cache.Config{ EnableLRU: true, }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter.go
cacheConf := cache.Config{ EnableLRU: true, } // initialize objects only once if gctx.safebrowsingCache == nil { cacheConf.MaxSize = c.SafeBrowsingCacheSize gctx.safebrowsingCache = cache.New(cacheConf) }
</s> remove // New creates properly initialized DNS Filter that is ready to be used </s> add // New creates properly initialized DNS Filter that is ready to be used. </s> remove func _Func() string { pc := make([]uintptr, 10) // at least 1 entry needed runtime.Callers(2, pc) f := runtime.FuncForPC(pc[0]) return path.Base(f.Name()) } </s> add </s> remove // Initialize urlfilter objects </s> add // Initialize urlfilter objects. </s> remove // it's difficult to update this file while it's being used. </s> add // it's difficult to update this file while it's being // used. </s> remove } else if util.IsFreeBSD() { </s> add } else if runtime.GOOS == "freebsd" {
cacheConf := cache.Config{ EnableLRU: true, } if gctx.safebrowsingCache == nil { cacheConf.MaxSize = c.SafeBrowsingCacheSize gctx.safebrowsingCache = cache.New(cacheConf) }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter.go
// // stats // // GetStats return dns filtering stats since startup func (d *Dnsfilter) GetStats() Stats { return gctx.stats }
</s> remove // Initialize urlfilter objects </s> add // Initialize urlfilter objects. </s> remove func (d *Dnsfilter) SetFilters(blockFilters []Filter, allowFilters []Filter, async bool) error { </s> add func (d *Dnsfilter) SetFilters(blockFilters, allowFilters []Filter, async bool) error { </s> remove q += fmt.Sprintf("%s.", hex.EncodeToString(hash[0:2])) </s> add // Ignore errors, since strings.(*Buffer).Write never returns // errors. // // TODO(e.burkov, a.garipov): Find out and document why exactly // this slice. _, _ = encoder.Write(hash[0:2]) _, _ = b.WriteRune('.') </s> remove // nolint func withBufferCap(n int) ClientOpt { return func(c *Client) (err error) { c.bufferCap = n return } } </s> add </s> remove // matchHost is a low-level way to check only if hostname is filtered by rules, skipping expensive safebrowsing and parental lookups </s> add // matchHost is a low-level way to check only if hostname is filtered by rules, // skipping expensive safebrowsing and parental lookups.
// GetStats return dns filtering stats since startup.
// // stats // // GetStats return dns filtering stats since startup. func (d *Dnsfilter) GetStats() Stats { return gctx.stats }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter.go
import ( "fmt" "net" "os" "path" "runtime" "testing" "github.com/AdguardTeam/urlfilter/rules" "github.com/miekg/dns" "github.com/stretchr/testify/assert"
</s> remove const dnsTimeout = 3 * time.Second const defaultSafebrowsingServer = "https://dns-family.adguard.com/dns-query" const defaultParentalServer = "https://dns-family.adguard.com/dns-query" const sbTXTSuffix = "sb.dns.adguard.com." const pcTXTSuffix = "pc.dns.adguard.com." </s> add const ( dnsTimeout = 3 * time.Second defaultSafebrowsingServer = `https://dns-family.adguard.com/dns-query` defaultParentalServer = `https://dns-family.adguard.com/dns-query` sbTXTSuffix = `sb.dns.adguard.com.` pcTXTSuffix = `pc.dns.adguard.com.` ) </s> remove func UIntArrayEquals(a []uint64, b []uint64) bool { </s> add func UIntArrayEquals(a, b []uint64) bool { </s> remove func check(t *testing.T, result bool, msg string) { if !result { t.Fatal(msg) } } </s> add </s> remove var ( // DefaultServers is the address of all link-local DHCP servers and // relay agents. DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, } ) </s> add // DefaultServers is the address of all link-local DHCP servers and // relay agents. var DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, } </s> remove var data []byte data = make([]byte, 4+2+len(s.userName)) </s> add const ( expireLen = 4 nameLen = 2 ) data := make([]byte, expireLen+nameLen+len(s.userName))
import ( "fmt" "net" "testing" "github.com/AdguardTeam/urlfilter/rules" "github.com/miekg/dns" "github.com/stretchr/testify/assert"
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter_test.go
gctx.safeSearchCache.Clear() } } func _Func() string { pc := make([]uintptr, 10) // at least 1 entry needed runtime.Callers(2, pc) f := runtime.FuncForPC(pc[0]) return path.Base(f.Name()) } func NewForTest(c *Config, filters []Filter) *Dnsfilter { setts = RequestFilteringSettings{} setts.FilteringEnabled = true if c != nil { c.SafeBrowsingCacheSize = 10000
</s> remove if err != nil { return false } return true </s> add return err == nil </s> remove // New creates properly initialized DNS Filter that is ready to be used </s> add // New creates properly initialized DNS Filter that is ready to be used. </s> remove // initialize objects only once </s> add </s> remove var hour int32 hour = 1 </s> add var hour int32 = 1 </s> remove // Initialize urlfilter objects </s> add // Initialize urlfilter objects.
gctx.safeSearchCache.Clear() } } func NewForTest(c *Config, filters []Filter) *Dnsfilter { setts = RequestFilteringSettings{} setts.FilteringEnabled = true if c != nil { c.SafeBrowsingCacheSize = 10000
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter_test.go
t.Errorf("Expected hostname %s to match", hostname) } } func (d *Dnsfilter) checkMatchIP(t *testing.T, hostname string, ip string, qtype uint16) { t.Helper() ret, err := d.CheckHost(hostname, qtype, &setts) if err != nil { t.Errorf("Error while matching host %s: %s", hostname, err) }
</s> remove // Process - get the list of IP addresses for the hostname // Return nil if not found </s> add // Process returns the list of IP addresses for the hostname or nil if nothing // found. </s> remove // it's difficult to update this file while it's being used. </s> add // it's difficult to update this file while it's being // used. </s> remove // matchHost is a low-level way to check only if hostname is filtered by rules, skipping expensive safebrowsing and parental lookups </s> add // matchHost is a low-level way to check only if hostname is filtered by rules, // skipping expensive safebrowsing and parental lookups. </s> remove var ip string ip = <-r.ipChannel </s> add ip := <-r.ipChannel </s> remove errorText := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> add msg := fmt.Sprintf("Unable to write response json: %s", err) log.Println(msg) http.Error(w, msg, http.StatusInternalServerError)
func (d *Dnsfilter) checkMatchIP(t *testing.T, hostname, ip string, qtype uint16) {
t.Errorf("Expected hostname %s to match", hostname) } } func (d *Dnsfilter) checkMatchIP(t *testing.T, hostname, ip string, qtype uint16) { t.Helper() ret, err := d.CheckHost(hostname, qtype, &setts) if err != nil { t.Errorf("Error while matching host %s: %s", hostname, err) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter_test.go
0.0.0.2 host2 ::1 host2 `, addr, addr6) filters := []Filter{Filter{ ID: 0, Data: []byte(text), }} d := NewForTest(nil, filters) defer d.Close()
</s> remove whiteFilters := []Filter{Filter{ </s> add whiteFilters := []Filter{{ </s> remove filters := []Filter{Filter{ </s> add filters := []Filter{{ </s> remove filters := []Filter{Filter{ </s> add filters := []Filter{{ </s> remove filters := []Filter{Filter{ </s> add filters := []Filter{{ </s> remove func prepareTestDir() string { const dir = "./agh-test" _ = os.RemoveAll(dir) _ = os.MkdirAll(dir, 0755) return dir } </s> add
filters := []Filter{{
0.0.0.2 host2 ::1 host2 `, addr, addr6) filters := []Filter{{ ID: 0, Data: []byte(text), }} d := NewForTest(nil, filters) defer d.Close()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter_test.go
} // FILTERING var blockingRules = "||example.org^\n" var whitelistRules = "||example.org^\n@@||test.example.org\n" var importantRules = "@@||example.org^\n||test.example.org^$important\n" var regexRules = "/example\\.org/\n@@||test.example.org^\n" var maskRules = "test*.example.org^\nexam*.com\n" var tests = []struct { testname string rules string hostname string
</s> remove var hour int32 hour = 1 </s> add var hour int32 = 1 </s> remove var ip string ip = <-r.ipChannel </s> add ip := <-r.ipChannel </s> remove /* expire byte[4] name_len byte[2] name byte[] */ </s> add </s> remove var ip string ip = <-w.ipChan </s> add ip := <-w.ipChan </s> remove var ( // DefaultServers is the address of all link-local DHCP servers and // relay agents. DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, } ) </s> add // DefaultServers is the address of all link-local DHCP servers and // relay agents. var DefaultServers = &net.UDPAddr{ IP: net.IPv4bcast, Port: ServerPort, }
const nl = "\n" const ( blockingRules = `||example.org^` + nl whitelistRules = `||example.org^` + nl + `@@||test.example.org` + nl importantRules = `@@||example.org^` + nl + `||test.example.org^$important` + nl regexRules = `/example\.org/` + nl + `@@||test.example.org^` + nl maskRules = `test*.example.org^` + nl + `exam*.com` + nl )
} // FILTERING const nl = "\n" const ( blockingRules = `||example.org^` + nl whitelistRules = `||example.org^` + nl + `@@||test.example.org` + nl importantRules = `@@||example.org^` + nl + `||test.example.org^$important` + nl regexRules = `/example\.org/` + nl + `@@||test.example.org^` + nl maskRules = `test*.example.org^` + nl + `exam*.com` + nl ) const nl = "\n" const ( blockingRules = `||example.org^` + nl whitelistRules = `||example.org^` + nl + `@@||test.example.org` + nl importantRules = `@@||example.org^` + nl + `||test.example.org^$important` + nl regexRules = `/example\.org/` + nl + `@@||test.example.org^` + nl maskRules = `test*.example.org^` + nl + `exam*.com` + nl ) const nl = "\n" const ( blockingRules = `||example.org^` + nl whitelistRules = `||example.org^` + nl + `@@||test.example.org` + nl importantRules = `@@||example.org^` + nl + `||test.example.org^$important` + nl regexRules = `/example\.org/` + nl + `@@||test.example.org^` + nl maskRules = `test*.example.org^` + nl + `exam*.com` + nl ) const nl = "\n" const ( blockingRules = `||example.org^` + nl whitelistRules = `||example.org^` + nl + `@@||test.example.org` + nl importantRules = `@@||example.org^` + nl + `||test.example.org^$important` + nl regexRules = `/example\.org/` + nl + `@@||test.example.org^` + nl maskRules = `test*.example.org^` + nl + `exam*.com` + nl ) const nl = "\n" const ( blockingRules = `||example.org^` + nl whitelistRules = `||example.org^` + nl + `@@||test.example.org` + nl importantRules = `@@||example.org^` + nl + `||test.example.org^$important` + nl regexRules = `/example\.org/` + nl + `@@||test.example.org^` + nl maskRules = `test*.example.org^` + nl + `exam*.com` + nl ) var tests = []struct { testname string rules string hostname string
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter_test.go
func TestMatching(t *testing.T) { for _, test := range tests { t.Run(fmt.Sprintf("%s-%s", test.testname, test.hostname), func(t *testing.T) { filters := []Filter{Filter{ ID: 0, Data: []byte(test.rules), }} d := NewForTest(nil, filters) defer d.Close()
</s> remove filters := []Filter{Filter{ </s> add filters := []Filter{{ </s> remove filters := []Filter{Filter{ </s> add filters := []Filter{{ </s> remove whiteFilters := []Filter{Filter{ </s> add whiteFilters := []Filter{{ </s> remove filters := []Filter{Filter{ </s> add filters := []Filter{{
filters := []Filter{{
func TestMatching(t *testing.T) { for _, test := range tests { t.Run(fmt.Sprintf("%s-%s", test.testname, test.hostname), func(t *testing.T) { filters := []Filter{{ ID: 0, Data: []byte(test.rules), }} d := NewForTest(nil, filters) defer d.Close()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request:* all: fix all staticcheck simplification and unused warnings Merge in DNS/adguard-home from 2270-fix-s-u-warnings to master Squashed commit of the following: commit 03e0f78bd471057007c2d4042ee26eda2bbc9b29 Merge: 50dc3ef5c 7e16fda57 Author: Eugene Burkov <[email protected]> Date: Fri Nov 6 11:54:09 2020 +0300 Merge branch 'master' into 2270-fix-s-u-warnings commit 50dc3ef5c44a5fdc941794c26784b0c44d7b5aa0 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 19:48:54 2020 +0300 * all: improve code quality commit d6d804f759ce3e47154a389b427550e72c4b9090 Author: Eugene Burkov <[email protected]> Date: Thu Nov 5 18:03:35 2020 +0300 * all: fix all staticcheck simplification and unused warnings Closes #2270.
https://github.com/AdguardTeam/AdGuardHome/commit/3e1f922252e2a9b735b0be28733067f3b85bb6f3
internal/dnsfilter/dnsfilter_test.go