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
ParentalBlockHost string QueryLogEnabled bool BlockedTTL uint32 // in seconds, default 3600 } type plug struct { d *dnsfilter.Dnsfilter Next plugin.Handler
</s> remove FilterFile string `yaml:"-"` Port int `yaml:"port"` ProtectionEnabled bool `yaml:"protection_enabled"` FilteringEnabled bool `yaml:"filtering_enabled"` SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"` SafeSearchEnabled bool `yaml:"safesearch_enabled"` ParentalEnabled bool `yaml:"parental_enabled"` ParentalSensitivity int `yaml:"parental_sensitivity"` BlockedResponseTTL int `yaml:"blocked_response_ttl"` QueryLogEnabled bool `yaml:"querylog_enabled"` Pprof string `yaml:"-"` Cache string `yaml:"-"` Prometheus string `yaml:"-"` UpstreamDNS []string `yaml:"upstream_dns"` </s> add Filters []coreDnsFilter `yaml:"-"` Port int `yaml:"port"` ProtectionEnabled bool `yaml:"protection_enabled"` FilteringEnabled bool `yaml:"filtering_enabled"` SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"` SafeSearchEnabled bool `yaml:"safesearch_enabled"` ParentalEnabled bool `yaml:"parental_enabled"` ParentalSensitivity int `yaml:"parental_sensitivity"` BlockedResponseTTL int `yaml:"blocked_response_ttl"` QueryLogEnabled bool `yaml:"querylog_enabled"` Pprof string `yaml:"-"` Cache string `yaml:"-"` Prometheus string `yaml:"-"` UpstreamDNS []string `yaml:"upstream_dns"` </s> remove BindHost string `yaml:"bind_host"` BindPort int `yaml:"bind_port"` AuthName string `yaml:"auth_name"` AuthPass string `yaml:"auth_pass"` CoreDNS coreDNSConfig `yaml:"coredns"` Filters []filter `yaml:"filters"` UserRules []string `yaml:"user_rules"` </s> add // Schema version of the config file. This value is used when performing the app updates. SchemaVersion int `yaml:"schema_version"` BindHost string `yaml:"bind_host"` BindPort int `yaml:"bind_port"` AuthName string `yaml:"auth_name"` AuthPass string `yaml:"auth_pass"` CoreDNS coreDNSConfig `yaml:"coredns"` Filters []filter `yaml:"filters"` UserRules []string `yaml:"user_rules"`
Filters []plugFilter
ParentalBlockHost string QueryLogEnabled bool BlockedTTL uint32 // in seconds, default 3600 Filters []plugFilter } type plug struct { d *dnsfilter.Dnsfilter Next plugin.Handler
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
coredns_plugin/coredns_plugin.go
ParentalBlockHost: "family.block.dns.adguard.com", BlockedTTL: 3600, // in seconds } // // coredns handling functions // func setupPlugin(c *caddy.Controller) (*plug, error) {
</s> remove return value </s> add return nil </s> remove func (filter *filter) update(now time.Time) (bool, error) { </s> add // Checks for filters updates // If "force" is true -- does not check the filter's LastUpdated field func (filter *filter) update(force bool) (bool, error) { </s> remove // eat all args so that coredns can start happily </s> add // Eat all args so that coredns can start happily </s> remove func clamp(value, low, high int) int { if value < low { return low </s> add // ---------------------------------- // helper functions for working with files // ---------------------------------- // Writes data first to a temporary file and then renames it to what's specified in path func writeFileSafe(path string, data []byte) error { dir := filepath.Dir(path) err := os.MkdirAll(dir, 0755) if err != nil { return err } tmpPath := path + ".tmp" err = ioutil.WriteFile(tmpPath, data, 0644) if err != nil { return err </s> remove binaryFile: "coredns", // only filename, no path coreFile: "Corefile", // only filename, no path FilterFile: "dnsfilter.txt", // only filename, no path </s> add binaryFile: "coredns", // only filename, no path coreFile: "Corefile", // only filename, no path
Filters: make([]plugFilter, 0),
ParentalBlockHost: "family.block.dns.adguard.com", BlockedTTL: 3600, // in seconds Filters: make([]plugFilter, 0), } // // coredns handling functions // func setupPlugin(c *caddy.Controller) (*plug, error) {
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
coredns_plugin/coredns_plugin.go
settings: defaultPluginSettings, d: dnsfilter.New(), } filterFileNames := []string{} for c.Next() { args := c.RemainingArgs() if len(args) > 0 { filterFileNames = append(filterFileNames, args...) }
</s> remove args := c.RemainingArgs() if len(args) > 0 { filterFileNames = append(filterFileNames, args...) } </s> add </s> remove switch c.Val() { </s> add blockValue := c.Val() switch blockValue { </s> remove log.Printf("filterFileNames = %+v", filterFileNames) </s> add for _, filter := range p.settings.Filters { log.Printf("Loading rules from %s", filter.Path) </s> remove for i, filterFileName := range filterFileNames { file, err := os.Open(filterFileName) </s> add file, err := os.Open(filter.Path) </s> remove // eat all args so that coredns can start happily </s> add // Eat all args so that coredns can start happily
log.Println("Initializing the CoreDNS plugin")
settings: defaultPluginSettings, d: dnsfilter.New(), } log.Println("Initializing the CoreDNS plugin") for c.Next() { args := c.RemainingArgs() if len(args) > 0 { filterFileNames = append(filterFileNames, args...) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
coredns_plugin/coredns_plugin.go
} filterFileNames := []string{} for c.Next() { args := c.RemainingArgs() if len(args) > 0 { filterFileNames = append(filterFileNames, args...) } for c.NextBlock() { switch c.Val() { case "safebrowsing": p.d.EnableSafeBrowsing() if c.NextArg() {
</s> remove switch c.Val() { </s> add blockValue := c.Val() switch blockValue { </s> remove filterFileNames := []string{} </s> add log.Println("Initializing the CoreDNS plugin") </s> remove log.Printf("filterFileNames = %+v", filterFileNames) </s> add for _, filter := range p.settings.Filters { log.Printf("Loading rules from %s", filter.Path) </s> remove for i, filterFileName := range filterFileNames { file, err := os.Open(filterFileName) </s> add file, err := os.Open(filter.Path) </s> remove err := writeFilterFile() if err != nil { errortext := fmt.Sprintf("Couldn't write filter file: %s", err) log.Println(errortext) } </s> add
} filterFileNames := []string{} for c.Next() { for c.NextBlock() { switch c.Val() { case "safebrowsing": p.d.EnableSafeBrowsing() if c.NextArg() {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
coredns_plugin/coredns_plugin.go
if len(args) > 0 { filterFileNames = append(filterFileNames, args...) } for c.NextBlock() { switch c.Val() { case "safebrowsing": p.d.EnableSafeBrowsing() if c.NextArg() { if len(c.Val()) == 0 { return nil, c.ArgErr()
</s> remove args := c.RemainingArgs() if len(args) > 0 { filterFileNames = append(filterFileNames, args...) } </s> add </s> remove filterFileNames := []string{} </s> add log.Println("Initializing the CoreDNS plugin") </s> remove err = d.AddRule(line, 0) if err == dnsfilter.ErrAlreadyExists || err == dnsfilter.ErrInvalidSyntax { continue } if err != nil { log.Printf("Cannot add rule %s from %s: %s", line, filter.URL, err) // Just ignore invalid rules continue } </s> add </s> remove d := dnsfilter.New() </s> add // Count lines in the filter </s> remove log.Printf("filterFileNames = %+v", filterFileNames) </s> add for _, filter := range p.settings.Filters { log.Printf("Loading rules from %s", filter.Path)
blockValue := c.Val() switch blockValue {
if len(args) > 0 { filterFileNames = append(filterFileNames, args...) } for c.NextBlock() { blockValue := c.Val() switch blockValue { case "safebrowsing": p.d.EnableSafeBrowsing() if c.NextArg() { if len(c.Val()) == 0 { return nil, c.ArgErr()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
coredns_plugin/coredns_plugin.go
} } } log.Printf("filterFileNames = %+v", filterFileNames) for i, filterFileName := range filterFileNames { file, err := os.Open(filterFileName) if err != nil { return nil, err
</s> remove for i, filterFileName := range filterFileNames { file, err := os.Open(filterFileName) </s> add file, err := os.Open(filter.Path) </s> remove if doConfigRename { err := renameOldConfigIfNeccessary() if err != nil { panic(err) } } </s> add </s> remove config.RUnlock() err := ioutil.WriteFile(filterpath+".tmp", data, 0644) if err != nil { log.Printf("Couldn't write filter file: %s", err) </s> add filterFilePath := filter.getFilterFilePath() log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath) if _, err := os.Stat(filterFilePath); os.IsNotExist(err) { // do nothing, file doesn't exist </s> remove return err </s> add return nil
for _, filter := range p.settings.Filters { log.Printf("Loading rules from %s", filter.Path)
} } } for _, filter := range p.settings.Filters { log.Printf("Loading rules from %s", filter.Path) for i, filterFileName := range filterFileNames { file, err := os.Open(filterFileName) if err != nil { return nil, err
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
coredns_plugin/coredns_plugin.go
} log.Printf("filterFileNames = %+v", filterFileNames) for i, filterFileName := range filterFileNames { file, err := os.Open(filterFileName) if err != nil { return nil, err } defer file.Close()
</s> remove log.Printf("filterFileNames = %+v", filterFileNames) </s> add for _, filter := range p.settings.Filters { log.Printf("Loading rules from %s", filter.Path) </s> remove config.RUnlock() err := ioutil.WriteFile(filterpath+".tmp", data, 0644) if err != nil { log.Printf("Couldn't write filter file: %s", err) </s> add filterFilePath := filter.getFilterFilePath() log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath) if _, err := os.Stat(filterFilePath); os.IsNotExist(err) { // do nothing, file doesn't exist </s> remove if doConfigRename { err := renameOldConfigIfNeccessary() if err != nil { panic(err) } } </s> add </s> remove return err </s> add return nil
file, err := os.Open(filter.Path)
} log.Printf("filterFileNames = %+v", filterFileNames) file, err := os.Open(filter.Path) file, err := os.Open(filter.Path) if err != nil { return nil, err } defer file.Close()
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
coredns_plugin/coredns_plugin.go
if err != nil { return nil, err } defer file.Close() count := 0 scanner := bufio.NewScanner(file)
</s> remove for i, filterFileName := range filterFileNames { file, err := os.Open(filterFileName) </s> add file, err := os.Open(filter.Path) </s> remove err = p.d.AddRule(text, uint32(i)) </s> add err = p.d.AddRule(text, filter.ID) </s> remove log.Printf("filterFileNames = %+v", filterFileNames) </s> add for _, filter := range p.settings.Filters { log.Printf("Loading rules from %s", filter.Path) </s> remove err := writeFilterFile() if err != nil { errortext := fmt.Sprintf("Couldn't write filter file: %s", err) log.Println(errortext) } </s> add </s> remove return err </s> add return nil
//noinspection GoDeferInLoop
if err != nil { return nil, err } //noinspection GoDeferInLoop defer file.Close() count := 0 scanner := bufio.NewScanner(file)
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
coredns_plugin/coredns_plugin.go
scanner := bufio.NewScanner(file) for scanner.Scan() { text := scanner.Text() err = p.d.AddRule(text, uint32(i)) if err == dnsfilter.ErrAlreadyExists || err == dnsfilter.ErrInvalidSyntax { continue } if err != nil { log.Printf("Cannot add rule %s: %s", text, err)
</s> remove err = d.AddRule(line, 0) if err == dnsfilter.ErrAlreadyExists || err == dnsfilter.ErrInvalidSyntax { continue } if err != nil { log.Printf("Cannot add rule %s from %s: %s", line, filter.URL, err) // Just ignore invalid rules continue } </s> add </s> remove config.RUnlock() err := ioutil.WriteFile(filterpath+".tmp", data, 0644) if err != nil { log.Printf("Couldn't write filter file: %s", err) </s> add filterFilePath := filter.getFilterFilePath() log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath) if _, err := os.Stat(filterFilePath); os.IsNotExist(err) { // do nothing, file doesn't exist </s> remove updated, err := filter.update(now) </s> add updated, err := filter.update(false) </s> remove err = os.Rename(oldConfigFile, newConfigFile) if err != nil { log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err) return err </s> add // Perform upgrade operations for each consecutive version upgrade for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; { err := upgradeConfigSchema(oldVersion, newVersion) if err != nil { log.Fatal(err) } // Increment old and new versions oldVersion++ newVersion++ } // Save the current schema version config.SchemaVersion = SchemaVersion return nil } // Upgrade from oldVersion to newVersion func upgradeConfigSchema(oldVersion int, newVersion int) error { if oldVersion == 0 && newVersion == 1 { log.Printf("Updating schema from %d to %d", oldVersion, newVersion) // The first schema upgrade: // Added "ID" field to "filter" -- we need to populate this field now // Added "config.ourDataDir" -- where we will now store filters contents for i := range config.Filters { filter := &config.Filters[i] // otherwise we will be operating on a copy log.Printf("Seting ID=%d for filter %s", i, filter.URL) filter.ID = i + 1 // start with ID=1 // Forcibly update the filter _, err := filter.update(true) if err != nil { log.Fatal(err) } } // No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/ dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt") _, err := os.Stat(dnsFilterPath) if !os.IsNotExist(err) { log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath) err = os.Remove(dnsFilterPath) if err != nil { log.Printf("Cannot remove %s due to %s", dnsFilterPath, err) } }
err = p.d.AddRule(text, filter.ID)
scanner := bufio.NewScanner(file) for scanner.Scan() { text := scanner.Text() err = p.d.AddRule(text, filter.ID) if err == dnsfilter.ErrAlreadyExists || err == dnsfilter.ErrInvalidSyntax { continue } if err != nil { log.Printf("Cannot add rule %s: %s", text, err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
coredns_plugin/coredns_plugin.go
continue } count++ } log.Printf("Added %d rules from %s", count, filterFileName) if err = scanner.Err(); err != nil { return nil, err } }
</s> remove err = d.AddRule(line, 0) if err == dnsfilter.ErrAlreadyExists || err == dnsfilter.ErrInvalidSyntax { continue } if err != nil { log.Printf("Cannot add rule %s from %s: %s", line, filter.URL, err) // Just ignore invalid rules continue } </s> add </s> remove log.Printf("filterFileNames = %+v", filterFileNames) </s> add for _, filter := range p.settings.Filters { log.Printf("Loading rules from %s", filter.Path) </s> remove for i, filterFileName := range filterFileNames { file, err := os.Open(filterFileName) </s> add file, err := os.Open(filter.Path) </s> remove err = writeFilterFile() if err != nil { errortext := fmt.Sprintf("Couldn't write filter file: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) return } </s> add </s> remove log.Printf("Couldn't write DNS config: %s", err) } err = os.Rename(corefile+".tmp", corefile) if err != nil { log.Printf("Couldn't rename DNS config: %s", err) </s> add log.Printf("Couldn't save DNS config: %s", err) return err
log.Printf("Added %d rules from %d", count, filter.ID)
continue } count++ } log.Printf("Added %d rules from %d", count, filter.ID) if err = scanner.Err(); err != nil { return nil, err } }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
coredns_plugin/coredns_plugin.go
} type statsFunc func(ch interface{}, name string, text string, value float64, valueType prometheus.ValueType) func doDesc(ch interface{}, name string, text string, value float64, valueType prometheus.ValueType) { realch, ok := ch.(chan<- *prometheus.Desc) if !ok { log.Printf("Couldn't convert ch to chan<- *prometheus.Desc\n") return
</s> remove func clamp(value, low, high int) int { if value < low { return low </s> add // ---------------------------------- // helper functions for working with files // ---------------------------------- // Writes data first to a temporary file and then renames it to what's specified in path func writeFileSafe(path string, data []byte) error { dir := filepath.Dir(path) err := os.MkdirAll(dir, 0755) if err != nil { return err } tmpPath := path + ".tmp" err = ioutil.WriteFile(tmpPath, data, 0644) if err != nil { return err </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 if value > high { return high </s> add err = os.Rename(tmpPath, path) if err != nil { return err </s> remove // extract filter name and count number of rules </s> add // Extract filter name and count number of rules </s> remove return value </s> add return nil
//noinspection GoUnusedParameter
} type statsFunc func(ch interface{}, name string, text string, value float64, valueType prometheus.ValueType) //noinspection GoUnusedParameter func doDesc(ch interface{}, name string, text string, value float64, valueType prometheus.ValueType) { realch, ok := ch.(chan<- *prometheus.Desc) if !ok { log.Printf("Couldn't convert ch to chan<- *prometheus.Desc\n") return
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
coredns_plugin/coredns_plugin.go
func (p *plug) serveDNSInternal(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, dnsfilter.Result, error) { if len(r.Question) != 1 { // google DNS, bind and others do the same return dns.RcodeFormatError, dnsfilter.Result{}, fmt.Errorf("Got DNS request with != 1 questions") } for _, question := range r.Question { host := strings.ToLower(strings.TrimSuffix(question.Name, ".")) // is it a safesearch domain? p.RLock()
</s> remove err = os.Rename(oldConfigFile, newConfigFile) if err != nil { log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err) return err </s> add // Perform upgrade operations for each consecutive version upgrade for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; { err := upgradeConfigSchema(oldVersion, newVersion) if err != nil { log.Fatal(err) } // Increment old and new versions oldVersion++ newVersion++ } // Save the current schema version config.SchemaVersion = SchemaVersion return nil } // Upgrade from oldVersion to newVersion func upgradeConfigSchema(oldVersion int, newVersion int) error { if oldVersion == 0 && newVersion == 1 { log.Printf("Updating schema from %d to %d", oldVersion, newVersion) // The first schema upgrade: // Added "ID" field to "filter" -- we need to populate this field now // Added "config.ourDataDir" -- where we will now store filters contents for i := range config.Filters { filter := &config.Filters[i] // otherwise we will be operating on a copy log.Printf("Seting ID=%d for filter %s", i, filter.URL) filter.ID = i + 1 // start with ID=1 // Forcibly update the filter _, err := filter.update(true) if err != nil { log.Fatal(err) } } // No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/ dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt") _, err := os.Stat(dnsFilterPath) if !os.IsNotExist(err) { log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath) err = os.Remove(dnsFilterPath) if err != nil { log.Printf("Cannot remove %s due to %s", dnsFilterPath, err) } } </s> remove func clamp(value, low, high int) int { if value < low { return low </s> add // ---------------------------------- // helper functions for working with files // ---------------------------------- // Writes data first to a temporary file and then renames it to what's specified in path func writeFileSafe(path string, data []byte) error { dir := filepath.Dir(path) err := os.MkdirAll(dir, 0755) if err != nil { return err } tmpPath := path + ".tmp" err = ioutil.WriteFile(tmpPath, data, 0644) if err != nil { return err </s> remove err := writeConfig() </s> add // Do the upgrade if necessary err := upgradeConfig() if err != nil { log.Fatal(err) } // Save the updated config err = writeConfig() </s> remove elapsed := time.Since(filter.LastUpdated) if elapsed <= updatePeriod { </s> add if !force && time.Since(filter.LastUpdated) <= updatePeriod { </s> remove func (filter *filter) update(now time.Time) (bool, error) { </s> add // Checks for filters updates // If "force" is true -- does not check the filter's LastUpdated field func (filter *filter) update(force bool) (bool, error) {
return dns.RcodeFormatError, dnsfilter.Result{}, fmt.Errorf("got a DNS request with more than one Question")
func (p *plug) serveDNSInternal(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, dnsfilter.Result, error) { if len(r.Question) != 1 { // google DNS, bind and others do the same return dns.RcodeFormatError, dnsfilter.Result{}, fmt.Errorf("got a DNS request with more than one Question") } for _, question := range r.Question { host := strings.ToLower(strings.TrimSuffix(question.Name, ".")) // is it a safesearch domain? p.RLock()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
coredns_plugin/coredns_plugin.go
) func TestSetup(t *testing.T) { for i, testcase := range []struct { config string failing bool }{ {`dnsfilter`, false},
</s> remove log.Printf("filterFileNames = %+v", filterFileNames) </s> add for _, filter := range p.settings.Filters { log.Printf("Loading rules from %s", filter.Path) </s> remove for i, filterFileName := range filterFileNames { file, err := os.Open(filterFileName) </s> add file, err := os.Open(filter.Path) </s> remove FilterFile string `yaml:"-"` Port int `yaml:"port"` ProtectionEnabled bool `yaml:"protection_enabled"` FilteringEnabled bool `yaml:"filtering_enabled"` SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"` SafeSearchEnabled bool `yaml:"safesearch_enabled"` ParentalEnabled bool `yaml:"parental_enabled"` ParentalSensitivity int `yaml:"parental_sensitivity"` BlockedResponseTTL int `yaml:"blocked_response_ttl"` QueryLogEnabled bool `yaml:"querylog_enabled"` Pprof string `yaml:"-"` Cache string `yaml:"-"` Prometheus string `yaml:"-"` UpstreamDNS []string `yaml:"upstream_dns"` </s> add Filters []coreDnsFilter `yaml:"-"` Port int `yaml:"port"` ProtectionEnabled bool `yaml:"protection_enabled"` FilteringEnabled bool `yaml:"filtering_enabled"` SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"` SafeSearchEnabled bool `yaml:"safesearch_enabled"` ParentalEnabled bool `yaml:"parental_enabled"` ParentalSensitivity int `yaml:"parental_sensitivity"` BlockedResponseTTL int `yaml:"blocked_response_ttl"` QueryLogEnabled bool `yaml:"querylog_enabled"` Pprof string `yaml:"-"` Cache string `yaml:"-"` Prometheus string `yaml:"-"` UpstreamDNS []string `yaml:"upstream_dns"`
// TODO: Change tests -- there's new config template now
) // TODO: Change tests -- there's new config template now func TestSetup(t *testing.T) { for i, testcase := range []struct { config string failing bool }{ {`dnsfilter`, false},
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
coredns_plugin/coredns_plugin_test.go
"bufio" "errors" "fmt" "io" "net/http" "os" "path" "path/filepath" "runtime"
</s> remove func clamp(value, low, high int) int { if value < low { return low </s> add // ---------------------------------- // helper functions for working with files // ---------------------------------- // Writes data first to a temporary file and then renames it to what's specified in path func writeFileSafe(path string, data []byte) error { dir := filepath.Dir(path) err := os.MkdirAll(dir, 0755) if err != nil { return err } tmpPath := path + ".tmp" err = ioutil.WriteFile(tmpPath, data, 0644) if err != nil { return err </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 {{if .ProtectionEnabled}}dnsfilter {{if .FilteringEnabled}}{{.FilterFile}}{{end}} { </s> add {{if .ProtectionEnabled}}dnsfilter {
"io/ioutil"
"bufio" "errors" "fmt" "io" "io/ioutil" "net/http" "os" "path" "path/filepath" "runtime"
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
helpers.go
"io/ioutil" "net/http" "os" "path" "runtime" "strings" )
</s> remove "github.com/AdguardTeam/AdGuardHome/dnsfilter" </s> add </s> remove func clamp(value, low, high int) int { if value < low { return low </s> add // ---------------------------------- // helper functions for working with files // ---------------------------------- // Writes data first to a temporary file and then renames it to what's specified in path func writeFileSafe(path string, data []byte) error { dir := filepath.Dir(path) err := os.MkdirAll(dir, 0755) if err != nil { return err } tmpPath := path + ".tmp" err = ioutil.WriteFile(tmpPath, data, 0644) if err != nil { return err </s> remove "gopkg.in/yaml.v2" </s> add
"path/filepath"
"io/ioutil" "net/http" "os" "path" "path/filepath" "runtime" "strings" )
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
helpers.go
"runtime" "strings" ) func clamp(value, low, high int) int { if value < low { return low } if value > high { return high } return value
</s> remove if value > high { return high </s> add err = os.Rename(tmpPath, path) if err != nil { return err </s> remove return value </s> add return nil </s> remove err := writeFilterFile() if err != nil { errortext := fmt.Sprintf("Couldn't write filter file: %s", err) log.Println(errortext) } </s> add </s> remove switch c.Val() { </s> add blockValue := c.Val() switch blockValue {
// ---------------------------------- // helper functions for working with files // ---------------------------------- // Writes data first to a temporary file and then renames it to what's specified in path func writeFileSafe(path string, data []byte) error { dir := filepath.Dir(path) err := os.MkdirAll(dir, 0755) if err != nil { return err } tmpPath := path + ".tmp" err = ioutil.WriteFile(tmpPath, data, 0644) if err != nil { return err
"runtime" "strings" ) // ---------------------------------- // helper functions for working with files // ---------------------------------- // Writes data first to a temporary file and then renames it to what's specified in path func writeFileSafe(path string, data []byte) error { dir := filepath.Dir(path) err := os.MkdirAll(dir, 0755) if err != nil { return err } tmpPath := path + ".tmp" err = ioutil.WriteFile(tmpPath, data, 0644) if err != nil { return err // ---------------------------------- // helper functions for working with files // ---------------------------------- // Writes data first to a temporary file and then renames it to what's specified in path func writeFileSafe(path string, data []byte) error { dir := filepath.Dir(path) err := os.MkdirAll(dir, 0755) if err != nil { return err } tmpPath := path + ".tmp" err = ioutil.WriteFile(tmpPath, data, 0644) if err != nil { return err // ---------------------------------- // helper functions for working with files // ---------------------------------- // Writes data first to a temporary file and then renames it to what's specified in path func writeFileSafe(path string, data []byte) error { dir := filepath.Dir(path) err := os.MkdirAll(dir, 0755) if err != nil { return err } tmpPath := path + ".tmp" err = ioutil.WriteFile(tmpPath, data, 0644) if err != nil { return err } if value > high { return high } return value
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
helpers.go
func clamp(value, low, high int) int { if value < low { return low } if value > high { return high } return value } // ----------------------------------
</s> remove func clamp(value, low, high int) int { if value < low { return low </s> add // ---------------------------------- // helper functions for working with files // ---------------------------------- // Writes data first to a temporary file and then renames it to what's specified in path func writeFileSafe(path string, data []byte) error { dir := filepath.Dir(path) err := os.MkdirAll(dir, 0755) if err != nil { return err } tmpPath := path + ".tmp" err = ioutil.WriteFile(tmpPath, data, 0644) if err != nil { return err </s> remove return value </s> add return nil </s> remove err := writeFilterFile() if err != nil { errortext := fmt.Sprintf("Couldn't write filter file: %s", err) log.Println(errortext) } </s> add </s> remove func (filter *filter) update(now time.Time) (bool, error) { </s> add // Checks for filters updates // If "force" is true -- does not check the filter's LastUpdated field func (filter *filter) update(force bool) (bool, error) {
err = os.Rename(tmpPath, path) if err != nil { return err
func clamp(value, low, high int) int { if value < low { return low } err = os.Rename(tmpPath, path) if err != nil { return err err = os.Rename(tmpPath, path) if err != nil { return err } return value } // ----------------------------------
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
helpers.go
} if value > high { return high } return value } // ---------------------------------- // helper functions for HTTP handlers // ----------------------------------
</s> remove if value > high { return high </s> add err = os.Rename(tmpPath, path) if err != nil { return err </s> remove func clamp(value, low, high int) int { if value < low { return low </s> add // ---------------------------------- // helper functions for working with files // ---------------------------------- // Writes data first to a temporary file and then renames it to what's specified in path func writeFileSafe(path string, data []byte) error { dir := filepath.Dir(path) err := os.MkdirAll(dir, 0755) if err != nil { return err } tmpPath := path + ".tmp" err = ioutil.WriteFile(tmpPath, data, 0644) if err != nil { return err </s> remove func (filter *filter) update(now time.Time) (bool, error) { </s> add // Checks for filters updates // If "force" is true -- does not check the filter's LastUpdated field func (filter *filter) update(force bool) (bool, error) {
return nil
} if value > high { return high } return nil } // ---------------------------------- // helper functions for HTTP handlers // ----------------------------------
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
helpers.go
// --------------------- // debug logging helpers // --------------------- 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 trace(format string, args ...interface{}) { pc := make([]uintptr, 10) // at least 1 entry needed runtime.Callers(2, pc) f := runtime.FuncForPC(pc[0]) var buf strings.Builder
</s> remove func renameOldConfigIfNeccessary() error { oldConfigFile := filepath.Join(config.ourBinaryDir, "AdguardDNS.yaml") _, err := os.Stat(oldConfigFile) if os.IsNotExist(err) { // do nothing, file doesn't exist trace("File %s doesn't exist, nothing to do", oldConfigFile) </s> add // Performs necessary upgrade operations if needed func upgradeConfig() error { if config.SchemaVersion == SchemaVersion { // No upgrade, do nothing </s> remove // eat all args so that coredns can start happily </s> add // Eat all args so that coredns can start happily </s> remove return dns.RcodeFormatError, dnsfilter.Result{}, fmt.Errorf("Got DNS request with != 1 questions") </s> add return dns.RcodeFormatError, dnsfilter.Result{}, fmt.Errorf("got a DNS request with more than one Question") </s> remove err := writeConfig() </s> add // Do the upgrade if necessary err := upgradeConfig() if err != nil { log.Fatal(err) } // Save the updated config err = writeConfig()
// --------------------- // debug logging helpers // --------------------- func trace(format string, args ...interface{}) { pc := make([]uintptr, 10) // at least 1 entry needed runtime.Callers(2, pc) f := runtime.FuncForPC(pc[0]) var buf strings.Builder
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix #371 #421 Filters are now saved to a file Also, they're loaded from the file on startup Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly) Some minor refactoring, unused functions removed
https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913
helpers.go
// is not one of these, clientID is an empty string and err is nil. func (s *Server) clientIDFromDNSContext(pctx *proxy.DNSContext) (clientID string, err error) { proto := pctx.Proto if proto == proxy.ProtoHTTPS { return clientIDFromDNSContextHTTPS(pctx) } else if proto != proxy.ProtoTLS && proto != proxy.ProtoQUIC { return "", nil } hostSrvName := s.conf.ServerName
</s> remove cliSrvName := "" </s> add cliSrvName, err := clientServerName(pctx, proto) if err != nil { return "", err } clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) } return clientID, nil } // clientServerName returns the TLS server name based on the protocol. func clientServerName(pctx *proxy.DNSContext, proto proxy.Proto) (srvName string, err error) { </s> remove case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf( "proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn, ) </s> add case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName </s> remove return clientID, nil </s> add return srvName, nil </s> remove pctx.QUICConnection, </s> add qConn, </s> remove cliSrvName = conn.ConnectionState().TLS.ServerName } </s> add srvName = conn.ConnectionState().TLS.ServerName case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf("proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn) }
clientID, err = clientIDFromDNSContextHTTPS(pctx) if err != nil { return "", fmt.Errorf("checking url: %w", err) } else if clientID != "" { return clientID, nil } // Go on and check the domain name as well.
// is not one of these, clientID is an empty string and err is nil. func (s *Server) clientIDFromDNSContext(pctx *proxy.DNSContext) (clientID string, err error) { proto := pctx.Proto if proto == proxy.ProtoHTTPS { clientID, err = clientIDFromDNSContextHTTPS(pctx) if err != nil { return "", fmt.Errorf("checking url: %w", err) } else if clientID != "" { return clientID, nil } // Go on and check the domain name as well. } else if proto != proxy.ProtoTLS && proto != proxy.ProtoQUIC { return "", nil } hostSrvName := s.conf.ServerName
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid.go
if hostSrvName == "" { return "", nil } cliSrvName := "" switch proto { case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok {
</s> remove case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf( "proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn, ) </s> add case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName </s> remove cliSrvName = conn.ConnectionState().TLS.ServerName } </s> add srvName = conn.ConnectionState().TLS.ServerName case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf("proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn) } </s> remove return clientIDFromDNSContextHTTPS(pctx) </s> add clientID, err = clientIDFromDNSContextHTTPS(pctx) if err != nil { return "", fmt.Errorf("checking url: %w", err) } else if clientID != "" { return clientID, nil } // Go on and check the domain name as well. </s> remove conn, ok := pctx.QUICConnection.(quicConnection) </s> add qConn := pctx.QUICConnection conn, ok := qConn.(quicConnection) </s> remove cliSrvName = tc.ConnectionState().ServerName </s> add
cliSrvName, err := clientServerName(pctx, proto) if err != nil { return "", err } clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) } return clientID, nil } // clientServerName returns the TLS server name based on the protocol. func clientServerName(pctx *proxy.DNSContext, proto proxy.Proto) (srvName string, err error) {
if hostSrvName == "" { return "", nil } cliSrvName, err := clientServerName(pctx, proto) if err != nil { return "", err } clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) } return clientID, nil } // clientServerName returns the TLS server name based on the protocol. func clientServerName(pctx *proxy.DNSContext, proto proxy.Proto) (srvName string, err error) { switch proto { case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid.go
} cliSrvName := "" switch proto { case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf( "proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn, ) } cliSrvName = tc.ConnectionState().ServerName case proxy.ProtoQUIC: conn, ok := pctx.QUICConnection.(quicConnection)
</s> remove cliSrvName = tc.ConnectionState().ServerName </s> add </s> remove conn, ok := pctx.QUICConnection.(quicConnection) </s> add qConn := pctx.QUICConnection conn, ok := qConn.(quicConnection) </s> remove cliSrvName = conn.ConnectionState().TLS.ServerName } </s> add srvName = conn.ConnectionState().TLS.ServerName case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf("proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn) } </s> remove pctx.QUICConnection, </s> add qConn, </s> remove cliSrvName := "" </s> add cliSrvName, err := clientServerName(pctx, proto) if err != nil { return "", err } clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) } return clientID, nil } // clientServerName returns the TLS server name based on the protocol. func clientServerName(pctx *proxy.DNSContext, proto proxy.Proto) (srvName string, err error) {
case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName
} cliSrvName := "" switch proto { case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName } cliSrvName = tc.ConnectionState().ServerName case proxy.ProtoQUIC: conn, ok := pctx.QUICConnection.(quicConnection)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid.go
proto, conn, ) } cliSrvName = tc.ConnectionState().ServerName case proxy.ProtoQUIC: conn, ok := pctx.QUICConnection.(quicConnection) if !ok { return "", fmt.Errorf( "proxy ctx quic conn of proto %s is %T, want quic.Connection",
</s> remove conn, ok := pctx.QUICConnection.(quicConnection) </s> add qConn := pctx.QUICConnection conn, ok := qConn.(quicConnection) </s> remove pctx.QUICConnection, </s> add qConn, </s> remove case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf( "proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn, ) </s> add case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName </s> remove cliSrvName = conn.ConnectionState().TLS.ServerName } </s> add srvName = conn.ConnectionState().TLS.ServerName case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf("proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn) }
proto, conn, ) } case proxy.ProtoQUIC: conn, ok := pctx.QUICConnection.(quicConnection) if !ok { return "", fmt.Errorf( "proxy ctx quic conn of proto %s is %T, want quic.Connection",
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid.go
} cliSrvName = tc.ConnectionState().ServerName case proxy.ProtoQUIC: conn, ok := pctx.QUICConnection.(quicConnection) if !ok { return "", fmt.Errorf( "proxy ctx quic conn of proto %s is %T, want quic.Connection", proto, pctx.QUICConnection,
</s> remove cliSrvName = tc.ConnectionState().ServerName </s> add </s> remove pctx.QUICConnection, </s> add qConn, </s> remove case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf( "proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn, ) </s> add case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName </s> remove cliSrvName = conn.ConnectionState().TLS.ServerName } </s> add srvName = conn.ConnectionState().TLS.ServerName case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf("proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn) } </s> remove cliSrvName := "" </s> add cliSrvName, err := clientServerName(pctx, proto) if err != nil { return "", err } clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) } return clientID, nil } // clientServerName returns the TLS server name based on the protocol. func clientServerName(pctx *proxy.DNSContext, proto proxy.Proto) (srvName string, err error) {
qConn := pctx.QUICConnection conn, ok := qConn.(quicConnection)
} cliSrvName = tc.ConnectionState().ServerName case proxy.ProtoQUIC: qConn := pctx.QUICConnection conn, ok := qConn.(quicConnection) if !ok { return "", fmt.Errorf( "proxy ctx quic conn of proto %s is %T, want quic.Connection", proto, pctx.QUICConnection,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid.go
if !ok { return "", fmt.Errorf( "proxy ctx quic conn of proto %s is %T, want quic.Connection", proto, pctx.QUICConnection, ) } cliSrvName = conn.ConnectionState().TLS.ServerName }
</s> remove cliSrvName = tc.ConnectionState().ServerName </s> add </s> remove conn, ok := pctx.QUICConnection.(quicConnection) </s> add qConn := pctx.QUICConnection conn, ok := qConn.(quicConnection) </s> remove cliSrvName = conn.ConnectionState().TLS.ServerName } </s> add srvName = conn.ConnectionState().TLS.ServerName case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf("proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn) } </s> remove case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf( "proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn, ) </s> add case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName </s> remove clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) </s> add srvName = tc.ConnectionState().ServerName
qConn,
if !ok { return "", fmt.Errorf( "proxy ctx quic conn of proto %s is %T, want quic.Connection", proto, qConn, ) } cliSrvName = conn.ConnectionState().TLS.ServerName }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid.go
pctx.QUICConnection, ) } cliSrvName = conn.ConnectionState().TLS.ServerName } clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck,
</s> remove clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) </s> add srvName = tc.ConnectionState().ServerName </s> remove cliSrvName := "" </s> add cliSrvName, err := clientServerName(pctx, proto) if err != nil { return "", err } clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) } return clientID, nil } // clientServerName returns the TLS server name based on the protocol. func clientServerName(pctx *proxy.DNSContext, proto proxy.Proto) (srvName string, err error) { </s> remove pctx.QUICConnection, </s> add qConn, </s> remove return clientID, nil </s> add return srvName, nil </s> remove return clientIDFromDNSContextHTTPS(pctx) </s> add clientID, err = clientIDFromDNSContextHTTPS(pctx) if err != nil { return "", fmt.Errorf("checking url: %w", err) } else if clientID != "" { return clientID, nil } // Go on and check the domain name as well.
srvName = conn.ConnectionState().TLS.ServerName case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf("proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn) }
pctx.QUICConnection, ) } srvName = conn.ConnectionState().TLS.ServerName case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf("proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn) } srvName = conn.ConnectionState().TLS.ServerName case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf("proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn) } clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck,
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid.go
cliSrvName = conn.ConnectionState().TLS.ServerName } clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) } return clientID, nil }
</s> remove return clientID, nil </s> add return srvName, nil </s> remove cliSrvName := "" </s> add cliSrvName, err := clientServerName(pctx, proto) if err != nil { return "", err } clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) } return clientID, nil } // clientServerName returns the TLS server name based on the protocol. func clientServerName(pctx *proxy.DNSContext, proto proxy.Proto) (srvName string, err error) { </s> remove cliSrvName = conn.ConnectionState().TLS.ServerName } </s> add srvName = conn.ConnectionState().TLS.ServerName case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf("proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn) } </s> remove return clientIDFromDNSContextHTTPS(pctx) </s> add clientID, err = clientIDFromDNSContextHTTPS(pctx) if err != nil { return "", fmt.Errorf("checking url: %w", err) } else if clientID != "" { return clientID, nil } // Go on and check the domain name as well. </s> remove pctx.QUICConnection, </s> add qConn,
srvName = tc.ConnectionState().ServerName
cliSrvName = conn.ConnectionState().TLS.ServerName } srvName = tc.ConnectionState().ServerName srvName = tc.ConnectionState().ServerName srvName = tc.ConnectionState().ServerName srvName = tc.ConnectionState().ServerName srvName = tc.ConnectionState().ServerName srvName = tc.ConnectionState().ServerName srvName = tc.ConnectionState().ServerName } return clientID, nil }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid.go
if err != nil { return "", fmt.Errorf("clientid check: %w", err) } return clientID, nil }
</s> remove clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) </s> add srvName = tc.ConnectionState().ServerName </s> remove cliSrvName := "" </s> add cliSrvName, err := clientServerName(pctx, proto) if err != nil { return "", err } clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) } return clientID, nil } // clientServerName returns the TLS server name based on the protocol. func clientServerName(pctx *proxy.DNSContext, proto proxy.Proto) (srvName string, err error) { </s> remove return clientIDFromDNSContextHTTPS(pctx) </s> add clientID, err = clientIDFromDNSContextHTTPS(pctx) if err != nil { return "", fmt.Errorf("checking url: %w", err) } else if clientID != "" { return clientID, nil } // Go on and check the domain name as well. </s> remove case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf( "proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn, ) </s> add case proxy.ProtoHTTPS: if connState := pctx.HTTPRequest.TLS; connState != nil { srvName = pctx.HTTPRequest.TLS.ServerName </s> remove cliSrvName = conn.ConnectionState().TLS.ServerName } </s> add srvName = conn.ConnectionState().TLS.ServerName case proxy.ProtoTLS: conn := pctx.Conn tc, ok := conn.(tlsConn) if !ok { return "", fmt.Errorf("proxy ctx conn of proto %s is %T, want *tls.Conn", proto, conn) }
return srvName, nil
if err != nil { return "", fmt.Errorf("clientid check: %w", err) } return srvName, nil }
[ "keep", "keep", "keep", "keep", "replace", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid.go
srv := &Server{ conf: ServerConfig{TLSConfig: tlsConf}, } var conn net.Conn if tc.proto == proxy.ProtoTLS { conn = testTLSConn{ serverName: tc.cliSrvName, } } var qconn quic.Connection if tc.proto == proxy.ProtoQUIC {
</s> remove } </s> add </s> remove var qconn quic.Connection if tc.proto == proxy.ProtoQUIC { </s> add httpReq = &http.Request{ URL: u, TLS: connState, } case proxy.ProtoQUIC: </s> remove return clientIDFromDNSContextHTTPS(pctx) </s> add clientID, err = clientIDFromDNSContextHTTPS(pctx) if err != nil { return "", fmt.Errorf("checking url: %w", err) } else if clientID != "" { return clientID, nil } // Go on and check the domain name as well. </s> remove cliSrvName := "" </s> add cliSrvName, err := clientServerName(pctx, proto) if err != nil { return "", err } clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) } return clientID, nil } // clientServerName returns the TLS server name based on the protocol. func clientServerName(pctx *proxy.DNSContext, proto proxy.Proto) (srvName string, err error) {
var ( conn net.Conn qconn quic.Connection httpReq *http.Request ) switch tc.proto { case proxy.ProtoHTTPS: u := &url.URL{ Path: "/dns-query", } connState := &tls.ConnectionState{ ServerName: tc.cliSrvName,
srv := &Server{ conf: ServerConfig{TLSConfig: tlsConf}, } var ( conn net.Conn qconn quic.Connection httpReq *http.Request ) switch tc.proto { case proxy.ProtoHTTPS: u := &url.URL{ Path: "/dns-query", } connState := &tls.ConnectionState{ ServerName: tc.cliSrvName, var ( conn net.Conn qconn quic.Connection httpReq *http.Request ) switch tc.proto { case proxy.ProtoHTTPS: u := &url.URL{ Path: "/dns-query", } connState := &tls.ConnectionState{ ServerName: tc.cliSrvName, var ( conn net.Conn qconn quic.Connection httpReq *http.Request ) switch tc.proto { case proxy.ProtoHTTPS: u := &url.URL{ Path: "/dns-query", } connState := &tls.ConnectionState{ ServerName: tc.cliSrvName, var ( conn net.Conn qconn quic.Connection httpReq *http.Request ) switch tc.proto { case proxy.ProtoHTTPS: u := &url.URL{ Path: "/dns-query", } connState := &tls.ConnectionState{ ServerName: tc.cliSrvName, } } var qconn quic.Connection if tc.proto == proxy.ProtoQUIC {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
if tc.proto == proxy.ProtoTLS { conn = testTLSConn{ serverName: tc.cliSrvName, } } var qconn quic.Connection if tc.proto == proxy.ProtoQUIC { qconn = testQUICConnection{ serverName: tc.cliSrvName,
</s> remove var qconn quic.Connection if tc.proto == proxy.ProtoQUIC { </s> add httpReq = &http.Request{ URL: u, TLS: connState, } case proxy.ProtoQUIC: </s> remove var conn net.Conn if tc.proto == proxy.ProtoTLS { conn = testTLSConn{ serverName: tc.cliSrvName, </s> add var ( conn net.Conn qconn quic.Connection httpReq *http.Request ) switch tc.proto { case proxy.ProtoHTTPS: u := &url.URL{ Path: "/dns-query", } connState := &tls.ConnectionState{ ServerName: tc.cliSrvName, </s> remove return clientIDFromDNSContextHTTPS(pctx) </s> add clientID, err = clientIDFromDNSContextHTTPS(pctx) if err != nil { return "", fmt.Errorf("checking url: %w", err) } else if clientID != "" { return clientID, nil } // Go on and check the domain name as well. </s> remove cliSrvName := "" </s> add cliSrvName, err := clientServerName(pctx, proto) if err != nil { return "", err } clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) } return clientID, nil } // clientServerName returns the TLS server name based on the protocol. func clientServerName(pctx *proxy.DNSContext, proto proxy.Proto) (srvName string, err error) {
if tc.proto == proxy.ProtoTLS { conn = testTLSConn{ serverName: tc.cliSrvName, } var qconn quic.Connection if tc.proto == proxy.ProtoQUIC { qconn = testQUICConnection{ serverName: tc.cliSrvName,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
serverName: tc.cliSrvName, } } var qconn quic.Connection if tc.proto == proxy.ProtoQUIC { qconn = testQUICConnection{ serverName: tc.cliSrvName, } }
</s> remove } </s> add </s> remove var conn net.Conn if tc.proto == proxy.ProtoTLS { conn = testTLSConn{ serverName: tc.cliSrvName, </s> add var ( conn net.Conn qconn quic.Connection httpReq *http.Request ) switch tc.proto { case proxy.ProtoHTTPS: u := &url.URL{ Path: "/dns-query", } connState := &tls.ConnectionState{ ServerName: tc.cliSrvName, </s> remove return clientIDFromDNSContextHTTPS(pctx) </s> add clientID, err = clientIDFromDNSContextHTTPS(pctx) if err != nil { return "", fmt.Errorf("checking url: %w", err) } else if clientID != "" { return clientID, nil } // Go on and check the domain name as well.
httpReq = &http.Request{ URL: u, TLS: connState, } case proxy.ProtoQUIC:
serverName: tc.cliSrvName, } } httpReq = &http.Request{ URL: u, TLS: connState, } case proxy.ProtoQUIC: httpReq = &http.Request{ URL: u, TLS: connState, } case proxy.ProtoQUIC: qconn = testQUICConnection{ serverName: tc.cliSrvName, } }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
case proxy.ProtoQUIC: qconn = testQUICConnection{ serverName: tc.cliSrvName, } } pctx := &proxy.DNSContext{ Proto: tc.proto, Conn: conn, HTTPRequest: httpReq,
</s> remove var qconn quic.Connection if tc.proto == proxy.ProtoQUIC { </s> add httpReq = &http.Request{ URL: u, TLS: connState, } case proxy.ProtoQUIC: </s> remove } </s> add </s> remove var conn net.Conn if tc.proto == proxy.ProtoTLS { conn = testTLSConn{ serverName: tc.cliSrvName, </s> add var ( conn net.Conn qconn quic.Connection httpReq *http.Request ) switch tc.proto { case proxy.ProtoHTTPS: u := &url.URL{ Path: "/dns-query", } connState := &tls.ConnectionState{ ServerName: tc.cliSrvName,
case proxy.ProtoTLS: conn = testTLSConn{ serverName: tc.cliSrvName, }
case proxy.ProtoQUIC: qconn = testQUICConnection{ serverName: tc.cliSrvName, } case proxy.ProtoTLS: conn = testTLSConn{ serverName: tc.cliSrvName, } } pctx := &proxy.DNSContext{ Proto: tc.proto, Conn: conn, HTTPRequest: httpReq,
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
pctx := &proxy.DNSContext{ Proto: tc.proto, Conn: conn, QUICConnection: qconn, } clientID, err := srv.clientIDFromDNSContext(pctx) assert.Equal(t, tc.wantClientID, clientID)
</s> remove clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) </s> add srvName = tc.ConnectionState().ServerName </s> remove cliSrvName := "" </s> add cliSrvName, err := clientServerName(pctx, proto) if err != nil { return "", err } clientID, err = clientIDFromClientServerName( hostSrvName, cliSrvName, s.conf.StrictSNICheck, ) if err != nil { return "", fmt.Errorf("clientid check: %w", err) } return clientID, nil } // clientServerName returns the TLS server name based on the protocol. func clientServerName(pctx *proxy.DNSContext, proto proxy.Proto) (srvName string, err error) { </s> remove return clientID, nil </s> add return srvName, nil
HTTPRequest: httpReq,
pctx := &proxy.DNSContext{ Proto: tc.proto, Conn: conn, HTTPRequest: httpReq, QUICConnection: qconn, } clientID, err := srv.clientIDFromDNSContext(pctx) assert.Equal(t, tc.wantClientID, clientID)
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
name string path string wantClientID string wantErrMsg string }{{ name: "no_clientid",
</s> remove return clientIDFromDNSContextHTTPS(pctx) </s> add clientID, err = clientIDFromDNSContextHTTPS(pctx) if err != nil { return "", fmt.Errorf("checking url: %w", err) } else if clientID != "" { return clientID, nil } // Go on and check the domain name as well.
cliSrvName string
name string path string cliSrvName string wantClientID string wantErrMsg string }{{ name: "no_clientid",
[ "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
name: "no_clientid", path: "/dns-query", wantClientID: "", wantErrMsg: "", }, { name: "no_clientid_slash", path: "/dns-query/", cliSrvName: "example.com",
</s>
cliSrvName: "example.com",
name: "no_clientid", path: "/dns-query", cliSrvName: "example.com", wantClientID: "", wantErrMsg: "", }, { name: "no_clientid_slash", path: "/dns-query/", cliSrvName: "example.com",
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
wantErrMsg: "", }, { name: "no_clientid_slash", path: "/dns-query/", wantClientID: "", wantErrMsg: "", }, { name: "clientid", path: "/dns-query/cli",
</s>
cliSrvName: "example.com",
wantErrMsg: "", }, { name: "no_clientid_slash", path: "/dns-query/", cliSrvName: "example.com", wantClientID: "", wantErrMsg: "", }, { name: "clientid", path: "/dns-query/cli",
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
name: "clientid", path: "/dns-query/cli", wantClientID: "cli", wantErrMsg: "", }, { name: "clientid_slash",
</s>
cliSrvName: "example.com",
name: "clientid", path: "/dns-query/cli", cliSrvName: "example.com", wantClientID: "cli", wantErrMsg: "", }, { name: "clientid_slash",
[ "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
wantErrMsg: "", }, { name: "clientid_slash", path: "/dns-query/cli/", wantClientID: "cli", wantErrMsg: "", }, { name: "clientid_case", path: "/dns-query/InSeNsItIvE", cliSrvName: "example.com",
</s>
cliSrvName: "example.com",
wantErrMsg: "", }, { name: "clientid_slash", path: "/dns-query/cli/", cliSrvName: "example.com", wantClientID: "cli", wantErrMsg: "", }, { name: "clientid_case", path: "/dns-query/InSeNsItIvE", cliSrvName: "example.com",
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
name: "clientid_case", path: "/dns-query/InSeNsItIvE", wantClientID: "insensitive", wantErrMsg: ``, }, { name: "bad_url", path: "/foo", cliSrvName: "example.com",
</s>
cliSrvName: "example.com",
name: "clientid_case", path: "/dns-query/InSeNsItIvE", cliSrvName: "example.com", wantClientID: "insensitive", wantErrMsg: ``, }, { name: "bad_url", path: "/foo", cliSrvName: "example.com",
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
wantErrMsg: ``, }, { name: "bad_url", path: "/foo", wantClientID: "", wantErrMsg: `clientid check: invalid path "/foo"`, }, { name: "extra",
</s>
cliSrvName: "example.com",
wantErrMsg: ``, }, { name: "bad_url", path: "/foo", cliSrvName: "example.com", wantClientID: "", wantErrMsg: `clientid check: invalid path "/foo"`, }, { name: "extra",
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
name: "extra", path: "/dns-query/cli/foo", wantClientID: "", wantErrMsg: `clientid check: invalid path "/dns-query/cli/foo": extra parts`, }, { name: "invalid_clientid", path: "/dns-query/!!!",
</s>
cliSrvName: "example.com",
name: "extra", path: "/dns-query/cli/foo", cliSrvName: "example.com", wantClientID: "", wantErrMsg: `clientid check: invalid path "/dns-query/cli/foo": extra parts`, }, { name: "invalid_clientid", path: "/dns-query/!!!",
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
name: "invalid_clientid", path: "/dns-query/!!!", wantClientID: "", wantErrMsg: `clientid check: invalid clientid "!!!": bad domain name label rune '!'`, }, { name: "both_ids", path: "/dns-query/right",
</s>
cliSrvName: "example.com",
name: "invalid_clientid", path: "/dns-query/!!!", cliSrvName: "example.com", wantClientID: "", wantErrMsg: `clientid check: invalid clientid "!!!": bad domain name label rune '!'`, }, { name: "both_ids", path: "/dns-query/right",
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
cliSrvName: "example.com", wantClientID: "", wantErrMsg: `clientid check: invalid clientid "!!!": bad domain name label rune '!'`, }} for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { connState := &tls.ConnectionState{ ServerName: tc.cliSrvName,
</s> remove var conn net.Conn if tc.proto == proxy.ProtoTLS { conn = testTLSConn{ serverName: tc.cliSrvName, </s> add var ( conn net.Conn qconn quic.Connection httpReq *http.Request ) switch tc.proto { case proxy.ProtoHTTPS: u := &url.URL{ Path: "/dns-query", } connState := &tls.ConnectionState{ ServerName: tc.cliSrvName,
}, { name: "both_ids", path: "/dns-query/right", cliSrvName: "wrong.example.com", wantClientID: "right", wantErrMsg: "",
cliSrvName: "example.com", wantClientID: "", wantErrMsg: `clientid check: invalid clientid "!!!": bad domain name label rune '!'`, }, { name: "both_ids", path: "/dns-query/right", cliSrvName: "wrong.example.com", wantClientID: "right", wantErrMsg: "", }} for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { connState := &tls.ConnectionState{ ServerName: tc.cliSrvName,
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
}} for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { r := &http.Request{ URL: &url.URL{ Path: tc.path, },
</s> remove var qconn quic.Connection if tc.proto == proxy.ProtoQUIC { </s> add httpReq = &http.Request{ URL: u, TLS: connState, } case proxy.ProtoQUIC: </s> remove var conn net.Conn if tc.proto == proxy.ProtoTLS { conn = testTLSConn{ serverName: tc.cliSrvName, </s> add var ( conn net.Conn qconn quic.Connection httpReq *http.Request ) switch tc.proto { case proxy.ProtoHTTPS: u := &url.URL{ Path: "/dns-query", } connState := &tls.ConnectionState{ ServerName: tc.cliSrvName,
connState := &tls.ConnectionState{ ServerName: tc.cliSrvName, }
}} for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { connState := &tls.ConnectionState{ ServerName: tc.cliSrvName, } r := &http.Request{ URL: &url.URL{ Path: tc.path, },
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
URL: &url.URL{ Path: tc.path, }, } pctx := &proxy.DNSContext{ Proto: proxy.ProtoHTTPS, HTTPRequest: r,
</s> remove var conn net.Conn if tc.proto == proxy.ProtoTLS { conn = testTLSConn{ serverName: tc.cliSrvName, </s> add var ( conn net.Conn qconn quic.Connection httpReq *http.Request ) switch tc.proto { case proxy.ProtoHTTPS: u := &url.URL{ Path: "/dns-query", } connState := &tls.ConnectionState{ ServerName: tc.cliSrvName, </s> remove var qconn quic.Connection if tc.proto == proxy.ProtoQUIC { </s> add httpReq = &http.Request{ URL: u, TLS: connState, } case proxy.ProtoQUIC:
TLS: connState,
URL: &url.URL{ Path: tc.path, }, TLS: connState, } pctx := &proxy.DNSContext{ Proto: proxy.ProtoHTTPS, HTTPRequest: r,
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: 3418-clientid-doh Closes #3418. Squashed commit of the following: commit 8a1180f8ef03d30ea3ae6a3e3121ddcac513f45b Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 17:26:22 2022 +0300 all: imp docs, tests commit 9629c69b39540db119044f2f79c1c4ed39de911f Author: Ainar Garipov <[email protected]> Date: Wed Oct 5 15:34:33 2022 +0300 dnsforward: accept clientids from doh client srvname
https://github.com/AdguardTeam/AdGuardHome/commit/330ac303242970d79b557e611bec3227b0af5a7b
internal/dnsforward/clientid_test.go
:root { --yellow-pale: rgba(247, 181, 0, 0.1); --green79: #67B279; --gray-a5: #a5a5a5; --gray-d8: #d8d8d8; --gray-f3: #F3F3F3; --font-family-monospace: Monaco, Menlo, "Ubuntu Mono", Consolas, source-code-pro, monospace; }
</s> remove --gray-f3: #F3F3F3; </s> add --gray-f3: #f3f3f3; </s> remove --btn-unblock-disabled: #D8D8D8; --btn-unblock-active: #4D4D4D; </s> add --btn-unblock-disabled: #d8d8d8; --btn-unblock-active: #4d4d4d; </s> remove content: ':'; </s> add content: ":"; </s> remove .dashboard-title__button{ </s> add .dashboard-title__button { </s> remove .dashboard-title__button{ </s> add .dashboard-title__button {
--green79: #67b279;
:root { --yellow-pale: rgba(247, 181, 0, 0.1); --green79: #67b279; --gray-a5: #a5a5a5; --gray-d8: #d8d8d8; --gray-f3: #F3F3F3; --font-family-monospace: Monaco, Menlo, "Ubuntu Mono", Consolas, source-code-pro, monospace; }
[ "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix a couple of stylelint violations
https://github.com/AdguardTeam/AdGuardHome/commit/334b3fc636025657ac6af2df0b90ec01332c8187
client/src/components/App/index.css
--yellow-pale: rgba(247, 181, 0, 0.1); --green79: #67B279; --gray-a5: #a5a5a5; --gray-d8: #d8d8d8; --gray-f3: #F3F3F3; --font-family-monospace: Monaco, Menlo, "Ubuntu Mono", Consolas, source-code-pro, monospace; } body { margin: 0;
</s> remove --green79: #67B279; </s> add --green79: #67b279; </s> remove .dashboard-title__button{ </s> add .dashboard-title__button { </s> remove .dashboard-title__button{ </s> add .dashboard-title__button { </s> remove content: ''; </s> add content: ""; </s> remove --btn-unblock-disabled: #D8D8D8; --btn-unblock-active: #4D4D4D; </s> add --btn-unblock-disabled: #d8d8d8; --btn-unblock-active: #4d4d4d;
--gray-f3: #f3f3f3;
--yellow-pale: rgba(247, 181, 0, 0.1); --green79: #67B279; --gray-a5: #a5a5a5; --gray-d8: #d8d8d8; --gray-f3: #f3f3f3; --font-family-monospace: Monaco, Menlo, "Ubuntu Mono", Consolas, source-code-pro, monospace; } body { margin: 0;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix a couple of stylelint violations
https://github.com/AdguardTeam/AdGuardHome/commit/334b3fc636025657ac6af2df0b90ec01332c8187
client/src/components/App/index.css
display: flex; align-items: center; } .dashboard-title__button{ margin: 0 0.5rem; } @media (max-width: 767.98px) { .page-title--dashboard {
</s> remove .dashboard-title__button{ </s> add .dashboard-title__button { </s> remove --btn-unblock-disabled: #D8D8D8; --btn-unblock-active: #4D4D4D; </s> add --btn-unblock-disabled: #d8d8d8; --btn-unblock-active: #4d4d4d; </s> remove content: ':'; </s> add content: ":"; </s> remove background: var(--white) url('../ui/svg/chevron-down.svg') no-repeat; </s> add background: var(--white) url("../ui/svg/chevron-down.svg") no-repeat; </s> remove --gray-f3: #F3F3F3; </s> add --gray-f3: #f3f3f3;
.dashboard-title__button {
display: flex; align-items: center; } .dashboard-title__button { margin: 0 0.5rem; } @media (max-width: 767.98px) { .page-title--dashboard {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix a couple of stylelint violations
https://github.com/AdguardTeam/AdGuardHome/commit/334b3fc636025657ac6af2df0b90ec01332c8187
client/src/components/Dashboard/Dashboard.css
flex-direction: column; align-items: flex-start; } .dashboard-title__button{ margin: 0.5rem 0; display: block; } }
</s> remove .dashboard-title__button{ </s> add .dashboard-title__button { </s> remove --gray-f3: #F3F3F3; </s> add --gray-f3: #f3f3f3; </s> remove content: ':'; </s> add content: ":"; </s> remove content: ''; </s> add content: ""; </s> remove background: var(--white) url('../ui/svg/chevron-down.svg') no-repeat; </s> add background: var(--white) url("../ui/svg/chevron-down.svg") no-repeat;
.dashboard-title__button {
flex-direction: column; align-items: flex-start; } .dashboard-title__button { margin: 0.5rem 0; display: block; } }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ]
Fix a couple of stylelint violations
https://github.com/AdguardTeam/AdGuardHome/commit/334b3fc636025657ac6af2df0b90ec01332c8187
client/src/components/Dashboard/Dashboard.css
} } .grid .key-colon:nth-child(odd)::after { content: ':'; } .grid__one-row { grid-template-columns: 15rem; }
</s> remove content: ''; </s> add content: ""; </s> remove .dashboard-title__button{ </s> add .dashboard-title__button { </s> remove .dashboard-title__button{ </s> add .dashboard-title__button { </s> remove background: var(--white) url('../ui/svg/chevron-down.svg') no-repeat; </s> add background: var(--white) url("../ui/svg/chevron-down.svg") no-repeat; </s> remove --btn-unblock-disabled: #D8D8D8; --btn-unblock-active: #4D4D4D; </s> add --btn-unblock-disabled: #d8d8d8; --btn-unblock-active: #4d4d4d;
content: ":";
} } .grid .key-colon:nth-child(odd)::after { content: ":"; } .grid__one-row { grid-template-columns: 15rem; }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix a couple of stylelint violations
https://github.com/AdguardTeam/AdGuardHome/commit/334b3fc636025657ac6af2df0b90ec01332c8187
client/src/components/Logs/Cells/IconTooltip.css
padding-top: 2rem; } .title--border:before { content: ''; position: absolute; left: 0; border-top: 0.5px solid var(--gray-d8) !important; width: 100%; margin-top: -1rem;
</s> remove content: ':'; </s> add content: ":"; </s> remove .dashboard-title__button{ </s> add .dashboard-title__button { </s> remove --gray-f3: #F3F3F3; </s> add --gray-f3: #f3f3f3; </s> remove .dashboard-title__button{ </s> add .dashboard-title__button { </s> remove background: var(--white) url('../ui/svg/chevron-down.svg') no-repeat; </s> add background: var(--white) url("../ui/svg/chevron-down.svg") no-repeat;
content: "";
padding-top: 2rem; } .title--border:before { content: ""; position: absolute; left: 0; border-top: 0.5px solid var(--gray-d8) !important; width: 100%; margin-top: -1rem;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix a couple of stylelint violations
https://github.com/AdguardTeam/AdGuardHome/commit/334b3fc636025657ac6af2df0b90ec01332c8187
client/src/components/Logs/Cells/IconTooltip.css
--size-domain: 180; --size-response: 150; --size-client: 123; --gray-216: rgba(216, 216, 216, 0.23); --gray-4d: #4D4D4D; --gray-f3: #F3F3F3; --gray-8: #888; --gray-3: #333; --danger: #DF3812; --white80: rgba(255, 255, 255, 0.8);
</s> remove --danger: #DF3812; </s> add --danger: #df3812; </s> remove --btn-block: #C23814; --btn-block-disabled: #E3B3A6; --btn-block-active: #A62200; </s> add --btn-block: #c23814; --btn-block-disabled: #e3b3a6; --btn-block-active: #a62200; </s> remove --gray-f3: #F3F3F3; </s> add --gray-f3: #f3f3f3; </s> remove --green79: #67B279; </s> add --green79: #67b279; </s> remove --btn-unblock-disabled: #D8D8D8; --btn-unblock-active: #4D4D4D; </s> add --btn-unblock-disabled: #d8d8d8; --btn-unblock-active: #4d4d4d;
--gray-4d: #4d4d4d; --gray-f3: #f3f3f3;
--size-domain: 180; --size-response: 150; --size-client: 123; --gray-216: rgba(216, 216, 216, 0.23); --gray-4d: #4d4d4d; --gray-f3: #f3f3f3; --gray-4d: #4d4d4d; --gray-f3: #f3f3f3; --gray-8: #888; --gray-3: #333; --danger: #DF3812; --white80: rgba(255, 255, 255, 0.8);
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix a couple of stylelint violations
https://github.com/AdguardTeam/AdGuardHome/commit/334b3fc636025657ac6af2df0b90ec01332c8187
client/src/components/Logs/Logs.css
--gray-4d: #4D4D4D; --gray-f3: #F3F3F3; --gray-8: #888; --gray-3: #333; --danger: #DF3812; --white80: rgba(255, 255, 255, 0.8); --btn-block: #C23814; --btn-block-disabled: #E3B3A6; --btn-block-active: #A62200;
</s> remove --btn-block: #C23814; --btn-block-disabled: #E3B3A6; --btn-block-active: #A62200; </s> add --btn-block: #c23814; --btn-block-disabled: #e3b3a6; --btn-block-active: #a62200; </s> remove --gray-4d: #4D4D4D; --gray-f3: #F3F3F3; </s> add --gray-4d: #4d4d4d; --gray-f3: #f3f3f3; </s> remove --btn-unblock-disabled: #D8D8D8; --btn-unblock-active: #4D4D4D; </s> add --btn-unblock-disabled: #d8d8d8; --btn-unblock-active: #4d4d4d; </s> remove --gray-f3: #F3F3F3; </s> add --gray-f3: #f3f3f3; </s> remove --green79: #67B279; </s> add --green79: #67b279;
--danger: #df3812;
--gray-4d: #4D4D4D; --gray-f3: #F3F3F3; --gray-8: #888; --gray-3: #333; --danger: #df3812; --white80: rgba(255, 255, 255, 0.8); --btn-block: #C23814; --btn-block-disabled: #E3B3A6; --btn-block-active: #A62200;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix a couple of stylelint violations
https://github.com/AdguardTeam/AdGuardHome/commit/334b3fc636025657ac6af2df0b90ec01332c8187
client/src/components/Logs/Logs.css
--gray-8: #888; --gray-3: #333; --danger: #DF3812; --white80: rgba(255, 255, 255, 0.8); --btn-block: #C23814; --btn-block-disabled: #E3B3A6; --btn-block-active: #A62200; --btn-unblock: #888888; --btn-unblock-disabled: #D8D8D8; --btn-unblock-active: #4D4D4D; --option-border-radius: 4px;
</s> remove --danger: #DF3812; </s> add --danger: #df3812; </s> remove --btn-unblock-disabled: #D8D8D8; --btn-unblock-active: #4D4D4D; </s> add --btn-unblock-disabled: #d8d8d8; --btn-unblock-active: #4d4d4d; </s> remove --gray-4d: #4D4D4D; --gray-f3: #F3F3F3; </s> add --gray-4d: #4d4d4d; --gray-f3: #f3f3f3; </s> remove background: var(--white) url('../ui/svg/chevron-down.svg') no-repeat; </s> add background: var(--white) url("../ui/svg/chevron-down.svg") no-repeat; </s> remove content: ''; </s> add content: "";
--btn-block: #c23814; --btn-block-disabled: #e3b3a6; --btn-block-active: #a62200;
--gray-8: #888; --gray-3: #333; --danger: #DF3812; --white80: rgba(255, 255, 255, 0.8); --btn-block: #c23814; --btn-block-disabled: #e3b3a6; --btn-block-active: #a62200; --btn-block: #c23814; --btn-block-disabled: #e3b3a6; --btn-block-active: #a62200; --btn-block: #c23814; --btn-block-disabled: #e3b3a6; --btn-block-active: #a62200; --btn-block: #c23814; --btn-block-disabled: #e3b3a6; --btn-block-active: #a62200; --btn-block: #c23814; --btn-block-disabled: #e3b3a6; --btn-block-active: #a62200; --btn-unblock: #888888; --btn-unblock-disabled: #D8D8D8; --btn-unblock-active: #4D4D4D; --option-border-radius: 4px;
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix a couple of stylelint violations
https://github.com/AdguardTeam/AdGuardHome/commit/334b3fc636025657ac6af2df0b90ec01332c8187
client/src/components/Logs/Logs.css
--btn-block-disabled: #E3B3A6; --btn-block-active: #A62200; --btn-unblock: #888888; --btn-unblock-disabled: #D8D8D8; --btn-unblock-active: #4D4D4D; --option-border-radius: 4px; } .logs__text { padding: 0 1px;
</s> remove --btn-block: #C23814; --btn-block-disabled: #E3B3A6; --btn-block-active: #A62200; </s> add --btn-block: #c23814; --btn-block-disabled: #e3b3a6; --btn-block-active: #a62200; </s> remove --danger: #DF3812; </s> add --danger: #df3812; </s> remove .dashboard-title__button{ </s> add .dashboard-title__button { </s> remove content: ':'; </s> add content: ":"; </s> remove .dashboard-title__button{ </s> add .dashboard-title__button {
--btn-unblock-disabled: #d8d8d8; --btn-unblock-active: #4d4d4d;
--btn-block-disabled: #E3B3A6; --btn-block-active: #A62200; --btn-unblock: #888888; --btn-unblock-disabled: #d8d8d8; --btn-unblock-active: #4d4d4d; --btn-unblock-disabled: #d8d8d8; --btn-unblock-active: #4d4d4d; --btn-unblock-disabled: #d8d8d8; --btn-unblock-active: #4d4d4d; --option-border-radius: 4px; } .logs__text { padding: 0 1px;
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix a couple of stylelint violations
https://github.com/AdguardTeam/AdGuardHome/commit/334b3fc636025657ac6af2df0b90ec01332c8187
client/src/components/Logs/Logs.css
cursor: pointer; } .custom-select__arrow--left { background: var(--white) url('../ui/svg/chevron-down.svg') no-repeat; background-position: 5px 9px; background-size: 22px; } .custom-select--logs {
</s> remove content: ':'; </s> add content: ":"; </s> remove .dashboard-title__button{ </s> add .dashboard-title__button { </s> remove .dashboard-title__button{ </s> add .dashboard-title__button { </s> remove --btn-unblock-disabled: #D8D8D8; --btn-unblock-active: #4D4D4D; </s> add --btn-unblock-disabled: #d8d8d8; --btn-unblock-active: #4d4d4d; </s> remove content: ''; </s> add content: "";
background: var(--white) url("../ui/svg/chevron-down.svg") no-repeat;
cursor: pointer; } .custom-select__arrow--left { background: var(--white) url("../ui/svg/chevron-down.svg") no-repeat; background-position: 5px 9px; background-size: 22px; } .custom-select--logs {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Fix a couple of stylelint violations
https://github.com/AdguardTeam/AdGuardHome/commit/334b3fc636025657ac6af2df0b90ec01332c8187
client/src/components/Logs/Logs.css
REWRITE: 'Rewrite', REWRITE_HOSTS: 'RewriteEtcHosts', FILTERED_SAFE_SEARCH: 'FilteredSafeSearch', FILTERED_SAFE_BROWSING: 'FilteredSafeBrowsing', FILTERED_PARENTAL: 'FilteredParental', };
</s> remove res.Reason = ReasonRewrite </s> add res.Reason = Rewritten </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
REWRITE_RULE: 'RewriteRule',
REWRITE: 'Rewrite', REWRITE_HOSTS: 'RewriteEtcHosts', REWRITE_RULE: 'RewriteRule', FILTERED_SAFE_SEARCH: 'FilteredSafeSearch', FILTERED_SAFE_BROWSING: 'FilteredSafeBrowsing', FILTERED_PARENTAL: 'FilteredParental', };
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
client/src/helpers/constants.js
LABEL: RESPONSE_FILTER.REWRITTEN.LABEL, COLOR: QUERY_STATUS_COLORS.BLUE, }, [FILTERED_STATUS.FILTERED_SAFE_BROWSING]: { LABEL: RESPONSE_FILTER.BLOCKED_THREATS.LABEL, COLOR: QUERY_STATUS_COLORS.YELLOW, }, [FILTERED_STATUS.FILTERED_PARENTAL]: {
</s> remove } else if res.Reason == dnsfilter.DNSRewriteRule { </s> add } else if res.Reason == dnsfilter.RewrittenRule { </s> remove } else if res.Reason == dnsfilter.ReasonRewrite || res.Reason == dnsfilter.RewriteAutoHosts { </s> add } else if res.Reason == dnsfilter.Rewritten || res.Reason == dnsfilter.RewrittenAutoHosts { </s> remove if res.Reason == DNSRewriteRule && res.CanonName == host { </s> add if res.Reason == RewrittenRule && res.CanonName == host { </s> remove } else if res.Reason == dnsfilter.RewriteAutoHosts && len(res.ReverseHosts) != 0 { </s> add } else if res.Reason == dnsfilter.RewrittenAutoHosts && len(res.ReverseHosts) != 0 { </s> remove result.Reason = RewriteAutoHosts </s> add result.Reason = RewrittenAutoHosts
[FILTERED_STATUS.REWRITE_RULE]: { LABEL: RESPONSE_FILTER.REWRITTEN.LABEL, COLOR: QUERY_STATUS_COLORS.BLUE, },
LABEL: RESPONSE_FILTER.REWRITTEN.LABEL, COLOR: QUERY_STATUS_COLORS.BLUE, }, [FILTERED_STATUS.REWRITE_RULE]: { LABEL: RESPONSE_FILTER.REWRITTEN.LABEL, COLOR: QUERY_STATUS_COLORS.BLUE, }, [FILTERED_STATUS.FILTERED_SAFE_BROWSING]: { LABEL: RESPONSE_FILTER.BLOCKED_THREATS.LABEL, COLOR: QUERY_STATUS_COLORS.YELLOW, }, [FILTERED_STATUS.FILTERED_PARENTAL]: {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
client/src/helpers/constants.js
FilteredSafeSearch // FilteredBlockedService - the host is blocked by "blocked services" settings FilteredBlockedService // ReasonRewrite is returned when there was a rewrite by // a legacy DNS Rewrite rule. ReasonRewrite // RewriteAutoHosts is returned when there was a rewrite by // autohosts rules (/etc/hosts and so on). RewriteAutoHosts // DNSRewriteRule is returned when a $dnsrewrite filter rule was // applied. DNSRewriteRule ) // TODO(a.garipov): Resync with actual code names or replace completely // in HTTP API v1. var reasonNames = []string{
</s> remove if res.Reason == DNSRewriteRule && res.CanonName == host { </s> add if res.Reason == RewrittenRule && res.CanonName == host { </s> remove // It is empty unless Reason is set to ReasonRewrite. </s> add // It is empty unless Reason is set to Rewritten or RewrittenRule. </s> remove // Reason is set to RewriteAutoHosts or ReasonRewrite. </s> add // Reason is set to RewrittenAutoHosts or Rewritten. </s> remove // empty unless Reason is set to RewriteAutoHosts. </s> add // empty unless Reason is set to RewrittenAutoHosts. </s> remove - 'DNSRewriteRule' </s> add - 'RewriteRule'
// Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule
FilteredSafeSearch // FilteredBlockedService - the host is blocked by "blocked services" settings FilteredBlockedService // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule ) // TODO(a.garipov): Resync with actual code names or replace completely // in HTTP API v1. var reasonNames = []string{
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/dnsfilter.go
FilteredInvalid: "FilteredInvalid", FilteredSafeSearch: "FilteredSafeSearch", FilteredBlockedService: "FilteredBlockedService", ReasonRewrite: "Rewrite", RewriteAutoHosts: "RewriteEtcHosts", DNSRewriteRule: "DNSRewriteRule", } func (r Reason) String() string { if r < 0 || int(r) >= len(reasonNames) { return ""
</s> remove // for ReasonRewrite: </s> add // for Rewritten: </s> remove } else if res.Reason == dnsfilter.ReasonRewrite || res.Reason == dnsfilter.RewriteAutoHosts { </s> add } else if res.Reason == dnsfilter.Rewritten || res.Reason == dnsfilter.RewrittenAutoHosts { </s> remove } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && </s> add } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) && </s> remove result.Reason = RewriteAutoHosts </s> add result.Reason = RewrittenAutoHosts </s> remove } else if res.Reason == dnsfilter.DNSRewriteRule { </s> add } else if res.Reason == dnsfilter.RewrittenRule {
Rewritten: "Rewrite", RewrittenAutoHosts: "RewriteEtcHosts", RewrittenRule: "RewriteRule",
FilteredInvalid: "FilteredInvalid", FilteredSafeSearch: "FilteredSafeSearch", FilteredBlockedService: "FilteredBlockedService", Rewritten: "Rewrite", RewrittenAutoHosts: "RewriteEtcHosts", RewrittenRule: "RewriteRule", Rewritten: "Rewrite", RewrittenAutoHosts: "RewriteEtcHosts", RewrittenRule: "RewriteRule", Rewritten: "Rewrite", RewrittenAutoHosts: "RewriteEtcHosts", RewrittenRule: "RewriteRule", Rewritten: "Rewrite", RewrittenAutoHosts: "RewriteEtcHosts", RewrittenRule: "RewriteRule", Rewritten: "Rewrite", RewrittenAutoHosts: "RewriteEtcHosts", RewrittenRule: "RewriteRule", } func (r Reason) String() string { if r < 0 || int(r) >= len(reasonNames) { return ""
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/dnsfilter.go
// is not nil. Rules []*ResultRule `json:",omitempty"` // ReverseHosts is the reverse lookup rewrite result. It is // empty unless Reason is set to RewriteAutoHosts. ReverseHosts []string `json:",omitempty"` // IPList is the lookup rewrite result. It is empty unless // Reason is set to RewriteAutoHosts or ReasonRewrite. IPList []net.IP `json:",omitempty"`
</s> remove // Reason is set to RewriteAutoHosts or ReasonRewrite. </s> add // Reason is set to RewrittenAutoHosts or Rewritten. </s> remove // It is empty unless Reason is set to ReasonRewrite. </s> add // It is empty unless Reason is set to Rewritten or RewrittenRule. </s> remove // ReasonRewrite is returned when there was a rewrite by // a legacy DNS Rewrite rule. ReasonRewrite // RewriteAutoHosts is returned when there was a rewrite by // autohosts rules (/etc/hosts and so on). RewriteAutoHosts // DNSRewriteRule is returned when a $dnsrewrite filter rule was // applied. DNSRewriteRule </s> add // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule </s> remove } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && </s> add } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) && </s> remove if res.Reason == DNSRewriteRule && res.CanonName == host { </s> add if res.Reason == RewrittenRule && res.CanonName == host {
// empty unless Reason is set to RewrittenAutoHosts.
// is not nil. Rules []*ResultRule `json:",omitempty"` // ReverseHosts is the reverse lookup rewrite result. It is // empty unless Reason is set to RewrittenAutoHosts. ReverseHosts []string `json:",omitempty"` // IPList is the lookup rewrite result. It is empty unless // Reason is set to RewriteAutoHosts or ReasonRewrite. IPList []net.IP `json:",omitempty"`
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/dnsfilter.go
// empty unless Reason is set to RewriteAutoHosts. ReverseHosts []string `json:",omitempty"` // IPList is the lookup rewrite result. It is empty unless // Reason is set to RewriteAutoHosts or ReasonRewrite. IPList []net.IP `json:",omitempty"` // CanonName is the CNAME value from the lookup rewrite result. // It is empty unless Reason is set to ReasonRewrite. CanonName string `json:",omitempty"`
</s> remove // empty unless Reason is set to RewriteAutoHosts. </s> add // empty unless Reason is set to RewrittenAutoHosts. </s> remove // It is empty unless Reason is set to ReasonRewrite. </s> add // It is empty unless Reason is set to Rewritten or RewrittenRule. </s> remove // ReasonRewrite is returned when there was a rewrite by // a legacy DNS Rewrite rule. ReasonRewrite // RewriteAutoHosts is returned when there was a rewrite by // autohosts rules (/etc/hosts and so on). RewriteAutoHosts // DNSRewriteRule is returned when a $dnsrewrite filter rule was // applied. DNSRewriteRule </s> add // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule </s> remove // for ReasonRewrite: </s> add // for Rewritten: </s> remove case dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule: </s> add case dnsfilter.Rewritten, dnsfilter.RewrittenRule:
// Reason is set to RewrittenAutoHosts or Rewritten.
// empty unless Reason is set to RewriteAutoHosts. ReverseHosts []string `json:",omitempty"` // IPList is the lookup rewrite result. It is empty unless // Reason is set to RewrittenAutoHosts or Rewritten. IPList []net.IP `json:",omitempty"` // CanonName is the CNAME value from the lookup rewrite result. // It is empty unless Reason is set to ReasonRewrite. CanonName string `json:",omitempty"`
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/dnsfilter.go
// Reason is set to RewriteAutoHosts or ReasonRewrite. IPList []net.IP `json:",omitempty"` // CanonName is the CNAME value from the lookup rewrite result. // It is empty unless Reason is set to ReasonRewrite. CanonName string `json:",omitempty"` // ServiceName is the name of the blocked service. It is empty // unless Reason is set to FilteredBlockedService. ServiceName string `json:",omitempty"`
</s> remove // Reason is set to RewriteAutoHosts or ReasonRewrite. </s> add // Reason is set to RewrittenAutoHosts or Rewritten. </s> remove // empty unless Reason is set to RewriteAutoHosts. </s> add // empty unless Reason is set to RewrittenAutoHosts. </s> remove // for ReasonRewrite: </s> add // for Rewritten: </s> remove // ReasonRewrite is returned when there was a rewrite by // a legacy DNS Rewrite rule. ReasonRewrite // RewriteAutoHosts is returned when there was a rewrite by // autohosts rules (/etc/hosts and so on). RewriteAutoHosts // DNSRewriteRule is returned when a $dnsrewrite filter rule was // applied. DNSRewriteRule </s> add // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule </s> remove } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && </s> add } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) &&
// It is empty unless Reason is set to Rewritten or RewrittenRule.
// Reason is set to RewriteAutoHosts or ReasonRewrite. IPList []net.IP `json:",omitempty"` // CanonName is the CNAME value from the lookup rewrite result. // It is empty unless Reason is set to Rewritten or RewrittenRule. CanonName string `json:",omitempty"` // ServiceName is the name of the blocked service. It is empty // unless Reason is set to FilteredBlockedService. ServiceName string `json:",omitempty"`
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/dnsfilter.go
var err error // first - check rewrites, they have the highest priority result = d.processRewrites(host, qtype) if result.Reason == ReasonRewrite { return result, nil } // Now check the hosts file -- do we have any rules for it? // just like DNS rewrites, it has higher priority than filtering rules.
</s> remove result.Reason = RewriteAutoHosts </s> add result.Reason = RewrittenAutoHosts </s> remove case dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule: </s> add case dnsfilter.Rewritten, dnsfilter.RewrittenRule: </s> remove } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && </s> add } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) && </s> remove if res.Reason == DNSRewriteRule && res.CanonName == host { </s> add if res.Reason == RewrittenRule && res.CanonName == host { </s> remove } else if res.Reason == dnsfilter.DNSRewriteRule { </s> add } else if res.Reason == dnsfilter.RewrittenRule {
if result.Reason == Rewritten {
var err error // first - check rewrites, they have the highest priority result = d.processRewrites(host, qtype) if result.Reason == Rewritten { return result, nil } // Now check the hosts file -- do we have any rules for it? // just like DNS rewrites, it has higher priority than filtering rules.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/dnsfilter.go
func (d *DNSFilter) checkAutoHosts(host string, qtype uint16, result *Result) (matched bool) { ips := d.Config.AutoHosts.Process(host, qtype) if ips != nil { result.Reason = RewriteAutoHosts result.IPList = ips return true }
</s> remove result.Reason = RewriteAutoHosts </s> add result.Reason = RewrittenAutoHosts </s> remove if result.Reason == ReasonRewrite { </s> add if result.Reason == Rewritten { </s> remove } else if res.Reason == dnsfilter.DNSRewriteRule { </s> add } else if res.Reason == dnsfilter.RewrittenRule { </s> remove res.Reason = ReasonRewrite </s> add res.Reason = Rewritten </s> remove } else if res.Reason == dnsfilter.ReasonRewrite || res.Reason == dnsfilter.RewriteAutoHosts { </s> add } else if res.Reason == dnsfilter.Rewritten || res.Reason == dnsfilter.RewrittenAutoHosts {
result.Reason = RewrittenAutoHosts
func (d *DNSFilter) checkAutoHosts(host string, qtype uint16, result *Result) (matched bool) { ips := d.Config.AutoHosts.Process(host, qtype) if ips != nil { result.Reason = RewrittenAutoHosts result.IPList = ips return true }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/dnsfilter.go
} revHosts := d.Config.AutoHosts.ProcessReverse(host, qtype) if len(revHosts) != 0 { result.Reason = RewriteAutoHosts // TODO(a.garipov): Optimize this with a buffer. result.ReverseHosts = make([]string, len(revHosts)) for i := range revHosts { result.ReverseHosts[i] = revHosts[i] + "."
</s> remove result.Reason = RewriteAutoHosts </s> add result.Reason = RewrittenAutoHosts </s> remove } else if res.Reason == dnsfilter.RewriteAutoHosts && len(res.ReverseHosts) != 0 { </s> add } else if res.Reason == dnsfilter.RewrittenAutoHosts && len(res.ReverseHosts) != 0 { </s> remove res.Reason = ReasonRewrite </s> add res.Reason = Rewritten </s> remove } else if res.Reason == dnsfilter.ReasonRewrite || res.Reason == dnsfilter.RewriteAutoHosts { </s> add } else if res.Reason == dnsfilter.Rewritten || res.Reason == dnsfilter.RewrittenAutoHosts { </s> remove if result.Reason == ReasonRewrite { </s> add if result.Reason == Rewritten {
result.Reason = RewrittenAutoHosts
} revHosts := d.Config.AutoHosts.ProcessReverse(host, qtype) if len(revHosts) != 0 { result.Reason = RewrittenAutoHosts // TODO(a.garipov): Optimize this with a buffer. result.ReverseHosts = make([]string, len(revHosts)) for i := range revHosts { result.ReverseHosts[i] = revHosts[i] + "."
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/dnsfilter.go
defer d.confLock.RUnlock() rr := findRewrites(d.Rewrites, host) if len(rr) != 0 { res.Reason = ReasonRewrite } cnames := map[string]bool{} origHost := host for len(rr) != 0 && rr[0].Type == dns.TypeCNAME {
</s> remove } else if res.Reason == dnsfilter.RewriteAutoHosts && len(res.ReverseHosts) != 0 { </s> add } else if res.Reason == dnsfilter.RewrittenAutoHosts && len(res.ReverseHosts) != 0 { </s> remove } else if res.Reason == dnsfilter.ReasonRewrite || res.Reason == dnsfilter.RewriteAutoHosts { </s> add } else if res.Reason == dnsfilter.Rewritten || res.Reason == dnsfilter.RewrittenAutoHosts { </s> remove if res.Reason == DNSRewriteRule && res.CanonName == host { </s> add if res.Reason == RewrittenRule && res.CanonName == host { </s> remove result.Reason = RewriteAutoHosts </s> add result.Reason = RewrittenAutoHosts </s> remove } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && </s> add } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) &&
res.Reason = Rewritten
defer d.confLock.RUnlock() rr := findRewrites(d.Rewrites, host) if len(rr) != 0 { res.Reason = Rewritten } cnames := map[string]bool{} origHost := host for len(rr) != 0 && rr[0].Type == dns.TypeCNAME {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/dnsfilter.go
// Check DNS rewrites first, because the API there is a bit // awkward. if dnsr := dnsres.DNSRewrites(); len(dnsr) > 0 { res = d.processDNSRewrites(dnsr) if res.Reason == DNSRewriteRule && res.CanonName == host { // A rewrite of a host to itself. Go on and // try matching other things. } else { return res, nil }
</s> remove // ReasonRewrite is returned when there was a rewrite by // a legacy DNS Rewrite rule. ReasonRewrite // RewriteAutoHosts is returned when there was a rewrite by // autohosts rules (/etc/hosts and so on). RewriteAutoHosts // DNSRewriteRule is returned when a $dnsrewrite filter rule was // applied. DNSRewriteRule </s> add // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule </s> remove } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && </s> add } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) && </s> remove } else if res.Reason == dnsfilter.DNSRewriteRule { </s> add } else if res.Reason == dnsfilter.RewrittenRule { </s> remove } else if res.Reason == dnsfilter.RewriteAutoHosts && len(res.ReverseHosts) != 0 { </s> add } else if res.Reason == dnsfilter.RewrittenAutoHosts && len(res.ReverseHosts) != 0 { </s> remove } else if res.Reason == dnsfilter.ReasonRewrite || res.Reason == dnsfilter.RewriteAutoHosts { </s> add } else if res.Reason == dnsfilter.Rewritten || res.Reason == dnsfilter.RewrittenAutoHosts {
if res.Reason == RewrittenRule && res.CanonName == host {
// Check DNS rewrites first, because the API there is a bit // awkward. if dnsr := dnsres.DNSRewrites(); len(dnsr) > 0 { res = d.processDNSRewrites(dnsr) if res.Reason == RewrittenRule && res.CanonName == host { // A rewrite of a host to itself. Go on and // try matching other things. } else { return res, nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/dnsfilter.go
Text: nr.RuleText, }} return Result{ Reason: DNSRewriteRule, Rules: rules, CanonName: dr.NewCNAME, } }
</s> remove Reason: DNSRewriteRule, </s> add Reason: RewrittenRule, </s> remove Reason: DNSRewriteRule, </s> add Reason: RewrittenRule, </s> remove Reason: dnsfilter.ReasonRewrite, </s> add Reason: dnsfilter.Rewritten, </s> remove } else if res.Reason == dnsfilter.DNSRewriteRule { </s> add } else if res.Reason == dnsfilter.RewrittenRule { </s> remove } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && </s> add } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) &&
Reason: RewrittenRule,
Text: nr.RuleText, }} return Result{ Reason: RewrittenRule, Rules: rules, CanonName: dr.NewCNAME, } }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/dnsrewrite.go
RCode: dr.RCode, } return Result{ Reason: DNSRewriteRule, Rules: rules, DNSRewriteResult: dnsrr, } } }
</s> remove Reason: DNSRewriteRule, </s> add Reason: RewrittenRule, </s> remove Reason: DNSRewriteRule, </s> add Reason: RewrittenRule, </s> remove } else if res.Reason == dnsfilter.DNSRewriteRule { </s> add } else if res.Reason == dnsfilter.RewrittenRule { </s> remove Reason: dnsfilter.ReasonRewrite, </s> add Reason: dnsfilter.Rewritten, </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
Reason: RewrittenRule,
RCode: dr.RCode, } return Result{ Reason: RewrittenRule, Rules: rules, DNSRewriteResult: dnsrr, } } }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/dnsrewrite.go
} } return Result{ Reason: DNSRewriteRule, Rules: rules, DNSRewriteResult: dnsrr, } }
</s> remove Reason: DNSRewriteRule, </s> add Reason: RewrittenRule, </s> remove Reason: DNSRewriteRule, </s> add Reason: RewrittenRule, </s> remove } else if res.Reason == dnsfilter.DNSRewriteRule { </s> add } else if res.Reason == dnsfilter.RewrittenRule { </s> remove Reason: dnsfilter.ReasonRewrite, </s> add Reason: dnsfilter.Rewritten, </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
Reason: RewrittenRule,
} } return Result{ Reason: RewrittenRule, Rules: rules, DNSRewriteResult: dnsrr, } }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/dnsrewrite.go
r := d.processRewrites("host2.com", dns.TypeA) assert.Equal(t, NotFilteredNotFound, r.Reason) r = d.processRewrites("www.host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.Equal(t, "host.com", r.CanonName) assert.Equal(t, 2, len(r.IPList)) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) assert.True(t, r.IPList[1].Equal(net.ParseIP("1.2.3.5")))
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
r := d.processRewrites("host2.com", dns.TypeA) assert.Equal(t, NotFilteredNotFound, r.Reason) r = d.processRewrites("www.host.com", dns.TypeA) assert.Equal(t, Rewritten, r.Reason) assert.Equal(t, "host.com", r.CanonName) assert.Equal(t, 2, len(r.IPList)) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) assert.True(t, r.IPList[1].Equal(net.ParseIP("1.2.3.5")))
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) assert.True(t, r.IPList[1].Equal(net.ParseIP("1.2.3.5"))) r = d.processRewrites("www.host.com", dns.TypeAAAA) assert.Equal(t, ReasonRewrite, r.Reason) assert.Equal(t, "host.com", r.CanonName) assert.Equal(t, 1, len(r.IPList)) assert.True(t, r.IPList[0].Equal(net.ParseIP("1:2:3::4"))) // wildcard
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) assert.True(t, r.IPList[1].Equal(net.ParseIP("1.2.3.5"))) r = d.processRewrites("www.host.com", dns.TypeAAAA) assert.Equal(t, Rewritten, r.Reason) assert.Equal(t, "host.com", r.CanonName) assert.Equal(t, 1, len(r.IPList)) assert.True(t, r.IPList[0].Equal(net.ParseIP("1:2:3::4"))) // wildcard
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
{"*.host.com", "1.2.3.5", 0, nil}, } d.prepareRewrites() r = d.processRewrites("host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) r = d.processRewrites("www.host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.5")))
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
{"*.host.com", "1.2.3.5", 0, nil}, } d.prepareRewrites() r = d.processRewrites("host.com", dns.TypeA) assert.Equal(t, Rewritten, r.Reason) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) r = d.processRewrites("www.host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.5")))
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
assert.Equal(t, ReasonRewrite, r.Reason) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) r = d.processRewrites("www.host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.5"))) r = d.processRewrites("www.host2.com", dns.TypeA) assert.Equal(t, NotFilteredNotFound, r.Reason)
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, ReasonRewrite, r.Reason) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) r = d.processRewrites("www.host.com", dns.TypeA) assert.Equal(t, Rewritten, r.Reason) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.5"))) r = d.processRewrites("www.host2.com", dns.TypeA) assert.Equal(t, NotFilteredNotFound, r.Reason)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
{"*.host.com", "1.2.3.5", 0, nil}, } d.prepareRewrites() r = d.processRewrites("a.host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.True(t, len(r.IPList) == 1) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) // wildcard + CNAME d.Rewrites = []RewriteEntry{
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
{"*.host.com", "1.2.3.5", 0, nil}, } d.prepareRewrites() r = d.processRewrites("a.host.com", dns.TypeA) assert.Equal(t, Rewritten, r.Reason) assert.True(t, len(r.IPList) == 1) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) // wildcard + CNAME d.Rewrites = []RewriteEntry{
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
{"*.host.com", "host.com", 0, nil}, } d.prepareRewrites() r = d.processRewrites("www.host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.Equal(t, "host.com", r.CanonName) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) // 2 CNAMEs d.Rewrites = []RewriteEntry{
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
{"*.host.com", "host.com", 0, nil}, } d.prepareRewrites() r = d.processRewrites("www.host.com", dns.TypeA) assert.Equal(t, Rewritten, r.Reason) assert.Equal(t, "host.com", r.CanonName) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) // 2 CNAMEs d.Rewrites = []RewriteEntry{
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
{"host.com", "1.2.3.4", 0, nil}, } d.prepareRewrites() r = d.processRewrites("b.host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.Equal(t, "host.com", r.CanonName) assert.True(t, len(r.IPList) == 1) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) // 2 CNAMEs + wildcard
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
{"host.com", "1.2.3.4", 0, nil}, } d.prepareRewrites() r = d.processRewrites("b.host.com", dns.TypeA) assert.Equal(t, Rewritten, r.Reason) assert.Equal(t, "host.com", r.CanonName) assert.True(t, len(r.IPList) == 1) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) // 2 CNAMEs + wildcard
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
{"*.somehost.com", "1.2.3.4", 0, nil}, } d.prepareRewrites() r = d.processRewrites("b.host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.Equal(t, "x.somehost.com", r.CanonName) assert.True(t, len(r.IPList) == 1) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) }
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
{"*.somehost.com", "1.2.3.4", 0, nil}, } d.prepareRewrites() r = d.processRewrites("b.host.com", dns.TypeA) assert.Equal(t, Rewritten, r.Reason) assert.Equal(t, "x.somehost.com", r.CanonName) assert.True(t, len(r.IPList) == 1) assert.True(t, r.IPList[0].Equal(net.ParseIP("1.2.3.4"))) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
d.prepareRewrites() // match exact r := d.processRewrites("host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.Equal(t, 1, len(r.IPList)) assert.Equal(t, "1.1.1.1", r.IPList[0].String()) // match L2 r = d.processRewrites("sub.host.com", dns.TypeA)
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
d.prepareRewrites() // match exact r := d.processRewrites("host.com", dns.TypeA) assert.Equal(t, Rewritten, r.Reason) assert.Equal(t, 1, len(r.IPList)) assert.Equal(t, "1.1.1.1", r.IPList[0].String()) // match L2 r = d.processRewrites("sub.host.com", dns.TypeA)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
assert.Equal(t, "1.1.1.1", r.IPList[0].String()) // match L2 r = d.processRewrites("sub.host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.Equal(t, 1, len(r.IPList)) assert.Equal(t, "2.2.2.2", r.IPList[0].String()) // match L3 r = d.processRewrites("my.sub.host.com", dns.TypeA)
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, "1.1.1.1", r.IPList[0].String()) // match L2 r = d.processRewrites("sub.host.com", dns.TypeA) assert.Equal(t, Rewritten, r.Reason) assert.Equal(t, 1, len(r.IPList)) assert.Equal(t, "2.2.2.2", r.IPList[0].String()) // match L3 r = d.processRewrites("my.sub.host.com", dns.TypeA)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
assert.Equal(t, "2.2.2.2", r.IPList[0].String()) // match L3 r = d.processRewrites("my.sub.host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.Equal(t, 1, len(r.IPList)) assert.Equal(t, "3.3.3.3", r.IPList[0].String()) } func TestRewritesExceptionCNAME(t *testing.T) {
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, "2.2.2.2", r.IPList[0].String()) // match L3 r = d.processRewrites("my.sub.host.com", dns.TypeA) assert.Equal(t, Rewritten, r.Reason) assert.Equal(t, 1, len(r.IPList)) assert.Equal(t, "3.3.3.3", r.IPList[0].String()) } func TestRewritesExceptionCNAME(t *testing.T) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
d.prepareRewrites() // match sub-domain r := d.processRewrites("my.host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.Equal(t, 1, len(r.IPList)) assert.Equal(t, "2.2.2.2", r.IPList[0].String()) // match sub-domain, but handle exception r = d.processRewrites("sub.host.com", dns.TypeA)
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
d.prepareRewrites() // match sub-domain r := d.processRewrites("my.host.com", dns.TypeA) assert.Equal(t, Rewritten, r.Reason) assert.Equal(t, 1, len(r.IPList)) assert.Equal(t, "2.2.2.2", r.IPList[0].String()) // match sub-domain, but handle exception r = d.processRewrites("sub.host.com", dns.TypeA)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
d.prepareRewrites() // match sub-domain r := d.processRewrites("my.host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.Equal(t, 1, len(r.IPList)) assert.Equal(t, "2.2.2.2", r.IPList[0].String()) // match sub-domain, but handle exception r = d.processRewrites("my.sub.host.com", dns.TypeA)
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
d.prepareRewrites() // match sub-domain r := d.processRewrites("my.host.com", dns.TypeA) assert.Equal(t, Rewritten, r.Reason) assert.Equal(t, 1, len(r.IPList)) assert.Equal(t, "2.2.2.2", r.IPList[0].String()) // match sub-domain, but handle exception r = d.processRewrites("my.sub.host.com", dns.TypeA)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
d.prepareRewrites() // match domain r := d.processRewrites("host.com", dns.TypeA) assert.Equal(t, ReasonRewrite, r.Reason) assert.Equal(t, 1, len(r.IPList)) assert.Equal(t, "1.2.3.4", r.IPList[0].String()) // match exception r = d.processRewrites("host.com", dns.TypeAAAA)
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
d.prepareRewrites() // match domain r := d.processRewrites("host.com", dns.TypeA) assert.Equal(t, Rewritten, r.Reason) assert.Equal(t, 1, len(r.IPList)) assert.Equal(t, "1.2.3.4", r.IPList[0].String()) // match exception r = d.processRewrites("host.com", dns.TypeAAAA)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
assert.Equal(t, NotFilteredNotFound, r.Reason) // match domain r = d.processRewrites("host2.com", dns.TypeAAAA) assert.Equal(t, ReasonRewrite, r.Reason) assert.Equal(t, 1, len(r.IPList)) assert.Equal(t, "::1", r.IPList[0].String()) // match exception r = d.processRewrites("host3.com", dns.TypeA)
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, NotFilteredNotFound, r.Reason) // match domain r = d.processRewrites("host2.com", dns.TypeAAAA) assert.Equal(t, Rewritten, r.Reason) assert.Equal(t, 1, len(r.IPList)) assert.Equal(t, "::1", r.IPList[0].String()) // match exception r = d.processRewrites("host3.com", dns.TypeA)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
assert.Equal(t, NotFilteredNotFound, r.Reason) // match domain r = d.processRewrites("host3.com", dns.TypeAAAA) assert.Equal(t, ReasonRewrite, r.Reason) assert.Equal(t, 0, len(r.IPList)) }
</s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason) </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, Rewritten, r.Reason)
assert.Equal(t, NotFilteredNotFound, r.Reason) // match domain r = d.processRewrites("host3.com", dns.TypeAAAA) assert.Equal(t, Rewritten, r.Reason) assert.Equal(t, 0, len(r.IPList)) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsfilter/rewrites_test.go
res := ctx.result var err error switch res.Reason { case dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule: if len(ctx.origQuestion.Name) == 0 { // origQuestion is set in case we get only CNAME without IP from rewrites table break }
</s> remove if res.Reason == DNSRewriteRule && res.CanonName == host { </s> add if res.Reason == RewrittenRule && res.CanonName == host { </s> remove if result.Reason == ReasonRewrite { </s> add if result.Reason == Rewritten { </s> remove } else if res.Reason == dnsfilter.RewriteAutoHosts && len(res.ReverseHosts) != 0 { </s> add } else if res.Reason == dnsfilter.RewrittenAutoHosts && len(res.ReverseHosts) != 0 { </s> remove } else if res.Reason == dnsfilter.DNSRewriteRule { </s> add } else if res.Reason == dnsfilter.RewrittenRule { </s> remove return res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.RewriteAutoHosts) </s> add return res.Reason.In( dnsfilter.Rewritten, dnsfilter.RewrittenAutoHosts, dnsfilter.RewrittenRule, )
case dnsfilter.Rewritten, dnsfilter.RewrittenRule:
res := ctx.result var err error switch res.Reason { case dnsfilter.Rewritten, dnsfilter.RewrittenRule: case dnsfilter.Rewritten, dnsfilter.RewrittenRule: if len(ctx.origQuestion.Name) == 0 { // origQuestion is set in case we get only CNAME without IP from rewrites table break }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsforward/dns.go
return nil, fmt.Errorf("dnsfilter failed to check host %q: %w", host, err) } else if res.IsFiltered { log.Tracef("Host %s is filtered, reason - %q, matched rule: %q", host, res.Reason, res.Rules[0].Text) d.Res = s.genDNSFilterMessage(d, &res) } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && res.CanonName != "" && len(res.IPList) == 0 { // Resolve the new canonical name, not the original host // name. The original question is readded in // processFilteringAfterResponse.
</s> remove } else if res.Reason == dnsfilter.RewriteAutoHosts && len(res.ReverseHosts) != 0 { </s> add } else if res.Reason == dnsfilter.RewrittenAutoHosts && len(res.ReverseHosts) != 0 { </s> remove if res.Reason == DNSRewriteRule && res.CanonName == host { </s> add if res.Reason == RewrittenRule && res.CanonName == host { </s> remove } else if res.Reason == dnsfilter.DNSRewriteRule { </s> add } else if res.Reason == dnsfilter.RewrittenRule { </s> remove } else if res.Reason == dnsfilter.ReasonRewrite || res.Reason == dnsfilter.RewriteAutoHosts { </s> add } else if res.Reason == dnsfilter.Rewritten || res.Reason == dnsfilter.RewrittenAutoHosts { </s> remove res.Reason = ReasonRewrite </s> add res.Reason = Rewritten
} else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) &&
return nil, fmt.Errorf("dnsfilter failed to check host %q: %w", host, err) } else if res.IsFiltered { log.Tracef("Host %s is filtered, reason - %q, matched rule: %q", host, res.Reason, res.Rules[0].Text) d.Res = s.genDNSFilterMessage(d, &res) } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) && res.CanonName != "" && len(res.IPList) == 0 { // Resolve the new canonical name, not the original host // name. The original question is readded in // processFilteringAfterResponse.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsforward/filter.go
// name. The original question is readded in // processFilteringAfterResponse. ctx.origQuestion = d.Req.Question[0] d.Req.Question[0].Name = dns.Fqdn(res.CanonName) } else if res.Reason == dnsfilter.RewriteAutoHosts && len(res.ReverseHosts) != 0 { resp := s.makeResponse(req) for _, h := range res.ReverseHosts { hdr := dns.RR_Header{ Name: req.Question[0].Name, Rrtype: dns.TypePTR,
</s> remove } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && </s> add } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) && </s> remove } else if res.Reason == dnsfilter.ReasonRewrite || res.Reason == dnsfilter.RewriteAutoHosts { </s> add } else if res.Reason == dnsfilter.Rewritten || res.Reason == dnsfilter.RewrittenAutoHosts { </s> remove res.Reason = ReasonRewrite </s> add res.Reason = Rewritten </s> remove result.Reason = RewriteAutoHosts </s> add result.Reason = RewrittenAutoHosts </s> remove } else if res.Reason == dnsfilter.DNSRewriteRule { </s> add } else if res.Reason == dnsfilter.RewrittenRule {
} else if res.Reason == dnsfilter.RewrittenAutoHosts && len(res.ReverseHosts) != 0 {
// name. The original question is readded in // processFilteringAfterResponse. ctx.origQuestion = d.Req.Question[0] d.Req.Question[0].Name = dns.Fqdn(res.CanonName) } else if res.Reason == dnsfilter.RewrittenAutoHosts && len(res.ReverseHosts) != 0 { resp := s.makeResponse(req) for _, h := range res.ReverseHosts { hdr := dns.RR_Header{ Name: req.Question[0].Name, Rrtype: dns.TypePTR,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsforward/filter.go
resp.Answer = append(resp.Answer, ptr) } d.Res = resp } else if res.Reason == dnsfilter.ReasonRewrite || res.Reason == dnsfilter.RewriteAutoHosts { resp := s.makeResponse(req) name := host if len(res.CanonName) != 0 { resp.Answer = append(resp.Answer, s.genAnswerCNAME(req, res.CanonName))
</s> remove } else if res.Reason == dnsfilter.RewriteAutoHosts && len(res.ReverseHosts) != 0 { </s> add } else if res.Reason == dnsfilter.RewrittenAutoHosts && len(res.ReverseHosts) != 0 { </s> remove } else if res.Reason == dnsfilter.DNSRewriteRule { </s> add } else if res.Reason == dnsfilter.RewrittenRule { </s> remove res.Reason = ReasonRewrite </s> add res.Reason = Rewritten </s> remove if res.Reason == DNSRewriteRule && res.CanonName == host { </s> add if res.Reason == RewrittenRule && res.CanonName == host { </s> remove } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && </s> add } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) &&
} else if res.Reason == dnsfilter.Rewritten || res.Reason == dnsfilter.RewrittenAutoHosts {
resp.Answer = append(resp.Answer, ptr) } d.Res = resp } else if res.Reason == dnsfilter.Rewritten || res.Reason == dnsfilter.RewrittenAutoHosts { resp := s.makeResponse(req) name := host if len(res.CanonName) != 0 { resp.Answer = append(resp.Answer, s.genAnswerCNAME(req, res.CanonName))
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsforward/filter.go
} } d.Res = resp } else if res.Reason == dnsfilter.DNSRewriteRule { err = s.filterDNSRewrite(req, res, d) if err != nil { return nil, err } }
</s> remove } else if res.Reason == dnsfilter.ReasonRewrite || res.Reason == dnsfilter.RewriteAutoHosts { </s> add } else if res.Reason == dnsfilter.Rewritten || res.Reason == dnsfilter.RewrittenAutoHosts { </s> remove } else if res.Reason == dnsfilter.RewriteAutoHosts && len(res.ReverseHosts) != 0 { </s> add } else if res.Reason == dnsfilter.RewrittenAutoHosts && len(res.ReverseHosts) != 0 { </s> remove if res.Reason == DNSRewriteRule && res.CanonName == host { </s> add if res.Reason == RewrittenRule && res.CanonName == host { </s> remove } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && </s> add } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) && </s> remove if result.Reason == ReasonRewrite { </s> add if result.Reason == Rewritten {
} else if res.Reason == dnsfilter.RewrittenRule {
} } d.Res = resp } else if res.Reason == dnsfilter.RewrittenRule { err = s.filterDNSRewrite(req, res, d) if err != nil { return nil, err } }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/dnsforward/filter.go
// for FilteredBlockedService: SvcName string `json:"service_name"` // for ReasonRewrite: CanonName string `json:"cname"` // CNAME value IPList []net.IP `json:"ip_addrs"` // list of IP addresses } func (f *Filtering) handleCheckHost(w http.ResponseWriter, r *http.Request) {
</s> remove // It is empty unless Reason is set to ReasonRewrite. </s> add // It is empty unless Reason is set to Rewritten or RewrittenRule. </s> remove // Reason is set to RewriteAutoHosts or ReasonRewrite. </s> add // Reason is set to RewrittenAutoHosts or Rewritten. </s> remove ReasonRewrite: "Rewrite", RewriteAutoHosts: "RewriteEtcHosts", DNSRewriteRule: "DNSRewriteRule", </s> add Rewritten: "Rewrite", RewrittenAutoHosts: "RewriteEtcHosts", RewrittenRule: "RewriteRule", </s> remove // empty unless Reason is set to RewriteAutoHosts. </s> add // empty unless Reason is set to RewrittenAutoHosts. </s> remove case dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule: </s> add case dnsfilter.Rewritten, dnsfilter.RewrittenRule:
// for Rewritten:
// for FilteredBlockedService: SvcName string `json:"service_name"` // for Rewritten: CanonName string `json:"cname"` // CNAME value IPList []net.IP `json:"ip_addrs"` // list of IP addresses } func (f *Filtering) handleCheckHost(w http.ResponseWriter, r *http.Request) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/home/controlfiltering.go
answer.A = net.ParseIP(answerStr) a.Answer = append(a.Answer, answer) res := dnsfilter.Result{ IsFiltered: true, Reason: dnsfilter.ReasonRewrite, ServiceName: "SomeService", Rules: []*dnsfilter.ResultRule{{ FilterListID: 1, Text: "SomeRule", }},
</s> remove Reason: DNSRewriteRule, </s> add Reason: RewrittenRule, </s> remove Reason: DNSRewriteRule, </s> add Reason: RewrittenRule, </s> remove Reason: DNSRewriteRule, </s> add Reason: RewrittenRule, </s> remove case dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule: </s> add case dnsfilter.Rewritten, dnsfilter.RewrittenRule: </s> remove assert.Equal(t, ReasonRewrite, r.Reason) </s> add assert.Equal(t, Rewritten, r.Reason)
Reason: dnsfilter.Rewritten,
answer.A = net.ParseIP(answerStr) a.Answer = append(a.Answer, answer) res := dnsfilter.Result{ IsFiltered: true, Reason: dnsfilter.Rewritten, ServiceName: "SomeService", Rules: []*dnsfilter.ResultRule{{ FilterListID: 1, Text: "SomeRule", }},
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/querylog/qlog_test.go
case filteringStatusFiltered: return res.IsFiltered || res.Reason.In( dnsfilter.NotFilteredAllowList, dnsfilter.ReasonRewrite, dnsfilter.RewriteAutoHosts, ) case filteringStatusBlocked: return res.IsFiltered && res.Reason.In(dnsfilter.FilteredBlockList, dnsfilter.FilteredBlockedService)
</s> remove return res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.RewriteAutoHosts) </s> add return res.Reason.In( dnsfilter.Rewritten, dnsfilter.RewrittenAutoHosts, dnsfilter.RewrittenRule, ) </s> remove case dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule: </s> add case dnsfilter.Rewritten, dnsfilter.RewrittenRule: </s> remove } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && </s> add } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) && </s> remove ReasonRewrite: "Rewrite", RewriteAutoHosts: "RewriteEtcHosts", DNSRewriteRule: "DNSRewriteRule", </s> add Rewritten: "Rewrite", RewrittenAutoHosts: "RewriteEtcHosts", RewrittenRule: "RewriteRule", </s> remove - 'DNSRewriteRule' </s> add - 'RewriteRule'
dnsfilter.Rewritten, dnsfilter.RewrittenAutoHosts, dnsfilter.RewrittenRule,
case filteringStatusFiltered: return res.IsFiltered || res.Reason.In( dnsfilter.NotFilteredAllowList, dnsfilter.Rewritten, dnsfilter.RewrittenAutoHosts, dnsfilter.RewrittenRule, dnsfilter.Rewritten, dnsfilter.RewrittenAutoHosts, dnsfilter.RewrittenRule, ) case filteringStatusBlocked: return res.IsFiltered && res.Reason.In(dnsfilter.FilteredBlockList, dnsfilter.FilteredBlockedService)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/querylog/searchcriteria.go
case filteringStatusWhitelisted: return res.Reason == dnsfilter.NotFilteredAllowList case filteringStatusRewritten: return res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.RewriteAutoHosts) case filteringStatusSafeSearch: return res.IsFiltered && res.Reason == dnsfilter.FilteredSafeSearch case filteringStatusProcessed:
</s> remove dnsfilter.ReasonRewrite, dnsfilter.RewriteAutoHosts, </s> add dnsfilter.Rewritten, dnsfilter.RewrittenAutoHosts, dnsfilter.RewrittenRule, </s> remove case dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule: </s> add case dnsfilter.Rewritten, dnsfilter.RewrittenRule: </s> remove if res.Reason == DNSRewriteRule && res.CanonName == host { </s> add if res.Reason == RewrittenRule && res.CanonName == host { </s> remove } else if res.Reason == dnsfilter.DNSRewriteRule { </s> add } else if res.Reason == dnsfilter.RewrittenRule { </s> remove } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && </s> add } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) &&
return res.Reason.In( dnsfilter.Rewritten, dnsfilter.RewrittenAutoHosts, dnsfilter.RewrittenRule, )
case filteringStatusWhitelisted: return res.Reason == dnsfilter.NotFilteredAllowList case filteringStatusRewritten: return res.Reason.In( dnsfilter.Rewritten, dnsfilter.RewrittenAutoHosts, dnsfilter.RewrittenRule, ) case filteringStatusSafeSearch: return res.IsFiltered && res.Reason == dnsfilter.FilteredSafeSearch case filteringStatusProcessed:
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
internal/querylog/searchcriteria.go
- 'FilteredSafeSearch' - 'FilteredBlockedService' - 'Rewrite' - 'RewriteEtcHosts' - 'DNSRewriteRule' 'filter_id': 'deprecated': true 'description': > In case if there's a rule applied to this DNS request, this is ID of the filter list that the rule belongs to.
</s> remove - 'DNSRewriteRule' </s> add - 'RewriteRule' </s> remove // ReasonRewrite is returned when there was a rewrite by // a legacy DNS Rewrite rule. ReasonRewrite // RewriteAutoHosts is returned when there was a rewrite by // autohosts rules (/etc/hosts and so on). RewriteAutoHosts // DNSRewriteRule is returned when a $dnsrewrite filter rule was // applied. DNSRewriteRule </s> add // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule </s> remove if result.Reason == ReasonRewrite { </s> add if result.Reason == Rewritten { </s> remove } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && </s> add } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) && </s> remove if res.Reason == DNSRewriteRule && res.CanonName == host { </s> add if res.Reason == RewrittenRule && res.CanonName == host {
- 'RewriteRule'
- 'FilteredSafeSearch' - 'FilteredBlockedService' - 'Rewrite' - 'RewriteEtcHosts' - 'RewriteRule' 'filter_id': 'deprecated': true 'description': > In case if there's a rule applied to this DNS request, this is ID of the filter list that the rule belongs to.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
openapi/openapi.yaml
- 'FilteredSafeSearch' - 'FilteredBlockedService' - 'Rewrite' - 'RewriteEtcHosts' - 'DNSRewriteRule' 'service_name': 'type': 'string' 'description': 'Set if reason=FilteredBlockedService' 'status': 'type': 'string'
</s> remove - 'DNSRewriteRule' </s> add - 'RewriteRule' </s> remove if result.Reason == ReasonRewrite { </s> add if result.Reason == Rewritten { </s> remove } else if res.Reason.In(dnsfilter.ReasonRewrite, dnsfilter.DNSRewriteRule) && </s> add } else if res.Reason.In(dnsfilter.Rewritten, dnsfilter.RewrittenRule) && </s> remove // ReasonRewrite is returned when there was a rewrite by // a legacy DNS Rewrite rule. ReasonRewrite // RewriteAutoHosts is returned when there was a rewrite by // autohosts rules (/etc/hosts and so on). RewriteAutoHosts // DNSRewriteRule is returned when a $dnsrewrite filter rule was // applied. DNSRewriteRule </s> add // Rewritten is returned when there was a rewrite by a legacy DNS // rewrite rule. Rewritten // RewrittenAutoHosts is returned when there was a rewrite by autohosts // rules (/etc/hosts and so on). RewrittenAutoHosts // RewrittenRule is returned when a $dnsrewrite filter rule was applied. // // TODO(a.garipov): Remove Rewritten and RewrittenAutoHosts by merging // their functionality into RewrittenRule. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2499. RewrittenRule </s> remove } else if res.Reason == dnsfilter.DNSRewriteRule { </s> add } else if res.Reason == dnsfilter.RewrittenRule {
- 'RewriteRule'
- 'FilteredSafeSearch' - 'FilteredBlockedService' - 'Rewrite' - 'RewriteEtcHosts' - 'RewriteRule' 'service_name': 'type': 'string' 'description': 'Set if reason=FilteredBlockedService' 'status': 'type': 'string'
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: all: improve dnsrewrite handling Merge in DNS/adguard-home from 2491-dnsrewrite-log to master Closes #2491. Squashed commit of the following: commit bfe3cb599ed0a921285fb1a6ea27aaefdcc0d093 Merge: 95c5ffe43 15d8f979b Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 18:33:32 2020 +0300 Merge branch 'master' into 2491-dnsrewrite-log commit 95c5ffe4360b732556455f24b844dad27047e64b Author: Artem Baskal <[email protected]> Date: Mon Dec 28 18:11:01 2020 +0300 Add RewriteRule for client commit b9096c8789009dac1838b542d3409fef54b59aa5 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:22:44 2020 +0300 all: imp naming, docs commit 4e00de0d613e4740451e4c8eb5a1de35a70a5896 Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 17:16:35 2020 +0300 all: imp naming, add todo commit 67e4045f627a9569f382309705963640dcf3454a Author: Ainar Garipov <[email protected]> Date: Mon Dec 28 16:53:00 2020 +0300 all: improve dnsrewrite handling
https://github.com/AdguardTeam/AdGuardHome/commit/338209f32bdb876da19e52c366e440ea3c457470
openapi/openapi.yaml
} } return false } func handleStart(w http.ResponseWriter, r *http.Request) { if isRunning() { http.Error(w, fmt.Sprintf("Unable to start coreDNS: Already running"), 400) return } err := writeCoreDNSConfig()
</s> remove http.Error(w, fmt.Sprintf("Unable to start coreDNS: Already running"), 400) return </s> add return fmt.Errorf("Unable to start coreDNS: Already running") </s> remove errortext := fmt.Sprintf("Unable to write coredns config: %s", err) </s> add errortext := fmt.Errorf("Unable to write coredns config: %s", err) </s> remove http.Error(w, errortext, http.StatusInternalServerError) return </s> add return errortext </s> remove fmt.Fprintf(w, "OK, PID %d\n", coreDNSCommand.Process.Pid) </s> add
func startDNSServer() error {
} } return false } func startDNSServer() error { if isRunning() { http.Error(w, fmt.Sprintf("Unable to start coreDNS: Already running"), 400) return } err := writeCoreDNSConfig()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Move starting of coredns server into separate function
https://github.com/AdguardTeam/AdGuardHome/commit/33fbccf0badee8a4c5f790d850d85e161536779f
control.go
return false } func handleStart(w http.ResponseWriter, r *http.Request) { if isRunning() { http.Error(w, fmt.Sprintf("Unable to start coreDNS: Already running"), 400) return } err := writeCoreDNSConfig() if err != nil { errortext := fmt.Sprintf("Unable to write coredns config: %s", err) log.Println(errortext)
</s> remove func handleStart(w http.ResponseWriter, r *http.Request) { </s> add func startDNSServer() error { </s> remove errortext := fmt.Sprintf("Unable to write coredns config: %s", err) </s> add errortext := fmt.Errorf("Unable to write coredns config: %s", err) </s> remove http.Error(w, errortext, http.StatusInternalServerError) return </s> add return errortext </s> remove http.Error(w, errortext, http.StatusInternalServerError) return </s> add return errortext
return fmt.Errorf("Unable to start coreDNS: Already running")
return false } func handleStart(w http.ResponseWriter, r *http.Request) { if isRunning() { return fmt.Errorf("Unable to start coreDNS: Already running") return fmt.Errorf("Unable to start coreDNS: Already running") } err := writeCoreDNSConfig() if err != nil { errortext := fmt.Sprintf("Unable to write coredns config: %s", err) log.Println(errortext)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Move starting of coredns server into separate function
https://github.com/AdguardTeam/AdGuardHome/commit/33fbccf0badee8a4c5f790d850d85e161536779f
control.go