docstring_tokens
stringlengths
18
16.9k
code_tokens
stringlengths
75
1.81M
html_url
stringlengths
74
116
file_name
stringlengths
3
311
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> resp, rtt, err := c.Exchange(&req, host) <mask> if err != nil { <mask> return fmt.Errorf("Couldn't communicate with DNS server %s: %s", input, err) <mask> } <mask> trace("exchange with %s took %v", input, rtt) <mask> if len(resp.Answer) != 1 { <mask> return fmt.Errorf("DNS server %s returned wrong answer", input) <mask> } </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove return "", fmt.Errorf("Invalid DNS server field: %s", h) </s> add return "", fmt.Errorf("invalid DNS server field: %s", h) </s> remove errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove err = writeFileSafe(corefile, []byte(configtext)) </s> add err = writeFileSafe(coreFile, []byte(configText)) </s> remove // use same update period for failed filter downloads to avoid flooding with requests </s> add // use the same update period for failed filter downloads to avoid flooding with requests </s> remove log.Printf("Downloading update for filter %d", filter.ID) </s> add log.Printf("Downloading update for filter %d from %s", filter.ID, filter.URL) </s> remove configtext := configBytes.String() </s> add configText := configBytes.String()
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> func sanitiseDNSServers(input string) ([]string, error) { <mask> fields := strings.Fields(input) <mask> hosts := []string{} <mask> for _, field := range fields { <mask> sanitized, err := sanitizeDNSServer(field) <mask> if err != nil { <mask> return hosts, err <mask> } </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> add // Saving it to the filters dir now err = filter.save() if err != nil { log.Fatal(err) } </s> remove updated, err := filter.update(false) </s> add updated, err := filter.update(force) </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configfile) if _, err := os.Stat(configfile); os.IsNotExist(err) { </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Reading YAML file: %s", configFile) if _, err := os.Stat(configFile); os.IsNotExist(err) { </s> add //noinspection GoUnusedParameter </s> remove // deduplicate // TODO: move it somewhere else { i := 0 // output index, used for deletion later urls := map[string]bool{} for _, filter := range config.Filters { if _, ok := urls[filter.URL]; !ok { // we didn't see it before, keep it urls[filter.URL] = true // remember the URL config.Filters[i] = filter i++ } } // all entries we want to keep are at front, delete the rest config.Filters = config.Filters[:i] } </s> add </s> remove lines := strings.Split(string(body), "\n") rulesCount := 0 seenTitle := false </s> add rulesCount, filterName := parseFilterContents(body)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep keep replace keep keep keep keep keep
<mask> return "", err <mask> } <mask> ip := net.ParseIP(h) <mask> if ip == nil { <mask> return "", fmt.Errorf("Invalid DNS server field: %s", h) <mask> } <mask> } <mask> return prefix + host, nil <mask> } <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove configtext := configBytes.String() </s> add configText := configBytes.String() </s> remove return fmt.Errorf("Couldn't communicate with DNS server %s: %s", input, err) </s> add return fmt.Errorf("couldn't communicate with DNS server %s: %s", input, err) </s> remove err = writeFileSafe(corefile, []byte(configtext)) </s> add err = writeFileSafe(coreFile, []byte(configText)) </s> remove // generate config text </s> add // generate CoreDNS config text </s> remove corefile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", corefile) configtext, err := generateCoreDNSConfigText() </s> add coreFile := filepath.Join(config.ourBinaryDir, config.CoreDNS.coreFile) log.Printf("Writing DNS config: %s", coreFile) configText, err := generateCoreDNSConfigText() </s> remove configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configfile) </s> add configFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) log.Printf("Writing YAML file: %s", configFile)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep add keep keep keep keep keep
<mask> } <mask> return net.JoinHostPort(input, port) <mask> } <mask> <mask> func handleGetVersionJSON(w http.ResponseWriter, r *http.Request) { <mask> now := time.Now() <mask> if now.Sub(versionCheckLastTime) <= versionCheckPeriod && len(versionCheckJSON) != 0 { <mask> // return cached copy <mask> w.Header().Set("Content-Type", "application/json") </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // Count lines in the filter for _, line := range lines { line = strings.TrimSpace(line) if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { filter.Name = m[0][1] seenTitle = true } } else if len(line) != 0 { rulesCount++ } </s> add if filterName != "" { filter.Name = filterName </s> remove if force != "" { config.Lock() for i := range config.Filters { filter := &config.Filters[i] // otherwise we will be operating on a copy filter.LastUpdated = time.Unix(0, 0) } config.Unlock() // not defer because refreshFiltersIfNeccessary locks it too } updated := refreshFiltersIfNeccessary() </s> add updated := checkFiltersUpdates(force != "") </s> remove log.Printf("Downloading update for filter %d", filter.ID) </s> add log.Printf("Downloading update for filter %d from %s", filter.ID, filter.URL) </s> remove errortext := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> add // Saving it to the filters dir now err = filter.save() if err != nil { log.Printf("Failed to save the updated filter %d: %s", filter.ID, err) continue } </s> add //noinspection GoUnusedParameter
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep add keep keep keep keep keep
<mask> config.CoreDNS.FilteringEnabled = false <mask> httpUpdateConfigReloadDNSReturnOK(w, r) <mask> } <mask> <mask> func handleFilteringStatus(w http.ResponseWriter, r *http.Request) { <mask> data := map[string]interface{}{ <mask> "enabled": config.CoreDNS.FilteringEnabled, <mask> } <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> remove // TODO: Start using filter ID </s> add </s> remove refreshFiltersIfNeccessary() </s> add checkFiltersUpdates(false)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep keep replace keep keep keep keep keep
<mask> httpError(w, http.StatusBadRequest, "Failed to parse request body json: %s", err) <mask> return <mask> } <mask> <mask> filter.Enabled = true <mask> if len(filter.URL) == 0 { <mask> http.Error(w, "URL parameter was not specified", 400) <mask> return <mask> } <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // check for duplicates </s> add // Check for duplicates </s> remove errortext := fmt.Sprintf("Failed to read request body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("Failed to read request body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // Count lines in the filter for _, line := range lines { line = strings.TrimSpace(line) if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { filter.Name = m[0][1] seenTitle = true } } else if len(line) != 0 { rulesCount++ } </s> add if filterName != "" { filter.Name = filterName </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep replace keep keep replace replace replace keep keep
<mask> } <mask> <mask> // check for duplicates <mask> for i := range config.Filters { <mask> if config.Filters[i].URL == filter.URL { <mask> errortext := fmt.Sprintf("Filter URL already added -- %s", filter.URL) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusBadRequest) <mask> return <mask> } </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Filter at url %s has no rules (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s has no rules (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) return } // Save the filter contents err = filter.save() if err != nil { errorText := fmt.Sprintf("Failed to save filter %d due to %s", filter.ID, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove // deduplicate // TODO: move it somewhere else { i := 0 // output index, used for deletion later urls := map[string]bool{} for _, filter := range config.Filters { if _, ok := urls[filter.URL]; !ok { // we didn't see it before, keep it urls[filter.URL] = true // remember the URL config.Filters[i] = filter i++ } } // all entries we want to keep are at front, delete the rest config.Filters = config.Filters[:i] } </s> add </s> remove updated, err := filter.update(false) </s> add updated, err := filter.update(force)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep add keep keep keep keep keep keep
<mask> return <mask> } <mask> } <mask> <mask> ok, err := filter.update(true) <mask> if err != nil { <mask> errorText := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) <mask> log.Println(errorText) <mask> http.Error(w, errorText, http.StatusBadRequest) <mask> return </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) return } // Save the filter contents err = filter.save() if err != nil { errorText := fmt.Sprintf("Failed to save filter %d due to %s", filter.ID, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't remove the filter file: %s", err) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't remove the filter file: %s", err) http.Error(w, errorText, http.StatusInternalServerError)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep replace replace replace keep keep keep replace replace replace
<mask> ok, err := filter.update(true) <mask> if err != nil { <mask> errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusBadRequest) <mask> return <mask> } <mask> if filter.RulesCount == 0 { <mask> errortext := fmt.Sprintf("Filter at url %s has no rules (maybe it points to blank page?)", filter.URL) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusBadRequest) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) return } // Save the filter contents err = filter.save() if err != nil { errorText := fmt.Sprintf("Failed to save filter %d due to %s", filter.ID, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> add // Set necessary properties filter.ID = NextFilterId filter.Enabled = true NextFilterId++ // Download the filter contents </s> remove // check for duplicates </s> add // Check for duplicates </s> remove errortext := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> http.Error(w, errortext, http.StatusBadRequest) <mask> return <mask> } <mask> if !ok { <mask> errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", filter.URL) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusBadRequest) <mask> return <mask> } <mask> <mask> // URL is deemed valid, append it to filters, update config, write new filter file and tell coredns to reload it <mask> config.Filters = append(config.Filters, filter) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Filter at url %s has no rules (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s has no rules (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter URL already added -- %s", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove // check for duplicates </s> add // Check for duplicates </s> remove errortext := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> // URL is deemed valid, append it to filters, update config, write new filter file and tell coredns to reload it <mask> config.Filters = append(config.Filters, filter) <mask> err = writeAllConfigs() <mask> if err != nil { <mask> errortext := fmt.Sprintf("Couldn't write config file: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusInternalServerError) <mask> return <mask> } <mask> <mask> tellCoreDNSToReload() <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Filter at the url %s is invalid (maybe it points to blank page?)", filter.URL) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) return } // Save the filter contents err = filter.save() if err != nil { errorText := fmt.Sprintf("Failed to save filter %d due to %s", filter.ID, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest) </s> remove errortext := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't remove the filter file: %s", err) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't remove the filter file: %s", err) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errortext) http.Error(w, errortext, http.StatusBadRequest) </s> add errorText := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) log.Println(errorText) http.Error(w, errorText, http.StatusBadRequest)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep replace replace replace keep keep keep replace keep keep
<mask> <mask> _, err = fmt.Fprintf(w, "OK %d rules\n", filter.RulesCount) <mask> if err != nil { <mask> errortext := fmt.Sprintf("Couldn't write body: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusInternalServerError) <mask> } <mask> } <mask> <mask> // TODO: Start using filter ID <mask> func handleFilteringRemoveURL(w http.ResponseWriter, r *http.Request) { <mask> parameters, err := parseParametersFromBody(r.Body) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> // TODO: Start using filter ID <mask> func handleFilteringRemoveURL(w http.ResponseWriter, r *http.Request) { <mask> parameters, err := parseParametersFromBody(r.Body) <mask> if err != nil { <mask> errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, 400) <mask> return <mask> } <mask> <mask> url, ok := parameters["url"] <mask> if !ok { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add </s> remove errortext := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep keep replace replace keep keep keep keep keep
<mask> } else { <mask> // Remove the filter file <mask> err := os.Remove(filter.getFilterFilePath()) <mask> if err != nil { <mask> errortext := fmt.Sprintf("Couldn't remove the filter file: %s", err) <mask> http.Error(w, errortext, http.StatusInternalServerError) <mask> return <mask> } <mask> } <mask> } <mask> // Update the configuration after removing filter files </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove // TODO: Start using filter ID </s> add </s> add // Saves configuration to the YAML file and also saves the user filter contents to a file </s> add // Set necessary properties filter.ID = NextFilterId filter.Enabled = true NextFilterId++ // Download the filter contents
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep replace keep keep keep replace replace replace keep keep keep
<mask> } <mask> <mask> // TODO: Start using filter ID <mask> func handleFilteringEnableURL(w http.ResponseWriter, r *http.Request) { <mask> parameters, err := parseParametersFromBody(r.Body) <mask> if err != nil { <mask> errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, 400) <mask> return <mask> } <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add </s> remove errortext := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep replace keep keep keep replace keep keep keep keep
<mask> // kick off refresh of rules from new URLs <mask> refreshFiltersIfNeccessary() <mask> httpUpdateConfigReloadDNSReturnOK(w, r) <mask> } <mask> <mask> // TODO: Start using filter ID <mask> func handleFilteringDisableURL(w http.ResponseWriter, r *http.Request) { <mask> parameters, err := parseParametersFromBody(r.Body) <mask> if err != nil { <mask> errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // TODO: Start using filter ID </s> add </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> // TODO: Start using filter ID <mask> func handleFilteringDisableURL(w http.ResponseWriter, r *http.Request) { <mask> parameters, err := parseParametersFromBody(r.Body) <mask> if err != nil { <mask> errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, 400) <mask> return <mask> } <mask> <mask> url, ok := parameters["url"] <mask> if !ok { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add </s> remove errortext := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> <mask> func handleFilteringSetRules(w http.ResponseWriter, r *http.Request) { <mask> body, err := ioutil.ReadAll(r.Body) <mask> if err != nil { <mask> errortext := fmt.Sprintf("Failed to read request body: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, 400) <mask> return <mask> } <mask> <mask> config.UserRules = strings.Split(string(body), "\n") <mask> httpUpdateConfigReloadDNSReturnOK(w, r) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove errortext := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errortext) http.Error(w, errortext, 400) </s> add errorText := fmt.Sprintf("failed to parse parameters from body: %s", err) log.Println(errorText) http.Error(w, errorText, 400) </s> remove // TODO: Start using filter ID </s> add </s> remove // TODO: Start using filter ID </s> add </s> add //noinspection GoUnusedParameter
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep replace replace replace replace replace replace replace replace replace keep keep keep replace
<mask> force := r.URL.Query().Get("force") <mask> if force != "" { <mask> config.Lock() <mask> for i := range config.Filters { <mask> filter := &config.Filters[i] // otherwise we will be operating on a copy <mask> filter.LastUpdated = time.Unix(0, 0) <mask> } <mask> config.Unlock() // not defer because refreshFiltersIfNeccessary locks it too <mask> } <mask> updated := refreshFiltersIfNeccessary() <mask> fmt.Fprintf(w, "OK %d filters updated\n", updated) <mask> } <mask> <mask> func runFilterRefreshers() { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove updated, err := filter.update(false) </s> add updated, err := filter.update(force) </s> remove // deduplicate // TODO: move it somewhere else { i := 0 // output index, used for deletion later urls := map[string]bool{} for _, filter := range config.Filters { if _, ok := urls[filter.URL]; !ok { // we didn't see it before, keep it urls[filter.URL] = true // remember the URL config.Filters[i] = filter i++ } } // all entries we want to keep are at front, delete the rest config.Filters = config.Filters[:i] } </s> add </s> remove func refreshFiltersIfNeccessary() int { </s> add // Checks filters updates if necessary // If force is true, it ignores the filter.LastUpdated field value func checkFiltersUpdates(force bool) int { </s> remove // check for duplicates </s> add // Check for duplicates </s> add // Saving it to the filters dir now err = filter.save() if err != nil { log.Printf("Failed to save the updated filter %d: %s", filter.ID, err) continue }
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep replace replace keep keep keep keep replace
<mask> go func() { <mask> for range time.Tick(time.Second) { <mask> refreshFiltersIfNeccessary() <mask> } <mask> }() <mask> } <mask> <mask> func refreshFiltersIfNeccessary() int { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove func runFilterRefreshers() { </s> add // Sets up a timer that will be checking for filters updates periodically func runFiltersUpdatesTimer() { </s> remove if force != "" { config.Lock() for i := range config.Filters { filter := &config.Filters[i] // otherwise we will be operating on a copy filter.LastUpdated = time.Unix(0, 0) } config.Unlock() // not defer because refreshFiltersIfNeccessary locks it too } updated := refreshFiltersIfNeccessary() </s> add updated := checkFiltersUpdates(force != "") </s> remove // deduplicate // TODO: move it somewhere else { i := 0 // output index, used for deletion later urls := map[string]bool{} for _, filter := range config.Filters { if _, ok := urls[filter.URL]; !ok { // we didn't see it before, keep it urls[filter.URL] = true // remember the URL config.Filters[i] = filter i++ } } // all entries we want to keep are at front, delete the rest config.Filters = config.Filters[:i] } </s> add </s> remove refreshFiltersIfNeccessary() </s> add checkFiltersUpdates(false) </s> remove // TODO: Start using filter ID </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep replace keep keep keep keep
<mask> func refreshFiltersIfNeccessary() int { <mask> config.Lock() <mask> <mask> // deduplicate <mask> // TODO: move it somewhere else <mask> { <mask> i := 0 // output index, used for deletion later <mask> urls := map[string]bool{} <mask> for _, filter := range config.Filters { <mask> if _, ok := urls[filter.URL]; !ok { <mask> // we didn't see it before, keep it <mask> urls[filter.URL] = true // remember the URL <mask> config.Filters[i] = filter <mask> i++ <mask> } <mask> } <mask> // all entries we want to keep are at front, delete the rest <mask> config.Filters = config.Filters[:i] <mask> } <mask> <mask> // fetch URLs <mask> updateCount := 0 <mask> for i := range config.Filters { <mask> filter := &config.Filters[i] // otherwise we will be operating on a copy <mask> updated, err := filter.update(false) <mask> if err != nil { <mask> log.Printf("Failed to update filter %s: %s\n", filter.URL, err) <mask> continue <mask> } </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove if force != "" { config.Lock() for i := range config.Filters { filter := &config.Filters[i] // otherwise we will be operating on a copy filter.LastUpdated = time.Unix(0, 0) } config.Unlock() // not defer because refreshFiltersIfNeccessary locks it too } updated := refreshFiltersIfNeccessary() </s> add updated := checkFiltersUpdates(force != "") </s> remove func refreshFiltersIfNeccessary() int { </s> add // Checks filters updates if necessary // If force is true, it ignores the filter.LastUpdated field value func checkFiltersUpdates(force bool) int { </s> remove // Count lines in the filter for _, line := range lines { line = strings.TrimSpace(line) if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { filter.Name = m[0][1] seenTitle = true } } else if len(line) != 0 { rulesCount++ } </s> add if filterName != "" { filter.Name = filterName </s> add // Saving it to the filters dir now err = filter.save() if err != nil { log.Printf("Failed to save the updated filter %d: %s", filter.ID, err) continue } </s> add // Saving it to the filters dir now err = filter.save() if err != nil { log.Fatal(err) }
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep add keep keep keep keep keep keep
<mask> } <mask> if updated { <mask> updateCount++ <mask> } <mask> } <mask> config.Unlock() <mask> <mask> if updateCount > 0 { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove jsonentry["status"] = status.String() </s> add jsonEntry["status"] = status.String() </s> remove jsonentry["rule"] = entry.Result.Rule </s> add jsonEntry["rule"] = entry.Result.Rule jsonEntry["filterId"] = entry.Result.FilterID </s> remove // Count lines in the filter for _, line := range lines { line = strings.TrimSpace(line) if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { filter.Name = m[0][1] seenTitle = true } } else if len(line) != 0 { rulesCount++ } </s> add if filterName != "" { filter.Name = filterName </s> remove updated, err := filter.update(false) </s> add updated, err := filter.update(force) </s> remove if force != "" { config.Lock() for i := range config.Filters { filter := &config.Filters[i] // otherwise we will be operating on a copy filter.LastUpdated = time.Unix(0, 0) } config.Unlock() // not defer because refreshFiltersIfNeccessary locks it too } updated := refreshFiltersIfNeccessary() </s> add updated := checkFiltersUpdates(force != "") </s> remove lines := strings.Split(string(body), "\n") rulesCount := 0 seenTitle := false </s> add rulesCount, filterName := parseFilterContents(body)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep add keep keep keep keep keep
<mask> // Checks for filters updates <mask> // If "force" is true -- does not check the filter's LastUpdated field <mask> func (filter *filter) update(force bool) (bool, error) { <mask> if !filter.Enabled { <mask> return false, nil <mask> } <mask> if !force && time.Since(filter.LastUpdated) <= updatePeriod { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove func refreshFiltersIfNeccessary() int { </s> add // Checks filters updates if necessary // If force is true, it ignores the filter.LastUpdated field value func checkFiltersUpdates(force bool) int { </s> remove log.Printf("Downloading update for filter %d", filter.ID) </s> add log.Printf("Downloading update for filter %d from %s", filter.ID, filter.URL) </s> remove // check for duplicates </s> add // Check for duplicates </s> remove // Saving it to the filters dir now err = filter.save() if err != nil { return false, nil } </s> add </s> remove return nil; </s> add return nil </s> remove // Count lines in the filter for _, line := range lines { line = strings.TrimSpace(line) if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { filter.Name = m[0][1] seenTitle = true } } else if len(line) != 0 { rulesCount++ } </s> add if filterName != "" { filter.Name = filterName
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep replace keep replace keep keep keep keep
<mask> <mask> log.Printf("Downloading update for filter %d", filter.ID) <mask> <mask> // use same update period for failed filter downloads to avoid flooding with requests <mask> filter.LastUpdated = time.Now() <mask> <mask> resp, err := client.Get(filter.URL) <mask> if resp != nil && resp.Body != nil { </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove updated, err := filter.update(false) </s> add updated, err := filter.update(force) </s> remove log.Printf("Filter %d length is %d", filter.ID, len(filterFile)) filter.contents = filterFile </s> add log.Printf("Filter %d length is %d", filter.ID, len(filterFileContents)) filter.contents = filterFileContents // Now extract the rules count rulesCount, _ := parseFilterContents(filter.contents) filter.RulesCount = rulesCount </s> remove // Count lines in the filter for _, line := range lines { line = strings.TrimSpace(line) if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { filter.Name = m[0][1] seenTitle = true } } else if len(line) != 0 { rulesCount++ } </s> add if filterName != "" { filter.Name = filterName </s> remove errortext := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove return fmt.Errorf("Couldn't communicate with DNS server %s: %s", input, err) </s> add return fmt.Errorf("couldn't communicate with DNS server %s: %s", input, err)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep keep replace replace replace keep replace replace replace replace replace replace replace replace replace replace replace
<mask> return false, err <mask> } <mask> <mask> // Extract filter name and count number of rules <mask> lines := strings.Split(string(body), "\n") <mask> rulesCount := 0 <mask> seenTitle := false <mask> <mask> // Count lines in the filter <mask> for _, line := range lines { <mask> line = strings.TrimSpace(line) <mask> if len(line) > 0 && line[0] == '!' { <mask> if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { <mask> filter.Name = m[0][1] <mask> seenTitle = true <mask> } <mask> } else if len(line) != 0 { <mask> rulesCount++ <mask> } </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove jsonentry["rule"] = entry.Result.Rule </s> add jsonEntry["rule"] = entry.Result.Rule jsonEntry["filterId"] = entry.Result.FilterID </s> remove // deduplicate // TODO: move it somewhere else { i := 0 // output index, used for deletion later urls := map[string]bool{} for _, filter := range config.Filters { if _, ok := urls[filter.URL]; !ok { // we didn't see it before, keep it urls[filter.URL] = true // remember the URL config.Filters[i] = filter i++ } } // all entries we want to keep are at front, delete the rest config.Filters = config.Filters[:i] } </s> add </s> remove jsonentry["status"] = status.String() </s> add jsonEntry["status"] = status.String() </s> add // Saving it to the filters dir now err = filter.save() if err != nil { log.Printf("Failed to save the updated filter %d: %s", filter.ID, err) continue } </s> add //noinspection GoUnusedParameter
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep keep replace keep keep keep keep keep
<mask> rulesCount++ <mask> } <mask> } <mask> <mask> // Check if the filter was really changed <mask> if bytes.Equal(filter.contents, body) { <mask> return false, nil <mask> } <mask> <mask> log.Printf("Filter %s updated: %d bytes, %d rules", filter.URL, len(body), rulesCount) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove log.Printf("Filter %s updated: %d bytes, %d rules", filter.URL, len(body), rulesCount) </s> add log.Printf("Filter %d has been updated: %d bytes, %d rules", filter.ID, len(body), rulesCount) </s> add log.Printf("The filter %d text has not changed", filter.ID) </s> remove // Saving it to the filters dir now err = filter.save() if err != nil { return false, nil } </s> add </s> remove // Count lines in the filter for _, line := range lines { line = strings.TrimSpace(line) if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { filter.Name = m[0][1] seenTitle = true } } else if len(line) != 0 { rulesCount++ } </s> add if filterName != "" { filter.Name = filterName </s> remove log.Printf("Filter %d length is %d", filter.ID, len(filterFile)) filter.contents = filterFile </s> add log.Printf("Filter %d length is %d", filter.ID, len(filterFileContents)) filter.contents = filterFileContents // Now extract the rules count rulesCount, _ := parseFilterContents(filter.contents) filter.RulesCount = rulesCount </s> remove filterFile, err := ioutil.ReadFile(filterFilePath) </s> add filterFileContents, err := ioutil.ReadFile(filterFilePath)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep add keep keep keep keep keep keep
<mask> // Check if the filter has been really changed <mask> if bytes.Equal(filter.contents, body) { <mask> return false, nil <mask> } <mask> <mask> log.Printf("Filter %d has been updated: %d bytes, %d rules", filter.ID, len(body), rulesCount) <mask> filter.RulesCount = rulesCount <mask> filter.contents = body </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove log.Printf("Filter %s updated: %d bytes, %d rules", filter.URL, len(body), rulesCount) </s> add log.Printf("Filter %d has been updated: %d bytes, %d rules", filter.ID, len(body), rulesCount) </s> remove // Check if the filter was really changed </s> add // Check if the filter has been really changed </s> remove // Saving it to the filters dir now err = filter.save() if err != nil { return false, nil } </s> add </s> remove log.Printf("Filter %d length is %d", filter.ID, len(filterFile)) filter.contents = filterFile </s> add log.Printf("Filter %d length is %d", filter.ID, len(filterFileContents)) filter.contents = filterFileContents // Now extract the rules count rulesCount, _ := parseFilterContents(filter.contents) filter.RulesCount = rulesCount </s> remove // Count lines in the filter for _, line := range lines { line = strings.TrimSpace(line) if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { filter.Name = m[0][1] seenTitle = true } } else if len(line) != 0 { rulesCount++ } </s> add if filterName != "" { filter.Name = filterName </s> remove filterFile, err := ioutil.ReadFile(filterFilePath) </s> add filterFileContents, err := ioutil.ReadFile(filterFilePath)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep replace keep keep keep replace replace replace replace replace replace keep keep
<mask> <mask> log.Printf("Filter %s updated: %d bytes, %d rules", filter.URL, len(body), rulesCount) <mask> filter.RulesCount = rulesCount <mask> filter.contents = body <mask> <mask> // Saving it to the filters dir now <mask> err = filter.save() <mask> if err != nil { <mask> return false, nil <mask> } <mask> <mask> return true, nil <mask> } </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> add log.Printf("The filter %d text has not changed", filter.ID) </s> remove // Check if the filter was really changed </s> add // Check if the filter has been really changed </s> add // Saving it to the filters dir now err = filter.save() if err != nil { log.Fatal(err) } </s> remove log.Printf("Filter %d length is %d", filter.ID, len(filterFile)) filter.contents = filterFile </s> add log.Printf("Filter %d length is %d", filter.ID, len(filterFileContents)) filter.contents = filterFileContents // Now extract the rules count rulesCount, _ := parseFilterContents(filter.contents) filter.RulesCount = rulesCount </s> add // Saving it to the filters dir now err = filter.save() if err != nil { log.Printf("Failed to save the updated filter %d: %s", filter.ID, err) continue }
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep keep replace keep keep keep keep keep
<mask> if err != nil { <mask> return err <mask> } <mask> <mask> return nil; <mask> } <mask> <mask> // loads filter contents from the file in config.ourDataDir <mask> func (filter *filter) load() error { <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // Saving it to the filters dir now err = filter.save() if err != nil { return false, nil } </s> add </s> remove log.Printf("Filter %d length is %d", filter.ID, len(filterFile)) filter.contents = filterFile </s> add log.Printf("Filter %d length is %d", filter.ID, len(filterFileContents)) filter.contents = filterFileContents // Now extract the rules count rulesCount, _ := parseFilterContents(filter.contents) filter.RulesCount = rulesCount </s> add // Saves configuration to the YAML file and also saves the user filter contents to a file </s> add // Call "save" to persist the filter contents </s> add // Loads configuration from the YAML file </s> remove return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID) + ".txt") </s> add return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID)+".txt")
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep replace keep keep keep keep replace replace keep keep
<mask> return err <mask> } <mask> <mask> filterFile, err := ioutil.ReadFile(filterFilePath) <mask> if err != nil { <mask> return err <mask> } <mask> <mask> log.Printf("Filter %d length is %d", filter.ID, len(filterFile)) <mask> filter.contents = filterFile <mask> return nil <mask> } </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove log.Printf("Filter %s updated: %d bytes, %d rules", filter.URL, len(body), rulesCount) </s> add log.Printf("Filter %d has been updated: %d bytes, %d rules", filter.ID, len(body), rulesCount) </s> remove // Saving it to the filters dir now err = filter.save() if err != nil { return false, nil } </s> add </s> add log.Printf("The filter %d text has not changed", filter.ID) </s> remove err = writeFileSafe(corefile, []byte(configtext)) </s> add err = writeFileSafe(coreFile, []byte(configText)) </s> remove err = writeFileSafe(configfile, yamlText) </s> add err = writeFileSafe(configFile, yamlText)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> // Path to the filter contents <mask> func (filter *filter) getFilterFilePath() string { <mask> return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID) + ".txt") <mask> } <mask> <mask> // ------------ <mask> // safebrowsing <mask> // ------------ </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove log.Printf("Filter %d length is %d", filter.ID, len(filterFile)) filter.contents = filterFile </s> add log.Printf("Filter %d length is %d", filter.ID, len(filterFileContents)) filter.contents = filterFileContents // Now extract the rules count rulesCount, _ := parseFilterContents(filter.contents) filter.RulesCount = rulesCount </s> remove return nil; </s> add return nil </s> add // Call "save" to persist the filter contents </s> remove // Saving it to the filters dir now err = filter.save() if err != nil { return false, nil } </s> add </s> add // Saves configuration to the YAML file and also saves the user filter contents to a file </s> remove ID int `json:"ID"` // auto-assigned when filter is added </s> add ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep add keep keep keep keep keep
<mask> } <mask> <mask> func handleSafeBrowsingStatus(w http.ResponseWriter, r *http.Request) { <mask> data := map[string]interface{}{ <mask> "enabled": config.CoreDNS.SafeBrowsingEnabled, <mask> } <mask> jsonVal, err := json.Marshal(data) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> remove data = append(data, jsonentry) </s> add data = append(data, jsonEntry) </s> add //noinspection GoUnusedParameter </s> remove errortext := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep add keep keep keep keep keep keep
<mask> config.CoreDNS.ParentalEnabled = false <mask> httpUpdateConfigReloadDNSReturnOK(w, r) <mask> } <mask> <mask> func handleParentalStatus(w http.ResponseWriter, r *http.Request) { <mask> data := map[string]interface{}{ <mask> "enabled": config.CoreDNS.ParentalEnabled, <mask> } <mask> if config.CoreDNS.ParentalEnabled { <mask> data["sensitivity"] = config.CoreDNS.ParentalSensitivity </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> remove // TODO: Start using filter ID </s> add </s> add //noinspection GoUnusedParameter </s> remove // TODO: Start using filter ID </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep add keep keep keep keep keep
<mask> httpUpdateConfigReloadDNSReturnOK(w, r) <mask> } <mask> <mask> func handleSafeSearchStatus(w http.ResponseWriter, r *http.Request) { <mask> data := map[string]interface{}{ <mask> "enabled": config.CoreDNS.SafeSearchEnabled, <mask> } <mask> jsonVal, err := json.Marshal(data) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> remove data = append(data, jsonentry) </s> add data = append(data, jsonEntry) </s> add //noinspection GoUnusedParameter </s> remove // TODO: Start using filter ID </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep replace keep keep keep keep replace replace replace replace
<mask> http.HandleFunc("/control/enable_protection", optionalAuth(ensurePOST(handleProtectionEnable))) <mask> http.HandleFunc("/control/disable_protection", optionalAuth(ensurePOST(handleProtectionDisable))) <mask> http.HandleFunc("/control/querylog", optionalAuth(ensureGET(coredns_plugin.HandleQueryLog))) <mask> http.HandleFunc("/control/querylog_enable", optionalAuth(ensurePOST(handleQueryLogEnable))) <mask> http.HandleFunc("/control/querylog_disable", optionalAuth(ensurePOST(handleQueryLogDisable))) <mask> http.HandleFunc("/control/set_upstream_dns", optionalAuth(ensurePOST(handleSetUpstreamDNS))) <mask> http.HandleFunc("/control/test_upstream_dns", optionalAuth(ensurePOST(handleTestUpstreamDNS))) <mask> http.HandleFunc("/control/stats_top", optionalAuth(ensureGET(coredns_plugin.HandleStatsTop))) <mask> http.HandleFunc("/control/stats", optionalAuth(ensureGET(coredns_plugin.HandleStats))) <mask> http.HandleFunc("/control/stats_history", optionalAuth(ensureGET(coredns_plugin.HandleStatsHistory))) <mask> http.HandleFunc("/control/stats_reset", optionalAuth(ensurePOST(coredns_plugin.HandleStatsReset))) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove urls: - 'https://filters.adtidy.org/windows/filters/1.txt' - 'https://filters.adtidy.org/windows/filters/2.txt' </s> add - filters: enabled: true id: 1 lastUpdated: "2018-10-30T12:18:57.223101822+03:00" name: "AdGuard Simplified Domain Names filter" rulesCount: 24896 url: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt" </s> add //noinspection GoUnusedParameter </s> remove var filterTitle = regexp.MustCompile(`^! Title: +(.*)$`) </s> add var filterTitleRegexp = regexp.MustCompile(`^! Title: +(.*)$`) </s> remove coredns_plugin.Reload <- true </s> add coreDnsPlugin.Reload <- true </s> add //noinspection GoUnusedParameter
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
control.go
keep keep keep keep replace keep keep keep keep keep
<mask> queryLogRotationPeriod = time.Hour * 24 // rotate the log every 24 hours <mask> queryLogFileName = "querylog.json" // .gz added during compression <mask> queryLogSize = 5000 // maximum API response for /querylog <mask> queryLogTopSize = 500 // Keep in memory only top N values <mask> queryLogAPIPort = "8618" // 8618 is sha512sum of "querylog" then each byte summed <mask> ) <mask> <mask> var ( <mask> logBufferLock sync.RWMutex <mask> logBuffer []*logEntry </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove var filterTitle = regexp.MustCompile(`^! Title: +(.*)$`) </s> add var filterTitleRegexp = regexp.MustCompile(`^! Title: +(.*)$`) </s> remove queryLogTime time.Time </s> add </s> add // Just a counter that we use for incrementing the filter ID var NextFilterId int </s> remove lines := strings.Split(string(body), "\n") rulesCount := 0 seenTitle := false </s> add rulesCount, filterName := parseFilterContents(body) </s> remove contents := []byte{} </s> add var contents []byte </s> remove // Saving it to the filters dir now err = filter.save() if err != nil { return false, nil } </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
coredns_plugin/querylog.go
keep keep keep keep replace keep keep keep keep keep
<mask> logBuffer []*logEntry <mask> <mask> queryLogCache []*logEntry <mask> queryLogLock sync.RWMutex <mask> queryLogTime time.Time <mask> ) <mask> <mask> type logEntry struct { <mask> Question []byte <mask> Answer []byte `json:",omitempty"` // sometimes empty answers happen like binerdunt.top or rev2.globalrootservers.net </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove queryLogAPIPort = "8618" // 8618 is sha512sum of "querylog" then each byte summed </s> add </s> remove LastUpdated time.Time `json:"last_updated" yaml:"-"` </s> add LastUpdated time.Time `json:"lastUpdated" yaml:"last_updated"` </s> remove var filterTitle = regexp.MustCompile(`^! Title: +(.*)$`) </s> add var filterTitleRegexp = regexp.MustCompile(`^! Title: +(.*)$`) </s> remove ID int `json:"ID"` // auto-assigned when filter is added </s> add ID int `json:"id" yaml:"id"` // auto-assigned when filter is added (see NextFilterId) </s> remove RulesCount int `json:"rules_count" yaml:"-"` </s> add RulesCount int `json:"rulesCount" yaml:"-"` </s> add // Config filename (can be overriden via the command line arguments)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
coredns_plugin/querylog.go
keep keep add keep keep keep keep keep keep
<mask> } <mask> } <mask> <mask> func HandleQueryLog(w http.ResponseWriter, r *http.Request) { <mask> queryLogLock.RLock() <mask> values := make([]*logEntry, len(queryLogCache)) <mask> copy(values, queryLogCache) <mask> queryLogLock.RUnlock() <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
coredns_plugin/querylog.go
keep replace keep keep keep keep keep keep keep keep replace keep keep
<mask> <mask> jsonentry := map[string]interface{}{ <mask> "reason": entry.Result.Reason.String(), <mask> "elapsed_ms": strconv.FormatFloat(entry.Elapsed.Seconds()*1000, 'f', -1, 64), <mask> "time": entry.Time.Format(time.RFC3339), <mask> "client": entry.IP, <mask> } <mask> <mask> jsonentry := map[string]interface{}{ <mask> "reason": entry.Result.Reason.String(), <mask> "elapsed_ms": strconv.FormatFloat(entry.Elapsed.Seconds()*1000, 'f', -1, 64), <mask> "time": entry.Time.Format(time.RFC3339), <mask> "client": entry.IP, </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove jsonentry["question"] = map[string]interface{}{ </s> add jsonEntry["question"] = map[string]interface{}{ </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
coredns_plugin/querylog.go
keep keep keep keep replace keep keep keep keep keep
<mask> "time": entry.Time.Format(time.RFC3339), <mask> "client": entry.IP, <mask> } <mask> if q != nil { <mask> jsonentry["question"] = map[string]interface{}{ <mask> "host": strings.ToLower(strings.TrimSuffix(q.Question[0].Name, ".")), <mask> "type": dns.Type(q.Question[0].Qtype).String(), <mask> "class": dns.Class(q.Question[0].Qclass).String(), <mask> } <mask> } </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove "elapsed_ms": strconv.FormatFloat(entry.Elapsed.Seconds()*1000, 'f', -1, 64), </s> add "elapsedMs": strconv.FormatFloat(entry.Elapsed.Seconds()*1000, 'f', -1, 64), </s> remove jsonentry := map[string]interface{}{ </s> add jsonEntry := map[string]interface{}{ </s> add //noinspection GoUnusedParameter </s> remove jsonentry["status"] = status.String() </s> add jsonEntry["status"] = status.String() </s> add // override bind host/port from the console </s> add //noinspection GoUnusedParameter
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
coredns_plugin/querylog.go
keep replace keep keep replace keep keep
<mask> status, _ := response.Typify(a, time.Now().UTC()) <mask> jsonentry["status"] = status.String() <mask> } <mask> if len(entry.Result.Rule) > 0 { <mask> jsonentry["rule"] = entry.Result.Rule <mask> } <mask> </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove // Count lines in the filter for _, line := range lines { line = strings.TrimSpace(line) if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { filter.Name = m[0][1] seenTitle = true } } else if len(line) != 0 { rulesCount++ } </s> add if filterName != "" { filter.Name = filterName </s> add // Saving it to the filters dir now err = filter.save() if err != nil { log.Printf("Failed to save the updated filter %d: %s", filter.ID, err) continue } </s> remove lines := strings.Split(string(body), "\n") rulesCount := 0 seenTitle := false </s> add rulesCount, filterName := parseFilterContents(body) </s> remove log.Printf("Filter %d length is %d", filter.ID, len(filterFile)) filter.contents = filterFile </s> add log.Printf("Filter %d length is %d", filter.ID, len(filterFileContents)) filter.contents = filterFileContents // Now extract the rules count rulesCount, _ := parseFilterContents(filter.contents) filter.RulesCount = rulesCount </s> remove data = append(data, jsonentry) </s> add data = append(data, jsonEntry)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
coredns_plugin/querylog.go
keep keep replace keep keep replace keep keep keep
<mask> answers = append(answers, answer) <mask> } <mask> jsonentry["answer"] = answers <mask> } <mask> <mask> data = append(data, jsonentry) <mask> } <mask> <mask> jsonVal, err := json.Marshal(data) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> add //noinspection GoUnusedParameter </s> add //noinspection GoUnusedParameter </s> remove jsonentry["rule"] = entry.Result.Rule </s> add jsonEntry["rule"] = entry.Result.Rule jsonEntry["filterId"] = entry.Result.FilterID </s> add //noinspection GoUnusedParameter
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
coredns_plugin/querylog.go
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> } <mask> <mask> jsonVal, err := json.Marshal(data) <mask> if err != nil { <mask> errortext := fmt.Sprintf("Couldn't marshal data into json: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusInternalServerError) <mask> return <mask> } <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> _, err = w.Write(jsonVal) </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove data = append(data, jsonentry) </s> add data = append(data, jsonEntry) </s> remove errortext := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Unable to write response json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't remove the filter file: %s", err) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't remove the filter file: %s", err) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove // TODO: Start using filter ID </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
coredns_plugin/querylog.go
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> _, err = w.Write(jsonVal) <mask> if err != nil { <mask> errortext := fmt.Sprintf("Unable to write response json: %s", err) <mask> log.Println(errortext) <mask> http.Error(w, errortext, http.StatusInternalServerError) <mask> } <mask> } <mask> <mask> func trace(format string, args ...interface{}) { <mask> pc := make([]uintptr, 10) // at least 1 entry needed </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove errortext := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't marshal data into json: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write body: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove errortext := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errortext) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't write config file: %s", err) log.Println(errorText) http.Error(w, errorText, http.StatusInternalServerError) </s> remove // TODO: Start using filter ID </s> add </s> add //noinspection GoUnusedParameter </s> remove errortext := fmt.Sprintf("Couldn't remove the filter file: %s", err) http.Error(w, errortext, http.StatusInternalServerError) </s> add errorText := fmt.Sprintf("Couldn't remove the filter file: %s", err) http.Error(w, errorText, http.StatusInternalServerError)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
coredns_plugin/querylog.go
keep add keep keep keep keep keep
<mask> res.Reason = FilteredBlackList <mask> res.IsFiltered = true <mask> if rule.isWhitelist { <mask> res.Reason = NotFilteredWhiteList <mask> res.IsFiltered = false <mask> } <mask> res.Rule = rule.text </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> add //noinspection GoUnusedParameter </s> remove // Count lines in the filter for _, line := range lines { line = strings.TrimSpace(line) if len(line) > 0 && line[0] == '!' { if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle { filter.Name = m[0][1] seenTitle = true } } else if len(line) != 0 { rulesCount++ } </s> add if filterName != "" { filter.Name = filterName </s> remove jsonentry["status"] = status.String() </s> add jsonEntry["status"] = status.String() </s> remove jsonentry["rule"] = entry.Result.Rule </s> add jsonEntry["rule"] = entry.Result.Rule jsonEntry["filterId"] = entry.Result.FilterID </s> add // override bind host/port from the console </s> add //noinspection GoUnusedParameter
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
dnsfilter/dnsfilter.go
keep keep keep keep replace keep keep keep keep keep
<mask> value: 94.100.180.201 <mask> - ttl: 55 <mask> type: A <mask> value: 217.69.139.200 <mask> elapsed_ms: '65.469556' <mask> question: <mask> class: IN <mask> host: mail.ru <mask> type: A <mask> reason: DNSFILTER_NOTFILTERED_NOTFOUND </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove elapsed_ms: '132.110929' </s> add elapsedMs: '132.110929' </s> remove - elapsed_ms: '0.15716999999999998' </s> add - elapsedMs: '0.15716999999999998' </s> add filterId: 1 </s> remove urls: - 'https://filters.adtidy.org/windows/filters/1.txt' - 'https://filters.adtidy.org/windows/filters/2.txt' </s> add - filters: enabled: true id: 1 lastUpdated: "2018-10-30T12:18:57.223101822+03:00" name: "AdGuard Simplified Domain Names filter" rulesCount: 24896 url: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt" </s> remove filter.Enabled = true </s> add </s> remove var filterTitle = regexp.MustCompile(`^! Title: +(.*)$`) </s> add var filterTitleRegexp = regexp.MustCompile(`^! Title: +(.*)$`)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
openapi.yaml
keep keep keep keep replace keep keep keep keep keep
<mask> type: A <mask> reason: DNSFILTER_NOTFILTERED_NOTFOUND <mask> status: NOERROR <mask> time: '2018-07-16T22:24:02+03:00' <mask> - elapsed_ms: '0.15716999999999998' <mask> question: <mask> class: IN <mask> host: doubleclick.net <mask> type: A <mask> reason: DNSFILTER_FILTERED_BLACKLIST </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove elapsed_ms: '65.469556' </s> add elapsedMs: '65.469556' </s> remove elapsed_ms: '132.110929' </s> add elapsedMs: '132.110929' </s> add filterId: 1 </s> remove urls: - 'https://filters.adtidy.org/windows/filters/1.txt' - 'https://filters.adtidy.org/windows/filters/2.txt' </s> add - filters: enabled: true id: 1 lastUpdated: "2018-10-30T12:18:57.223101822+03:00" name: "AdGuard Simplified Domain Names filter" rulesCount: 24896 url: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt" </s> remove filter.Enabled = true </s> add </s> remove var filterTitle = regexp.MustCompile(`^! Title: +(.*)$`) </s> add var filterTitleRegexp = regexp.MustCompile(`^! Title: +(.*)$`)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
openapi.yaml
keep keep keep keep replace keep keep keep keep keep
<mask> - answer: <mask> - ttl: 299 <mask> type: A <mask> value: 176.103.133.78 <mask> elapsed_ms: '132.110929' <mask> question: <mask> class: IN <mask> host: wmconvirus.narod.ru <mask> type: A <mask> reason: DNSFILTER_FILTERED_SAFEBROWSING </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove elapsed_ms: '65.469556' </s> add elapsedMs: '65.469556' </s> remove - elapsed_ms: '0.15716999999999998' </s> add - elapsedMs: '0.15716999999999998' </s> add filterId: 1 </s> remove urls: - 'https://filters.adtidy.org/windows/filters/1.txt' - 'https://filters.adtidy.org/windows/filters/2.txt' </s> add - filters: enabled: true id: 1 lastUpdated: "2018-10-30T12:18:57.223101822+03:00" name: "AdGuard Simplified Domain Names filter" rulesCount: 24896 url: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt" </s> remove filter.Enabled = true </s> add </s> remove var filterTitle = regexp.MustCompile(`^! Title: +(.*)$`) </s> add var filterTitleRegexp = regexp.MustCompile(`^! Title: +(.*)$`)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
openapi.yaml
keep keep keep add keep keep keep keep keep keep
<mask> host: wmconvirus.narod.ru <mask> type: A <mask> reason: DNSFILTER_FILTERED_SAFEBROWSING <mask> rule: adguard-malware-shavar <mask> status: NOERROR <mask> time: '2018-07-16T22:24:02+03:00' <mask> /querylog_enable: <mask> post: <mask> tags: <mask> - global </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> remove - elapsed_ms: '0.15716999999999998' </s> add - elapsedMs: '0.15716999999999998' </s> remove elapsed_ms: '132.110929' </s> add elapsedMs: '132.110929' </s> remove elapsed_ms: '65.469556' </s> add elapsedMs: '65.469556' </s> remove urls: - 'https://filters.adtidy.org/windows/filters/1.txt' - 'https://filters.adtidy.org/windows/filters/2.txt' </s> add - filters: enabled: true id: 1 lastUpdated: "2018-10-30T12:18:57.223101822+03:00" name: "AdGuard Simplified Domain Names filter" rulesCount: 24896 url: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt" </s> remove filter.Enabled = true </s> add </s> remove var filterTitle = regexp.MustCompile(`^! Title: +(.*)$`) </s> add var filterTitleRegexp = regexp.MustCompile(`^! Title: +(.*)$`)
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
openapi.yaml
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> description: OK <mask> examples: <mask> application/json: <mask> enabled: false <mask> urls: <mask> - 'https://filters.adtidy.org/windows/filters/1.txt' <mask> - 'https://filters.adtidy.org/windows/filters/2.txt' <mask> rules: <mask> - '@@||yandex.ru^|' <mask> /filtering/set_rules: <mask> put: <mask> tags: </s> Added filterId to the querylog Updated the openapi.yaml accordingly Some minor refactoring/renaming Fix other review comments </s> add filterId: 1 </s> remove elapsed_ms: '132.110929' </s> add elapsedMs: '132.110929' </s> remove - elapsed_ms: '0.15716999999999998' </s> add - elapsedMs: '0.15716999999999998' </s> remove elapsed_ms: '65.469556' </s> add elapsedMs: '65.469556' </s> add //noinspection GoUnusedParameter </s> add res.FilterID = rule.listID
https://github.com/AdguardTeam/AdGuardHome/commit/591065aa3aeff1cdee5cba0abdc7af0ceb09f54e
openapi.yaml
keep keep add keep keep keep keep
<mask> <mask> import ( <mask> "encoding/hex" <mask> "net" <mask> "net/http" <mask> "path/filepath" <mask> "runtime" </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove "time" </s> add </s> remove staticIPStatus := "yes" </s> add </s> remove lj := staticLeaseJSON{} </s> add lj := Lease{} </s> remove othSrv["found"] = foundVal v6["other_server"] = othSrv result := map[string]interface{}{} result["v4"] = v4 result["v6"] = v6 </s> add </s> remove foundVal = "error" othSrv["error"] = err6.Error() </s> add result.V6.OtherServer.Found = "error" result.V6.OtherServer.Error = err6.Error() </s> remove foundVal = "yes" </s> add result.V6.OtherServer.Found = "yes"
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcpd.go
keep keep keep keep replace keep keep keep keep keep
<mask> "net" <mask> "net/http" <mask> "os" <mask> "strings" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/sysutil" <mask> "github.com/AdguardTeam/AdGuardHome/internal/util" <mask> "github.com/AdguardTeam/golibs/jsonutil" <mask> "github.com/AdguardTeam/golibs/log" </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> add "encoding/json" "fmt" </s> remove staticIPStatus := "yes" </s> add </s> remove lj := staticLeaseJSON{} </s> add lj := Lease{} </s> remove othSrv["found"] = foundVal v6["other_server"] = othSrv result := map[string]interface{}{} result["v4"] = v4 result["v6"] = v6 </s> add </s> remove foundVal = "error" othSrv["error"] = err6.Error() </s> add result.V6.OtherServer.Found = "error" result.V6.OtherServer.Error = err6.Error() </s> remove foundVal = "yes" </s> add result.V6.OtherServer.Found = "yes"
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> log.Info("DHCP: %s %s: %s", r.Method, r.URL, text) <mask> http.Error(w, text, code) <mask> } <mask> <mask> // []Lease -> JSON <mask> func convertLeases(inputLeases []Lease, includeExpires bool) []map[string]string { <mask> leases := []map[string]string{} <mask> for _, l := range inputLeases { <mask> lease := map[string]string{ <mask> "mac": l.HWAddr.String(), <mask> "ip": l.IP.String(), <mask> "hostname": l.Hostname, <mask> } <mask> <mask> if includeExpires { <mask> lease["expires"] = l.Expiry.Format(time.RFC3339) <mask> } <mask> <mask> leases = append(leases, lease) <mask> } <mask> return leases <mask> } <mask> <mask> type v4ServerConfJSON struct { <mask> GatewayIP net.IP `json:"gateway_ip"` <mask> SubnetMask net.IP `json:"subnet_mask"` <mask> RangeStart net.IP `json:"range_start"` <mask> RangeEnd net.IP `json:"range_end"` </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove GatewayIP net.IP `yaml:"gateway_ip"` SubnetMask net.IP `yaml:"subnet_mask"` </s> add GatewayIP net.IP `yaml:"gateway_ip" json:"gateway_ip"` SubnetMask net.IP `yaml:"subnet_mask" json:"subnet_mask"` </s> remove Enabled bool `yaml:"-"` InterfaceName string `yaml:"-"` </s> add Enabled bool `yaml:"-" json:"-"` InterfaceName string `yaml:"-" json:"-"` </s> remove func v4ServerConfToJSON(c V4ServerConf) v4ServerConfJSON { return v4ServerConfJSON{ GatewayIP: c.GatewayIP, SubnetMask: c.SubnetMask, RangeStart: c.RangeStart, RangeEnd: c.RangeEnd, LeaseDuration: c.LeaseDuration, } } </s> add </s> remove type staticLeaseJSON struct { HWAddr string `json:"mac"` IP net.IP `json:"ip"` Hostname string `json:"hostname"` } </s> add </s> remove var result []Lease </s> add // The function shouldn't return nil value because zero-length slice // behaves differently in cases like marshalling. Our front-end also // requires non-nil value in the response. result := []Lease{} </s> remove func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { leases := convertLeases(s.Leases(LeasesDynamic), true) staticLeases := convertLeases(s.Leases(LeasesStatic), false) </s> add // dhcpStatusResponse is the response for /control/dhcp/status endpoint. type dhcpStatusResponse struct { Enabled bool `json:"enabled"` IfaceName string `json:"interface_name"` V4 V4ServerConf `json:"v4"` V6 V6ServerConf `json:"v6"` Leases []Lease `json:"leases"` StaticLeases []Lease `json:"static_leases"` }
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep replace replace replace replace replace replace replace replace replace replace keep keep replace replace replace replace
<mask> <mask> func v4ServerConfToJSON(c V4ServerConf) v4ServerConfJSON { <mask> return v4ServerConfJSON{ <mask> GatewayIP: c.GatewayIP, <mask> SubnetMask: c.SubnetMask, <mask> RangeStart: c.RangeStart, <mask> RangeEnd: c.RangeEnd, <mask> LeaseDuration: c.LeaseDuration, <mask> } <mask> } <mask> <mask> func v4JSONToServerConf(j v4ServerConfJSON) V4ServerConf { <mask> return V4ServerConf{ <mask> GatewayIP: j.GatewayIP.To4(), <mask> SubnetMask: j.SubnetMask.To4(), <mask> RangeStart: j.RangeStart.To4(), <mask> RangeEnd: j.RangeEnd.To4(), </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove func v6ServerConfToJSON(c V6ServerConf) v6ServerConfJSON { return v6ServerConfJSON{ RangeStart: c.RangeStart, LeaseDuration: c.LeaseDuration, } } </s> add </s> remove func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { leases := convertLeases(s.Leases(LeasesDynamic), true) staticLeases := convertLeases(s.Leases(LeasesStatic), false) </s> add // dhcpStatusResponse is the response for /control/dhcp/status endpoint. type dhcpStatusResponse struct { Enabled bool `json:"enabled"` IfaceName string `json:"interface_name"` V4 V4ServerConf `json:"v4"` V6 V6ServerConf `json:"v6"` Leases []Lease `json:"leases"` StaticLeases []Lease `json:"static_leases"` } </s> remove // []Lease -> JSON func convertLeases(inputLeases []Lease, includeExpires bool) []map[string]string { leases := []map[string]string{} for _, l := range inputLeases { lease := map[string]string{ "mac": l.HWAddr.String(), "ip": l.IP.String(), "hostname": l.Hostname, } if includeExpires { lease["expires"] = l.Expiry.Format(time.RFC3339) } leases = append(leases, lease) } return leases } </s> add </s> remove type staticLeaseJSON struct { HWAddr string `json:"mac"` IP net.IP `json:"ip"` Hostname string `json:"hostname"` } </s> add </s> remove lj := staticLeaseJSON{} </s> add lj := Lease{}
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace replace replace replace replace replace replace keep keep keep keep keep
<mask> RangeStart string `json:"range_start"` <mask> LeaseDuration uint32 `json:"lease_duration"` <mask> } <mask> <mask> func v6ServerConfToJSON(c V6ServerConf) v6ServerConfJSON { <mask> return v6ServerConfJSON{ <mask> RangeStart: c.RangeStart, <mask> LeaseDuration: c.LeaseDuration, <mask> } <mask> } <mask> <mask> func v6JSONToServerConf(j v6ServerConfJSON) V6ServerConf { <mask> return V6ServerConf{ <mask> RangeStart: j.RangeStart, <mask> LeaseDuration: j.LeaseDuration, <mask> } </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove func v4ServerConfToJSON(c V4ServerConf) v4ServerConfJSON { return v4ServerConfJSON{ GatewayIP: c.GatewayIP, SubnetMask: c.SubnetMask, RangeStart: c.RangeStart, RangeEnd: c.RangeEnd, LeaseDuration: c.LeaseDuration, } } </s> add </s> remove GatewayIP: j.GatewayIP.To4(), SubnetMask: j.SubnetMask.To4(), RangeStart: j.RangeStart.To4(), RangeEnd: j.RangeEnd.To4(), </s> add GatewayIP: j.GatewayIP, SubnetMask: j.SubnetMask, RangeStart: j.RangeStart, RangeEnd: j.RangeEnd, </s> remove func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { leases := convertLeases(s.Leases(LeasesDynamic), true) staticLeases := convertLeases(s.Leases(LeasesStatic), false) </s> add // dhcpStatusResponse is the response for /control/dhcp/status endpoint. type dhcpStatusResponse struct { Enabled bool `json:"enabled"` IfaceName string `json:"interface_name"` V4 V4ServerConf `json:"v4"` V6 V6ServerConf `json:"v6"` Leases []Lease `json:"leases"` StaticLeases []Lease `json:"static_leases"` } </s> remove type staticLeaseJSON struct { HWAddr string `json:"mac"` IP net.IP `json:"ip"` Hostname string `json:"hostname"` } </s> add </s> remove // []Lease -> JSON func convertLeases(inputLeases []Lease, includeExpires bool) []map[string]string { leases := []map[string]string{} for _, l := range inputLeases { lease := map[string]string{ "mac": l.HWAddr.String(), "ip": l.IP.String(), "hostname": l.Hostname, } if includeExpires { lease["expires"] = l.Expiry.Format(time.RFC3339) } leases = append(leases, lease) } return leases } </s> add </s> remove Enabled bool `yaml:"-"` InterfaceName string `yaml:"-"` </s> add Enabled bool `yaml:"-" json:"-"` InterfaceName string `yaml:"-" json:"-"`
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep replace replace replace keep replace replace keep keep keep
<mask> } <mask> <mask> func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { <mask> leases := convertLeases(s.Leases(LeasesDynamic), true) <mask> staticLeases := convertLeases(s.Leases(LeasesStatic), false) <mask> <mask> v4conf := V4ServerConf{} <mask> s.srv4.WriteDiskConfig4(&v4conf) <mask> <mask> v6conf := V6ServerConf{} <mask> s.srv6.WriteDiskConfig6(&v6conf) </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove v6conf := V6ServerConf{} s.srv6.WriteDiskConfig6(&v6conf) </s> add s.srv4.WriteDiskConfig4(&status.V4) s.srv6.WriteDiskConfig6(&status.V6) </s> remove lj := staticLeaseJSON{} </s> add lj := Lease{} </s> remove lj := staticLeaseJSON{} </s> add lj := Lease{} </s> remove response := map[string]interface{}{} </s> add response := map[string]netInterfaceJSON{} </s> remove status := map[string]interface{}{ "enabled": s.conf.Enabled, "interface_name": s.conf.InterfaceName, "v4": v4ServerConfToJSON(v4conf), "v6": v6ServerConfToJSON(v6conf), "leases": leases, "static_leases": staticLeases, } </s> add status.Leases = s.Leases(LeasesDynamic) status.StaticLeases = s.Leases(LeasesStatic)
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace replace keep keep keep keep keep
<mask> <mask> v4conf := V4ServerConf{} <mask> s.srv4.WriteDiskConfig4(&v4conf) <mask> <mask> v6conf := V6ServerConf{} <mask> s.srv6.WriteDiskConfig6(&v6conf) <mask> <mask> status := map[string]interface{}{ <mask> "enabled": s.conf.Enabled, <mask> "interface_name": s.conf.InterfaceName, <mask> "v4": v4ServerConfToJSON(v4conf), </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove status := map[string]interface{}{ "enabled": s.conf.Enabled, "interface_name": s.conf.InterfaceName, "v4": v4ServerConfToJSON(v4conf), "v6": v6ServerConfToJSON(v6conf), "leases": leases, "static_leases": staticLeases, } </s> add status.Leases = s.Leases(LeasesDynamic) status.StaticLeases = s.Leases(LeasesStatic) </s> remove v4conf := V4ServerConf{} s.srv4.WriteDiskConfig4(&v4conf) </s> add func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { status := &dhcpStatusResponse{ Enabled: s.conf.Enabled, IfaceName: s.conf.InterfaceName, V4: V4ServerConf{}, V6: V6ServerConf{}, } </s> remove func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { leases := convertLeases(s.Leases(LeasesDynamic), true) staticLeases := convertLeases(s.Leases(LeasesStatic), false) </s> add // dhcpStatusResponse is the response for /control/dhcp/status endpoint. type dhcpStatusResponse struct { Enabled bool `json:"enabled"` IfaceName string `json:"interface_name"` V4 V4ServerConf `json:"v4"` V6 V6ServerConf `json:"v6"` Leases []Lease `json:"leases"` StaticLeases []Lease `json:"static_leases"` } </s> remove data := map[string]interface{}{ "enabled": d.Config.SafeBrowsingEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) } </s> add </s> remove data := map[string]interface{}{ "enabled": d.Config.SafeSearchEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) return } </s> add </s> remove data := map[string]interface{}{ "enabled": d.Config.ParentalEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) return } </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> <mask> v6conf := V6ServerConf{} <mask> s.srv6.WriteDiskConfig6(&v6conf) <mask> <mask> status := map[string]interface{}{ <mask> "enabled": s.conf.Enabled, <mask> "interface_name": s.conf.InterfaceName, <mask> "v4": v4ServerConfToJSON(v4conf), <mask> "v6": v6ServerConfToJSON(v6conf), <mask> "leases": leases, <mask> "static_leases": staticLeases, <mask> } <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> err := json.NewEncoder(w).Encode(status) <mask> if err != nil { <mask> httpError(r, w, http.StatusInternalServerError, "Unable to marshal DHCP status json: %s", err) </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove v6conf := V6ServerConf{} s.srv6.WriteDiskConfig6(&v6conf) </s> add s.srv4.WriteDiskConfig4(&status.V4) s.srv6.WriteDiskConfig6(&status.V6) </s> remove data := map[string]interface{}{ "enabled": d.Config.SafeBrowsingEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) } </s> add </s> remove data := map[string]interface{}{ "enabled": d.Config.SafeSearchEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) return } </s> add </s> remove data := map[string]interface{}{ "enabled": d.Config.ParentalEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) return } </s> add </s> remove _, err = w.Write(jsonVal) </s> add err := json.NewEncoder(w).Encode(&struct { Enabled bool `json:"enabled"` }{ Enabled: d.Config.SafeBrowsingEnabled, }) </s> remove v4conf := V4ServerConf{} s.srv4.WriteDiskConfig4(&v4conf) </s> add func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { status := &dhcpStatusResponse{ Enabled: s.conf.Enabled, IfaceName: s.conf.InterfaceName, V4: V4ServerConf{}, V6: V6ServerConf{}, }
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
<mask> return <mask> } <mask> } <mask> <mask> type staticLeaseJSON struct { <mask> HWAddr string `json:"mac"` <mask> IP net.IP `json:"ip"` <mask> Hostname string `json:"hostname"` <mask> } <mask> <mask> type dhcpServerConfigJSON struct { <mask> Enabled bool `json:"enabled"` <mask> InterfaceName string `json:"interface_name"` <mask> V4 v4ServerConfJSON `json:"v4"` <mask> V6 v6ServerConfJSON `json:"v6"` </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { leases := convertLeases(s.Leases(LeasesDynamic), true) staticLeases := convertLeases(s.Leases(LeasesStatic), false) </s> add // dhcpStatusResponse is the response for /control/dhcp/status endpoint. type dhcpStatusResponse struct { Enabled bool `json:"enabled"` IfaceName string `json:"interface_name"` V4 V4ServerConf `json:"v4"` V6 V6ServerConf `json:"v6"` Leases []Lease `json:"leases"` StaticLeases []Lease `json:"static_leases"` } </s> remove Enabled bool `yaml:"-"` InterfaceName string `yaml:"-"` </s> add Enabled bool `yaml:"-" json:"-"` InterfaceName string `yaml:"-" json:"-"` </s> remove Enabled bool `yaml:"-"` InterfaceName string `yaml:"-"` </s> add Enabled bool `yaml:"-" json:"-"` InterfaceName string `yaml:"-" json:"-"` </s> remove GatewayIP net.IP `yaml:"gateway_ip"` SubnetMask net.IP `yaml:"subnet_mask"` </s> add GatewayIP net.IP `yaml:"gateway_ip" json:"gateway_ip"` SubnetMask net.IP `yaml:"subnet_mask" json:"subnet_mask"` </s> remove GatewayIP: j.GatewayIP.To4(), SubnetMask: j.SubnetMask.To4(), RangeStart: j.RangeStart.To4(), RangeEnd: j.RangeEnd.To4(), </s> add GatewayIP: j.GatewayIP, SubnetMask: j.SubnetMask, RangeStart: j.RangeStart, RangeEnd: j.RangeEnd, </s> remove // []Lease -> JSON func convertLeases(inputLeases []Lease, includeExpires bool) []map[string]string { leases := []map[string]string{} for _, l := range inputLeases { lease := map[string]string{ "mac": l.HWAddr.String(), "ip": l.IP.String(), "hostname": l.Hostname, } if includeExpires { lease["expires"] = l.Expiry.Format(time.RFC3339) } leases = append(leases, lease) } return leases } </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace keep keep keep keep keep
<mask> Flags string `json:"flags"` <mask> } <mask> <mask> func (s *Server) handleDHCPInterfaces(w http.ResponseWriter, r *http.Request) { <mask> response := map[string]interface{}{} <mask> <mask> ifaces, err := util.GetValidNetInterfaces() <mask> if err != nil { <mask> httpError(r, w, http.StatusInternalServerError, "Couldn't get interfaces: %s", err) <mask> return </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove lj := staticLeaseJSON{} </s> add lj := Lease{} </s> remove lj := staticLeaseJSON{} </s> add lj := Lease{} </s> remove data := map[string]interface{}{ "enabled": d.Config.SafeBrowsingEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) } </s> add </s> remove data := map[string]interface{}{ "enabled": d.Config.SafeSearchEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) return } </s> add </s> remove data := map[string]interface{}{ "enabled": d.Config.ParentalEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) return } </s> add </s> remove v4conf := V4ServerConf{} s.srv4.WriteDiskConfig4(&v4conf) </s> add func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { status := &dhcpStatusResponse{ Enabled: s.conf.Enabled, IfaceName: s.conf.InterfaceName, V4: V4ServerConf{}, V6: V6ServerConf{}, }
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep add keep keep keep keep keep keep
<mask> return <mask> } <mask> <mask> found4, err4 := CheckIfOtherDHCPServersPresentV4(interfaceName) <mask> <mask> isStaticIP, err := sysutil.IfaceHasStaticIP(interfaceName) <mask> if err != nil { <mask> result.V4.StaticIP.Static = "error" <mask> result.V4.StaticIP.Error = err.Error() </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove staticIP := map[string]interface{}{} </s> add </s> remove staticIPStatus := "yes" </s> add </s> remove staticIPStatus = "error" staticIP["error"] = err.Error() </s> add result.V4.StaticIP.Static = "error" result.V4.StaticIP.Error = err.Error() </s> remove staticIPStatus = "no" staticIP["ip"] = util.GetSubnet(interfaceName) </s> add result.V4.StaticIP.Static = "no" result.V4.StaticIP.IP = util.GetSubnet(interfaceName) </s> remove v4 := map[string]interface{}{} othSrv := map[string]interface{}{} foundVal := "no" </s> add </s> remove foundVal = "yes" </s> add result.V4.OtherServer.Found = "yes"
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep replace keep replace keep keep keep keep
<mask> <mask> staticIP := map[string]interface{}{} <mask> isStaticIP, err := sysutil.IfaceHasStaticIP(interfaceName) <mask> staticIPStatus := "yes" <mask> if err != nil { <mask> staticIPStatus = "error" <mask> staticIP["error"] = err.Error() <mask> } else if !isStaticIP { </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove staticIPStatus = "error" staticIP["error"] = err.Error() </s> add result.V4.StaticIP.Static = "error" result.V4.StaticIP.Error = err.Error() </s> remove staticIPStatus = "no" staticIP["ip"] = util.GetSubnet(interfaceName) </s> add result.V4.StaticIP.Static = "no" result.V4.StaticIP.IP = util.GetSubnet(interfaceName) </s> remove staticIP["static"] = staticIPStatus </s> add </s> remove v4 := map[string]interface{}{} othSrv := map[string]interface{}{} foundVal := "no" </s> add </s> remove v6 := map[string]interface{}{} othSrv = map[string]interface{}{} foundVal = "no" </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep replace replace keep replace replace keep keep keep
<mask> if err != nil { <mask> staticIPStatus = "error" <mask> staticIP["error"] = err.Error() <mask> } else if !isStaticIP { <mask> staticIPStatus = "no" <mask> staticIP["ip"] = util.GetSubnet(interfaceName) <mask> } <mask> staticIP["static"] = staticIPStatus <mask> </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove staticIP["static"] = staticIPStatus </s> add </s> remove staticIPStatus := "yes" </s> add </s> remove v4 := map[string]interface{}{} othSrv := map[string]interface{}{} foundVal := "no" </s> add </s> remove staticIP := map[string]interface{}{} </s> add </s> remove foundVal = "error" othSrv["error"] = err6.Error() </s> add result.V6.OtherServer.Found = "error" result.V6.OtherServer.Error = err6.Error()
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep replace keep replace replace replace keep keep keep
<mask> staticIP["ip"] = util.GetSubnet(interfaceName) <mask> } <mask> staticIP["static"] = staticIPStatus <mask> <mask> v4 := map[string]interface{}{} <mask> othSrv := map[string]interface{}{} <mask> foundVal := "no" <mask> if found4 { <mask> foundVal = "yes" <mask> } else if err4 != nil { </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove foundVal = "yes" </s> add result.V4.OtherServer.Found = "yes" </s> remove staticIPStatus = "no" staticIP["ip"] = util.GetSubnet(interfaceName) </s> add result.V4.StaticIP.Static = "no" result.V4.StaticIP.IP = util.GetSubnet(interfaceName) </s> remove staticIPStatus = "error" staticIP["error"] = err.Error() </s> add result.V4.StaticIP.Static = "error" result.V4.StaticIP.Error = err.Error() </s> remove foundVal = "yes" </s> add result.V6.OtherServer.Found = "yes" </s> remove foundVal = "error" othSrv["error"] = err4.Error() </s> add result.V4.OtherServer.Found = "error" result.V4.OtherServer.Error = err4.Error()
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace keep replace replace keep keep keep keep
<mask> v4 := map[string]interface{}{} <mask> othSrv := map[string]interface{}{} <mask> foundVal := "no" <mask> if found4 { <mask> foundVal = "yes" <mask> } else if err4 != nil { <mask> foundVal = "error" <mask> othSrv["error"] = err4.Error() <mask> } <mask> othSrv["found"] = foundVal <mask> v4["other_server"] = othSrv <mask> v4["static_ip"] = staticIP </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove othSrv["found"] = foundVal v4["other_server"] = othSrv v4["static_ip"] = staticIP </s> add </s> remove v4 := map[string]interface{}{} othSrv := map[string]interface{}{} foundVal := "no" </s> add </s> remove v6 := map[string]interface{}{} othSrv = map[string]interface{}{} foundVal = "no" </s> add </s> remove foundVal = "yes" </s> add result.V6.OtherServer.Found = "yes" </s> remove foundVal = "error" othSrv["error"] = err6.Error() </s> add result.V6.OtherServer.Found = "error" result.V6.OtherServer.Error = err6.Error()
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep replace replace replace keep keep keep replace replace replace keep keep
<mask> othSrv["error"] = err4.Error() <mask> } <mask> othSrv["found"] = foundVal <mask> v4["other_server"] = othSrv <mask> v4["static_ip"] = staticIP <mask> <mask> found6, err6 := CheckIfOtherDHCPServersPresentV6(interfaceName) <mask> <mask> v6 := map[string]interface{}{} <mask> othSrv = map[string]interface{}{} <mask> foundVal = "no" <mask> if found6 { <mask> foundVal = "yes" </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove foundVal = "yes" </s> add result.V6.OtherServer.Found = "yes" </s> remove foundVal = "error" othSrv["error"] = err4.Error() </s> add result.V4.OtherServer.Found = "error" result.V4.OtherServer.Error = err4.Error() </s> remove foundVal = "yes" </s> add result.V4.OtherServer.Found = "yes" </s> remove foundVal = "error" othSrv["error"] = err6.Error() </s> add result.V6.OtherServer.Found = "error" result.V6.OtherServer.Error = err6.Error() </s> remove v4 := map[string]interface{}{} othSrv := map[string]interface{}{} foundVal := "no" </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace keep replace replace keep keep
<mask> v6 := map[string]interface{}{} <mask> othSrv = map[string]interface{}{} <mask> foundVal = "no" <mask> if found6 { <mask> foundVal = "yes" <mask> } else if err6 != nil { <mask> foundVal = "error" <mask> othSrv["error"] = err6.Error() <mask> } <mask> othSrv["found"] = foundVal </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove v6 := map[string]interface{}{} othSrv = map[string]interface{}{} foundVal = "no" </s> add </s> remove foundVal = "yes" </s> add result.V4.OtherServer.Found = "yes" </s> remove othSrv["found"] = foundVal v4["other_server"] = othSrv v4["static_ip"] = staticIP </s> add </s> remove v4 := map[string]interface{}{} othSrv := map[string]interface{}{} foundVal := "no" </s> add </s> remove foundVal = "error" othSrv["error"] = err4.Error() </s> add result.V4.OtherServer.Found = "error" result.V4.OtherServer.Error = err4.Error()
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
<mask> } else if err6 != nil { <mask> foundVal = "error" <mask> othSrv["error"] = err6.Error() <mask> } <mask> othSrv["found"] = foundVal <mask> v6["other_server"] = othSrv <mask> <mask> result := map[string]interface{}{} <mask> result["v4"] = v4 <mask> result["v6"] = v6 <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> err = json.NewEncoder(w).Encode(result) <mask> if err != nil { <mask> httpError(r, w, http.StatusInternalServerError, "Failed to marshal DHCP found json: %s", err) </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove foundVal = "error" othSrv["error"] = err6.Error() </s> add result.V6.OtherServer.Found = "error" result.V6.OtherServer.Error = err6.Error() </s> remove foundVal = "yes" </s> add result.V6.OtherServer.Found = "yes" </s> remove v6 := map[string]interface{}{} othSrv = map[string]interface{}{} foundVal = "no" </s> add </s> remove othSrv["found"] = foundVal v4["other_server"] = othSrv v4["static_ip"] = staticIP </s> add </s> remove foundVal = "yes" </s> add result.V4.OtherServer.Found = "yes" </s> remove v4 := map[string]interface{}{} othSrv := map[string]interface{}{} foundVal := "no" </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> } <mask> <mask> func (s *Server) handleDHCPAddStaticLease(w http.ResponseWriter, r *http.Request) { <mask> lj := staticLeaseJSON{} <mask> err := json.NewDecoder(r.Body).Decode(&lj) <mask> if err != nil { <mask> httpError(r, w, http.StatusBadRequest, "json.Decode: %s", err) <mask> <mask> return </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove lj := staticLeaseJSON{} </s> add lj := Lease{} </s> remove response := map[string]interface{}{} </s> add response := map[string]netInterfaceJSON{} </s> remove v4conf := V4ServerConf{} s.srv4.WriteDiskConfig4(&v4conf) </s> add func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { status := &dhcpStatusResponse{ Enabled: s.conf.Enabled, IfaceName: s.conf.InterfaceName, V4: V4ServerConf{}, V6: V6ServerConf{}, } </s> remove data := map[string]interface{}{ "enabled": d.Config.SafeBrowsingEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) } </s> add </s> remove data := map[string]interface{}{ "enabled": d.Config.SafeSearchEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) return } </s> add </s> remove data := map[string]interface{}{ "enabled": d.Config.ParentalEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) return } </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep replace replace replace replace replace keep replace
<mask> <mask> ip4 := lj.IP.To4() <mask> <mask> mac, err := net.ParseMAC(lj.HWAddr) <mask> lease := Lease{ <mask> HWAddr: mac, <mask> } <mask> <mask> if ip4 == nil { <mask> lease.IP = lj.IP.To16() </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove mac, err := net.ParseMAC(lj.HWAddr) lease := Lease{ HWAddr: mac, } </s> add </s> remove lease.IP = lj.IP.To16() if err != nil { httpError(r, w, http.StatusBadRequest, "invalid MAC") return } </s> add lj.IP = lj.IP.To16() </s> remove if err != nil { httpError(r, w, http.StatusBadRequest, "invalid MAC") return } err = s.srv6.AddStaticLease(lease) </s> add err = s.srv6.AddStaticLease(lj) </s> remove lease.IP = ip4 lease.Hostname = lj.Hostname err = s.srv4.RemoveStaticLease(lease) </s> add lj.IP = ip4 err = s.srv4.RemoveStaticLease(lj) </s> remove lease.IP = ip4 lease.Hostname = lj.Hostname err = s.srv4.AddStaticLease(lease) </s> add lj.IP = ip4 err = s.srv4.AddStaticLease(lj)
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace replace replace replace replace replace replace keep keep keep keep keep
<mask> <mask> if ip4 == nil { <mask> lease.IP = lj.IP.To16() <mask> <mask> if err != nil { <mask> httpError(r, w, http.StatusBadRequest, "invalid MAC") <mask> <mask> return <mask> } <mask> <mask> err = s.srv6.AddStaticLease(lease) <mask> if err != nil { <mask> httpError(r, w, http.StatusBadRequest, "%s", err) <mask> } <mask> <mask> return </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove lease.IP = lj.IP.To16() if err != nil { httpError(r, w, http.StatusBadRequest, "invalid MAC") return } </s> add lj.IP = lj.IP.To16() </s> remove lease.IP = lj.IP.To16() </s> add lj.IP = lj.IP.To16() </s> remove mac, err := net.ParseMAC(lj.HWAddr) lease := Lease{ HWAddr: mac, } </s> add </s> remove mac, err := net.ParseMAC(lj.HWAddr) lease := Lease{ HWAddr: mac, } </s> add </s> remove lease.IP = ip4 lease.Hostname = lj.Hostname err = s.srv4.RemoveStaticLease(lease) </s> add lj.IP = ip4 err = s.srv4.RemoveStaticLease(lj) </s> remove lease.IP = ip4 lease.Hostname = lj.Hostname err = s.srv4.AddStaticLease(lease) </s> add lj.IP = ip4 err = s.srv4.AddStaticLease(lj)
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> <mask> return <mask> } <mask> <mask> lease.IP = ip4 <mask> lease.Hostname = lj.Hostname <mask> err = s.srv4.AddStaticLease(lease) <mask> if err != nil { <mask> httpError(r, w, http.StatusBadRequest, "%s", err) <mask> <mask> return <mask> } </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove lease.IP = ip4 lease.Hostname = lj.Hostname err = s.srv4.RemoveStaticLease(lease) </s> add lj.IP = ip4 err = s.srv4.RemoveStaticLease(lj) </s> remove if err != nil { httpError(r, w, http.StatusBadRequest, "invalid MAC") return } err = s.srv6.AddStaticLease(lease) </s> add err = s.srv6.AddStaticLease(lj) </s> remove lease.IP = lj.IP.To16() if err != nil { httpError(r, w, http.StatusBadRequest, "invalid MAC") return } </s> add lj.IP = lj.IP.To16() </s> remove err = s.srv6.RemoveStaticLease(lease) </s> add err = s.srv6.RemoveStaticLease(lj) </s> remove lease.IP = lj.IP.To16() </s> add lj.IP = lj.IP.To16() </s> remove mac, err := net.ParseMAC(lj.HWAddr) lease := Lease{ HWAddr: mac, } </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> } <mask> <mask> func (s *Server) handleDHCPRemoveStaticLease(w http.ResponseWriter, r *http.Request) { <mask> lj := staticLeaseJSON{} <mask> err := json.NewDecoder(r.Body).Decode(&lj) <mask> if err != nil { <mask> httpError(r, w, http.StatusBadRequest, "json.Decode: %s", err) <mask> <mask> return </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove lj := staticLeaseJSON{} </s> add lj := Lease{} </s> remove response := map[string]interface{}{} </s> add response := map[string]netInterfaceJSON{} </s> remove v4conf := V4ServerConf{} s.srv4.WriteDiskConfig4(&v4conf) </s> add func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { status := &dhcpStatusResponse{ Enabled: s.conf.Enabled, IfaceName: s.conf.InterfaceName, V4: V4ServerConf{}, V6: V6ServerConf{}, } </s> remove data := map[string]interface{}{ "enabled": d.Config.SafeBrowsingEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) } </s> add </s> remove data := map[string]interface{}{ "enabled": d.Config.SafeSearchEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) return } </s> add </s> remove data := map[string]interface{}{ "enabled": d.Config.ParentalEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) return } </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep replace replace replace replace replace keep replace replace replace replace replace replace replace keep keep keep
<mask> ip4 := lj.IP.To4() <mask> <mask> mac, err := net.ParseMAC(lj.HWAddr) <mask> lease := Lease{ <mask> HWAddr: mac, <mask> } <mask> <mask> if ip4 == nil { <mask> lease.IP = lj.IP.To16() <mask> <mask> if err != nil { <mask> httpError(r, w, http.StatusBadRequest, "invalid MAC") <mask> <mask> return <mask> } <mask> <mask> err = s.srv6.RemoveStaticLease(lease) <mask> if err != nil { </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> return <mask> } <mask> <mask> err = s.srv6.RemoveStaticLease(lease) <mask> if err != nil { <mask> httpError(r, w, http.StatusBadRequest, "%s", err) <mask> } <mask> <mask> return </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove lease.IP = lj.IP.To16() if err != nil { httpError(r, w, http.StatusBadRequest, "invalid MAC") return } </s> add lj.IP = lj.IP.To16() </s> remove if err != nil { httpError(r, w, http.StatusBadRequest, "invalid MAC") return } err = s.srv6.AddStaticLease(lease) </s> add err = s.srv6.AddStaticLease(lj) </s> remove lease.IP = ip4 lease.Hostname = lj.Hostname err = s.srv4.RemoveStaticLease(lease) </s> add lj.IP = ip4 err = s.srv4.RemoveStaticLease(lj) </s> remove lease.IP = ip4 lease.Hostname = lj.Hostname err = s.srv4.AddStaticLease(lease) </s> add lj.IP = ip4 err = s.srv4.AddStaticLease(lj) </s> remove lease.IP = lj.IP.To16() </s> add lj.IP = lj.IP.To16() </s> remove lj := staticLeaseJSON{} </s> add lj := Lease{}
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> <mask> return <mask> } <mask> <mask> lease.IP = ip4 <mask> lease.Hostname = lj.Hostname <mask> err = s.srv4.RemoveStaticLease(lease) <mask> if err != nil { <mask> httpError(r, w, http.StatusBadRequest, "%s", err) <mask> <mask> return <mask> } </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove lease.IP = ip4 lease.Hostname = lj.Hostname err = s.srv4.AddStaticLease(lease) </s> add lj.IP = ip4 err = s.srv4.AddStaticLease(lj) </s> remove if err != nil { httpError(r, w, http.StatusBadRequest, "invalid MAC") return } err = s.srv6.AddStaticLease(lease) </s> add err = s.srv6.AddStaticLease(lj) </s> remove lease.IP = lj.IP.To16() if err != nil { httpError(r, w, http.StatusBadRequest, "invalid MAC") return } </s> add lj.IP = lj.IP.To16() </s> remove err = s.srv6.RemoveStaticLease(lease) </s> add err = s.srv6.RemoveStaticLease(lj) </s> remove lease.IP = lj.IP.To16() </s> add lj.IP = lj.IP.To16() </s> remove mac, err := net.ParseMAC(lj.HWAddr) lease := Lease{ HWAddr: mac, } </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/dhcphttp.go
keep keep replace replace keep replace replace keep
<mask> // V4ServerConf - server configuration <mask> type V4ServerConf struct { <mask> Enabled bool `yaml:"-"` <mask> InterfaceName string `yaml:"-"` <mask> <mask> GatewayIP net.IP `yaml:"gateway_ip"` <mask> SubnetMask net.IP `yaml:"subnet_mask"` <mask> </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove Enabled bool `yaml:"-"` InterfaceName string `yaml:"-"` </s> add Enabled bool `yaml:"-" json:"-"` InterfaceName string `yaml:"-" json:"-"` </s> remove type staticLeaseJSON struct { HWAddr string `json:"mac"` IP net.IP `json:"ip"` Hostname string `json:"hostname"` } </s> add </s> remove // []Lease -> JSON func convertLeases(inputLeases []Lease, includeExpires bool) []map[string]string { leases := []map[string]string{} for _, l := range inputLeases { lease := map[string]string{ "mac": l.HWAddr.String(), "ip": l.IP.String(), "hostname": l.Hostname, } if includeExpires { lease["expires"] = l.Expiry.Format(time.RFC3339) } leases = append(leases, lease) } return leases } </s> add </s> remove func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { leases := convertLeases(s.Leases(LeasesDynamic), true) staticLeases := convertLeases(s.Leases(LeasesStatic), false) </s> add // dhcpStatusResponse is the response for /control/dhcp/status endpoint. type dhcpStatusResponse struct { Enabled bool `json:"enabled"` IfaceName string `json:"interface_name"` V4 V4ServerConf `json:"v4"` V6 V6ServerConf `json:"v6"` Leases []Lease `json:"leases"` StaticLeases []Lease `json:"static_leases"` } </s> remove RangeStart string `yaml:"range_start"` </s> add RangeStart string `yaml:"range_start" json:"range_start"`
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/server.go
keep keep keep replace replace keep replace keep
<mask> <mask> // The first & the last IP address for dynamic leases <mask> // Bytes [0..2] of the last allowed IP address must match the first IP <mask> RangeStart net.IP `yaml:"range_start"` <mask> RangeEnd net.IP `yaml:"range_end"` <mask> <mask> LeaseDuration uint32 `yaml:"lease_duration"` // in seconds <mask> </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove GatewayIP net.IP `yaml:"gateway_ip"` SubnetMask net.IP `yaml:"subnet_mask"` </s> add GatewayIP net.IP `yaml:"gateway_ip" json:"gateway_ip"` SubnetMask net.IP `yaml:"subnet_mask" json:"subnet_mask"` </s> remove LeaseDuration uint32 `yaml:"lease_duration"` // in seconds </s> add LeaseDuration uint32 `yaml:"lease_duration" json:"lease_duration"` // in seconds </s> remove RangeStart string `yaml:"range_start"` </s> add RangeStart string `yaml:"range_start" json:"range_start"` </s> remove Enabled bool `yaml:"-"` InterfaceName string `yaml:"-"` </s> add Enabled bool `yaml:"-" json:"-"` InterfaceName string `yaml:"-" json:"-"` </s> remove Enabled bool `yaml:"-"` InterfaceName string `yaml:"-"` </s> add Enabled bool `yaml:"-" json:"-"` InterfaceName string `yaml:"-" json:"-"`
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/server.go
keep keep keep keep replace keep keep keep keep keep
<mask> LeaseDuration uint32 `yaml:"lease_duration"` // in seconds <mask> <mask> // IP conflict detector: time (ms) to wait for ICMP reply <mask> // 0: disable <mask> ICMPTimeout uint32 `yaml:"icmp_timeout_msec"` <mask> <mask> // Custom Options. <mask> // <mask> // Option with arbitrary hexadecimal data: <mask> // DEC_CODE hex HEX_DATA </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove LeaseDuration uint32 `yaml:"lease_duration"` // in seconds </s> add LeaseDuration uint32 `yaml:"lease_duration" json:"lease_duration"` // in seconds </s> remove RangeStart net.IP `yaml:"range_start"` RangeEnd net.IP `yaml:"range_end"` </s> add RangeStart net.IP `yaml:"range_start" json:"range_start"` RangeEnd net.IP `yaml:"range_end" json:"range_end"` </s> remove LeaseDuration uint32 `yaml:"lease_duration"` // in seconds </s> add LeaseDuration uint32 `yaml:"lease_duration" json:"lease_duration"` // in seconds </s> remove RangeStart string `yaml:"range_start"` </s> add RangeStart string `yaml:"range_start" json:"range_start"` </s> remove Options []string `yaml:"options"` </s> add Options []string `yaml:"options" json:"-"` </s> remove RaSlaacOnly bool `yaml:"ra_slaac_only"` // send ICMPv6.RA packets without MO flags RaAllowSlaac bool `yaml:"ra_allow_slaac"` // send ICMPv6.RA packets with MO flags </s> add RaSlaacOnly bool `yaml:"ra_slaac_only" json:"-"` // send ICMPv6.RA packets without MO flags RaAllowSlaac bool `yaml:"ra_allow_slaac" json:"-"` // send ICMPv6.RA packets with MO flags
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/server.go
keep keep keep keep replace keep keep keep keep keep
<mask> // where DEC_CODE is a decimal DHCPv4 option code in range [1..255] <mask> // <mask> // Option with IP data (only 1 IP is supported): <mask> // DEC_CODE ip IP_ADDR <mask> Options []string `yaml:"options"` <mask> <mask> ipStart net.IP // starting IP address for dynamic leases <mask> ipEnd net.IP // ending IP address for dynamic leases <mask> leaseTime time.Duration // the time during which a dynamic lease is considered valid <mask> dnsIPAddrs []net.IP // IPv4 addresses to return to DHCP clients as DNS server addresses </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove RaSlaacOnly bool `yaml:"ra_slaac_only"` // send ICMPv6.RA packets without MO flags RaAllowSlaac bool `yaml:"ra_allow_slaac"` // send ICMPv6.RA packets with MO flags </s> add RaSlaacOnly bool `yaml:"ra_slaac_only" json:"-"` // send ICMPv6.RA packets without MO flags RaAllowSlaac bool `yaml:"ra_allow_slaac" json:"-"` // send ICMPv6.RA packets with MO flags </s> remove LeaseDuration uint32 `yaml:"lease_duration"` // in seconds </s> add LeaseDuration uint32 `yaml:"lease_duration" json:"lease_duration"` // in seconds </s> remove RangeStart net.IP `yaml:"range_start"` RangeEnd net.IP `yaml:"range_end"` </s> add RangeStart net.IP `yaml:"range_start" json:"range_start"` RangeEnd net.IP `yaml:"range_end" json:"range_end"` </s> remove ICMPTimeout uint32 `yaml:"icmp_timeout_msec"` </s> add ICMPTimeout uint32 `yaml:"icmp_timeout_msec" json:"-"` </s> remove LeaseDuration uint32 `yaml:"lease_duration"` // in seconds </s> add LeaseDuration uint32 `yaml:"lease_duration" json:"lease_duration"` // in seconds </s> remove GatewayIP net.IP `yaml:"gateway_ip"` SubnetMask net.IP `yaml:"subnet_mask"` </s> add GatewayIP net.IP `yaml:"gateway_ip" json:"gateway_ip"` SubnetMask net.IP `yaml:"subnet_mask" json:"subnet_mask"`
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/server.go
keep replace replace keep keep keep replace keep
<mask> type V6ServerConf struct { <mask> Enabled bool `yaml:"-"` <mask> InterfaceName string `yaml:"-"` <mask> <mask> // The first IP address for dynamic leases <mask> // The last allowed IP address ends with 0xff byte <mask> RangeStart string `yaml:"range_start"` <mask> </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove GatewayIP net.IP `yaml:"gateway_ip"` SubnetMask net.IP `yaml:"subnet_mask"` </s> add GatewayIP net.IP `yaml:"gateway_ip" json:"gateway_ip"` SubnetMask net.IP `yaml:"subnet_mask" json:"subnet_mask"` </s> remove Enabled bool `yaml:"-"` InterfaceName string `yaml:"-"` </s> add Enabled bool `yaml:"-" json:"-"` InterfaceName string `yaml:"-" json:"-"` </s> remove LeaseDuration uint32 `yaml:"lease_duration"` // in seconds </s> add LeaseDuration uint32 `yaml:"lease_duration" json:"lease_duration"` // in seconds </s> remove RangeStart net.IP `yaml:"range_start"` RangeEnd net.IP `yaml:"range_end"` </s> add RangeStart net.IP `yaml:"range_start" json:"range_start"` RangeEnd net.IP `yaml:"range_end" json:"range_end"` </s> remove type staticLeaseJSON struct { HWAddr string `json:"mac"` IP net.IP `json:"ip"` Hostname string `json:"hostname"` } </s> add
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/server.go
keep keep replace keep replace replace
<mask> RangeStart string `yaml:"range_start"` <mask> <mask> LeaseDuration uint32 `yaml:"lease_duration"` // in seconds <mask> <mask> RaSlaacOnly bool `yaml:"ra_slaac_only"` // send ICMPv6.RA packets without MO flags <mask> RaAllowSlaac bool `yaml:"ra_allow_slaac"` // send ICMPv6.RA packets with MO flags </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove RangeStart string `yaml:"range_start"` </s> add RangeStart string `yaml:"range_start" json:"range_start"` </s> remove LeaseDuration uint32 `yaml:"lease_duration"` // in seconds </s> add LeaseDuration uint32 `yaml:"lease_duration" json:"lease_duration"` // in seconds </s> remove ICMPTimeout uint32 `yaml:"icmp_timeout_msec"` </s> add ICMPTimeout uint32 `yaml:"icmp_timeout_msec" json:"-"` </s> remove Enabled bool `yaml:"-"` InterfaceName string `yaml:"-"` </s> add Enabled bool `yaml:"-" json:"-"` InterfaceName string `yaml:"-" json:"-"` </s> remove RangeStart net.IP `yaml:"range_start"` RangeEnd net.IP `yaml:"range_end"` </s> add RangeStart net.IP `yaml:"range_start" json:"range_start"` RangeEnd net.IP `yaml:"range_end" json:"range_end"`
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/server.go
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> // GetLeases returns the list of current DHCP leases (thread-safe) <mask> func (s *v4Server) GetLeases(flags int) []Lease { <mask> var result []Lease <mask> now := time.Now().Unix() <mask> <mask> s.leasesLock.Lock() <mask> for _, lease := range s.leases { <mask> if ((flags&LeasesDynamic) != 0 && lease.Expiry.Unix() > now && !s.blacklisted(lease)) || </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove var result []Lease </s> add // The function shouldn't return nil value because zero-length slice // behaves differently in cases like marshalling. Our front-end also // requires non-nil value in the response. result := []Lease{} </s> remove // []Lease -> JSON func convertLeases(inputLeases []Lease, includeExpires bool) []map[string]string { leases := []map[string]string{} for _, l := range inputLeases { lease := map[string]string{ "mac": l.HWAddr.String(), "ip": l.IP.String(), "hostname": l.Hostname, } if includeExpires { lease["expires"] = l.Expiry.Format(time.RFC3339) } leases = append(leases, lease) } return leases } </s> add </s> remove func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { leases := convertLeases(s.Leases(LeasesDynamic), true) staticLeases := convertLeases(s.Leases(LeasesStatic), false) </s> add // dhcpStatusResponse is the response for /control/dhcp/status endpoint. type dhcpStatusResponse struct { Enabled bool `json:"enabled"` IfaceName string `json:"interface_name"` V4 V4ServerConf `json:"v4"` V6 V6ServerConf `json:"v6"` Leases []Lease `json:"leases"` StaticLeases []Lease `json:"static_leases"` } </s> remove lj := staticLeaseJSON{} </s> add lj := Lease{} </s> remove lj := staticLeaseJSON{} </s> add lj := Lease{} </s> remove v4conf := V4ServerConf{} s.srv4.WriteDiskConfig4(&v4conf) </s> add func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { status := &dhcpStatusResponse{ Enabled: s.conf.Enabled, IfaceName: s.conf.InterfaceName, V4: V4ServerConf{}, V6: V6ServerConf{}, }
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/v4.go
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> // GetLeases - get current leases <mask> func (s *v6Server) GetLeases(flags int) []Lease { <mask> var result []Lease <mask> s.leasesLock.Lock() <mask> for _, lease := range s.leases { <mask> if lease.Expiry.Unix() == leaseExpireStatic { <mask> if (flags & LeasesStatic) != 0 { <mask> result = append(result, *lease) </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove var result []Lease </s> add // The function shouldn't return nil value because zero-length slice // behaves differently in cases like marshalling. Our front-end also // requires non-nil value in the response. result := []Lease{} </s> remove // []Lease -> JSON func convertLeases(inputLeases []Lease, includeExpires bool) []map[string]string { leases := []map[string]string{} for _, l := range inputLeases { lease := map[string]string{ "mac": l.HWAddr.String(), "ip": l.IP.String(), "hostname": l.Hostname, } if includeExpires { lease["expires"] = l.Expiry.Format(time.RFC3339) } leases = append(leases, lease) } return leases } </s> add </s> remove func (s *Server) handleDHCPStatus(w http.ResponseWriter, r *http.Request) { leases := convertLeases(s.Leases(LeasesDynamic), true) staticLeases := convertLeases(s.Leases(LeasesStatic), false) </s> add // dhcpStatusResponse is the response for /control/dhcp/status endpoint. type dhcpStatusResponse struct { Enabled bool `json:"enabled"` IfaceName string `json:"interface_name"` V4 V4ServerConf `json:"v4"` V6 V6ServerConf `json:"v6"` Leases []Lease `json:"leases"` StaticLeases []Lease `json:"static_leases"` } </s> remove mac, err := net.ParseMAC(lj.HWAddr) lease := Lease{ HWAddr: mac, } </s> add </s> remove mac, err := net.ParseMAC(lj.HWAddr) lease := Lease{ HWAddr: mac, } </s> add </s> remove response := map[string]interface{}{} </s> add response := map[string]netInterfaceJSON{}
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dhcpd/v6.go
keep keep replace replace replace replace replace replace replace replace keep replace keep keep keep
<mask> <mask> func (d *DNSFilter) handleSafeBrowsingStatus(w http.ResponseWriter, r *http.Request) { <mask> data := map[string]interface{}{ <mask> "enabled": d.Config.SafeBrowsingEnabled, <mask> } <mask> jsonVal, err := json.Marshal(data) <mask> if err != nil { <mask> httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) <mask> } <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> _, err = w.Write(jsonVal) <mask> if err != nil { <mask> httpError(r, w, http.StatusInternalServerError, "Unable to write response json: %s", err) <mask> return </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove data := map[string]interface{}{ "enabled": d.Config.SafeSearchEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) return } </s> add </s> remove data := map[string]interface{}{ "enabled": d.Config.ParentalEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) return } </s> add </s> remove _, err = w.Write(jsonVal) </s> add err := json.NewEncoder(w).Encode(&struct { Enabled bool `json:"enabled"` }{ Enabled: d.Config.SafeSearchEnabled, }) </s> remove _, err = w.Write(jsonVal) </s> add err := json.NewEncoder(w).Encode(&struct { Enabled bool `json:"enabled"` }{ Enabled: d.Config.ParentalEnabled, }) </s> remove status := map[string]interface{}{ "enabled": s.conf.Enabled, "interface_name": s.conf.InterfaceName, "v4": v4ServerConfToJSON(v4conf), "v6": v6ServerConfToJSON(v6conf), "leases": leases, "static_leases": staticLeases, } </s> add status.Leases = s.Leases(LeasesDynamic) status.StaticLeases = s.Leases(LeasesStatic)
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dnsfilter/safebrowsing.go
keep keep keep keep replace replace replace replace replace replace replace replace replace keep keep keep keep keep keep keep keep replace keep keep keep
<mask> d.Config.ConfigModified() <mask> } <mask> <mask> func (d *DNSFilter) handleParentalStatus(w http.ResponseWriter, r *http.Request) { <mask> data := map[string]interface{}{ <mask> "enabled": d.Config.ParentalEnabled, <mask> } <mask> jsonVal, err := json.Marshal(data) <mask> if err != nil { <mask> httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) <mask> return <mask> } <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> _, err = w.Write(jsonVal) <mask> if err != nil { <mask> httpError(r, w, http.StatusInternalServerError, "Unable to write response json: %s", err) <mask> return <mask> } <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> _, err = w.Write(jsonVal) <mask> if err != nil { <mask> httpError(r, w, http.StatusInternalServerError, "Unable to write response json: %s", err) <mask> return </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove data := map[string]interface{}{ "enabled": d.Config.SafeBrowsingEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) } </s> add </s> remove data := map[string]interface{}{ "enabled": d.Config.SafeSearchEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) return } </s> add </s> remove _, err = w.Write(jsonVal) </s> add err := json.NewEncoder(w).Encode(&struct { Enabled bool `json:"enabled"` }{ Enabled: d.Config.SafeBrowsingEnabled, }) </s> remove _, err = w.Write(jsonVal) </s> add err := json.NewEncoder(w).Encode(&struct { Enabled bool `json:"enabled"` }{ Enabled: d.Config.SafeSearchEnabled, }) </s> remove status := map[string]interface{}{ "enabled": s.conf.Enabled, "interface_name": s.conf.InterfaceName, "v4": v4ServerConfToJSON(v4conf), "v6": v6ServerConfToJSON(v6conf), "leases": leases, "static_leases": staticLeases, } </s> add status.Leases = s.Leases(LeasesDynamic) status.StaticLeases = s.Leases(LeasesStatic)
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dnsfilter/safebrowsing.go
keep keep replace replace replace replace replace replace replace replace replace keep keep keep keep keep keep keep keep replace keep keep keep
<mask> <mask> func (d *DNSFilter) handleSafeSearchStatus(w http.ResponseWriter, r *http.Request) { <mask> data := map[string]interface{}{ <mask> "enabled": d.Config.SafeSearchEnabled, <mask> } <mask> jsonVal, err := json.Marshal(data) <mask> if err != nil { <mask> httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) <mask> return <mask> } <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> _, err = w.Write(jsonVal) <mask> if err != nil { <mask> httpError(r, w, http.StatusInternalServerError, "Unable to write response json: %s", err) <mask> return <mask> } <mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> _, err = w.Write(jsonVal) <mask> if err != nil { <mask> httpError(r, w, http.StatusInternalServerError, "Unable to write response json: %s", err) <mask> return </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove data := map[string]interface{}{ "enabled": d.Config.SafeBrowsingEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) } </s> add </s> remove data := map[string]interface{}{ "enabled": d.Config.ParentalEnabled, } jsonVal, err := json.Marshal(data) if err != nil { httpError(r, w, http.StatusInternalServerError, "Unable to marshal status json: %s", err) return } </s> add </s> remove _, err = w.Write(jsonVal) </s> add err := json.NewEncoder(w).Encode(&struct { Enabled bool `json:"enabled"` }{ Enabled: d.Config.SafeBrowsingEnabled, }) </s> remove _, err = w.Write(jsonVal) </s> add err := json.NewEncoder(w).Encode(&struct { Enabled bool `json:"enabled"` }{ Enabled: d.Config.ParentalEnabled, }) </s> remove status := map[string]interface{}{ "enabled": s.conf.Enabled, "interface_name": s.conf.InterfaceName, "v4": v4ServerConfToJSON(v4conf), "v6": v6ServerConfToJSON(v6conf), "leases": leases, "static_leases": staticLeases, } </s> add status.Leases = s.Leases(LeasesDynamic) status.StaticLeases = s.Leases(LeasesStatic)
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
internal/dnsfilter/safesearch.go
keep keep keep keep replace keep keep keep keep keep
<mask> 'content': <mask> 'application/json': <mask> 'schema': <mask> '$ref': '#/components/schemas/DhcpStatus' <mask> '501': <mask> 'content': <mask> 'application/json': <mask> 'schema': <mask> '$ref': '#/components/schemas/Error' <mask> 'description': 'Not implemented (for example, on Windows).' </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> add 'NetInterfaces': 'type': 'object' 'description': > Network interfaces dictionary, keys are interface names. 'additionalProperties': '$ref': '#/components/schemas/NetInterface' </s> remove 'type': 'object' 'description': > Network interfaces dictionary, keys are interface names. 'additionalProperties': '$ref': '#/components/schemas/NetInterface' </s> add '$ref': '#/components/schemas/NetInterfaces' </s> remove 'description': 'yes|no|error' </s> add 'enum': - 'yes' - 'no' - 'error' 'description': > The result of determining static IP address. </s> remove 'description': 'yes|no|error' </s> add 'enum': - 'yes' - 'no' - 'error' 'description': > The result of searching the other DHCP server. </s> remove foundVal = "yes" </s> add result.V4.OtherServer.Found = "yes" </s> remove staticIPStatus = "error" staticIP["error"] = err.Error() </s> add result.V4.StaticIP.Static = "error" result.V4.StaticIP.Error = err.Error()
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
openapi/openapi.yaml
keep add keep keep keep keep keep
<mask> 'items': <mask> '$ref': '#/components/schemas/DhcpStaticLease' <mask> <mask> 'DhcpSearchResult': <mask> 'type': 'object' <mask> 'description': > <mask> Information about a DHCP server discovered in the current network. </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove 'type': 'object' 'description': > Network interfaces dictionary, keys are interface names. 'additionalProperties': '$ref': '#/components/schemas/NetInterface' </s> add '$ref': '#/components/schemas/NetInterfaces' </s> remove 'description': 'yes|no|error' </s> add 'enum': - 'yes' - 'no' - 'error' 'description': > The result of searching the other DHCP server. </s> remove 'description': 'yes|no|error' </s> add 'enum': - 'yes' - 'no' - 'error' 'description': > The result of determining static IP address. </s> remove '501': </s> add '500': 'content': 'application/json': 'schema': '$ref': '#/components/schemas/Error' 'description': 'Not implemented (for example, on Windows).' '/dhcp/interfaces': 'get': 'tags': - 'dhcp' 'operationId': 'dhcpInterfaces' 'summary': 'Gets the available interfaces' 'responses': '200': 'description': 'OK.' 'content': 'application/json': 'schema': '$ref': '#/components/schemas/NetInterfaces' '500': </s> remove var result []Lease </s> add // The function shouldn't return nil value because zero-length slice // behaves differently in cases like marshalling. Our front-end also // requires non-nil value in the response. result := []Lease{} </s> remove Options []string `yaml:"options"` </s> add Options []string `yaml:"options" json:"-"`
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
openapi/openapi.yaml
keep keep keep keep replace keep keep keep keep keep
<mask> 'type': 'object' <mask> 'properties': <mask> 'found': <mask> 'type': 'string' <mask> 'description': 'yes|no|error' <mask> 'example': 'no' <mask> 'error': <mask> 'type': 'string' <mask> 'description': 'Set if found=error' <mask> 'example': '' </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove 'description': 'yes|no|error' </s> add 'enum': - 'yes' - 'no' - 'error' 'description': > The result of determining static IP address. </s> remove 'type': 'object' 'description': > Network interfaces dictionary, keys are interface names. 'additionalProperties': '$ref': '#/components/schemas/NetInterface' </s> add '$ref': '#/components/schemas/NetInterfaces' </s> add 'NetInterfaces': 'type': 'object' 'description': > Network interfaces dictionary, keys are interface names. 'additionalProperties': '$ref': '#/components/schemas/NetInterface' </s> remove '501': </s> add '500': 'content': 'application/json': 'schema': '$ref': '#/components/schemas/Error' 'description': 'Not implemented (for example, on Windows).' '/dhcp/interfaces': 'get': 'tags': - 'dhcp' 'operationId': 'dhcpInterfaces' 'summary': 'Gets the available interfaces' 'responses': '200': 'description': 'OK.' 'content': 'application/json': 'schema': '$ref': '#/components/schemas/NetInterfaces' '500': </s> remove if err != nil { httpError(r, w, http.StatusBadRequest, "invalid MAC") return } err = s.srv6.AddStaticLease(lease) </s> add err = s.srv6.AddStaticLease(lj) </s> remove lease.IP = lj.IP.To16() if err != nil { httpError(r, w, http.StatusBadRequest, "invalid MAC") return } </s> add lj.IP = lj.IP.To16()
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
openapi/openapi.yaml
keep keep keep keep replace keep keep keep keep keep
<mask> 'type': 'object' <mask> 'properties': <mask> 'static': <mask> 'type': 'string' <mask> 'description': 'yes|no|error' <mask> 'example': 'yes' <mask> 'ip': <mask> 'type': 'string' <mask> 'description': 'Set if static=no' <mask> 'example': '' </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> remove 'description': 'yes|no|error' </s> add 'enum': - 'yes' - 'no' - 'error' 'description': > The result of searching the other DHCP server. </s> remove 'type': 'object' 'description': > Network interfaces dictionary, keys are interface names. 'additionalProperties': '$ref': '#/components/schemas/NetInterface' </s> add '$ref': '#/components/schemas/NetInterfaces' </s> add 'NetInterfaces': 'type': 'object' 'description': > Network interfaces dictionary, keys are interface names. 'additionalProperties': '$ref': '#/components/schemas/NetInterface' </s> remove '501': </s> add '500': 'content': 'application/json': 'schema': '$ref': '#/components/schemas/Error' 'description': 'Not implemented (for example, on Windows).' '/dhcp/interfaces': 'get': 'tags': - 'dhcp' 'operationId': 'dhcpInterfaces' 'summary': 'Gets the available interfaces' 'responses': '200': 'description': 'OK.' 'content': 'application/json': 'schema': '$ref': '#/components/schemas/NetInterfaces' '500': </s> remove if err != nil { httpError(r, w, http.StatusBadRequest, "invalid MAC") return } err = s.srv6.AddStaticLease(lease) </s> add err = s.srv6.AddStaticLease(lj) </s> remove lease.IP = lj.IP.To16() if err != nil { httpError(r, w, http.StatusBadRequest, "invalid MAC") return } </s> add lj.IP = lj.IP.To16()
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
openapi/openapi.yaml
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
<mask> 'type': 'integer' <mask> 'format': 'uint16' <mask> 'example': 80 <mask> 'interfaces': <mask> 'type': 'object' <mask> 'description': > <mask> Network interfaces dictionary, keys are interface names. <mask> 'additionalProperties': <mask> '$ref': '#/components/schemas/NetInterface' <mask> 'AddressesInfoBeta': <mask> 'type': 'object' <mask> 'description': 'AdGuard Home addresses configuration' <mask> 'required': <mask> - 'dns_port' </s> Pull request: 2509 type-safety vol.1 Merge in DNS/adguard-home from 2509-type-safety to master Updates #2509. Squashed commit of the following: commit 535968eb7de3a9e0817ddb57bc2320e5c5a55086 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 15:06:16 2021 +0300 dhcpd: fix comments commit dc79b80381fe7a8ecec6f9659fd23710c9229f59 Author: Eugene Burkov <[email protected]> Date: Wed Jan 20 14:08:10 2021 +0300 all: improve docs commit 156ebf6c9bad95f82cd121f019f3b59b77b18ba6 Author: Eugene Burkov <[email protected]> Date: Tue Jan 19 17:08:15 2021 +0300 all: improve JSON encoding and decoding </s> add 'NetInterfaces': 'type': 'object' 'description': > Network interfaces dictionary, keys are interface names. 'additionalProperties': '$ref': '#/components/schemas/NetInterface' </s> remove 'description': 'yes|no|error' </s> add 'enum': - 'yes' - 'no' - 'error' 'description': > The result of determining static IP address. </s> remove 'description': 'yes|no|error' </s> add 'enum': - 'yes' - 'no' - 'error' 'description': > The result of searching the other DHCP server. </s> remove '501': </s> add '500': 'content': 'application/json': 'schema': '$ref': '#/components/schemas/Error' 'description': 'Not implemented (for example, on Windows).' '/dhcp/interfaces': 'get': 'tags': - 'dhcp' 'operationId': 'dhcpInterfaces' 'summary': 'Gets the available interfaces' 'responses': '200': 'description': 'OK.' 'content': 'application/json': 'schema': '$ref': '#/components/schemas/NetInterfaces' '500': </s> remove Options []string `yaml:"options"` </s> add Options []string `yaml:"options" json:"-"` </s> remove RaSlaacOnly bool `yaml:"ra_slaac_only"` // send ICMPv6.RA packets without MO flags RaAllowSlaac bool `yaml:"ra_allow_slaac"` // send ICMPv6.RA packets with MO flags </s> add RaSlaacOnly bool `yaml:"ra_slaac_only" json:"-"` // send ICMPv6.RA packets without MO flags RaAllowSlaac bool `yaml:"ra_allow_slaac" json:"-"` // send ICMPv6.RA packets with MO flags
https://github.com/AdguardTeam/AdGuardHome/commit/5a50efadb2be6493d4c6f5fd2104b6d5861471f5
openapi/openapi.yaml
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> go 1.15 <mask> <mask> require ( <mask> github.com/AdguardTeam/dnsproxy v0.37.2 <mask> github.com/AdguardTeam/golibs v0.4.5 <mask> github.com/AdguardTeam/urlfilter v0.14.5 <mask> github.com/NYTimes/gziphandler v1.1.1 <mask> github.com/ameshkov/dnscrypt/v2 v2.1.3 <mask> github.com/digineo/go-ipset/v2 v2.2.1 </s> Pull request: all: fix some races Updates #3087. Squashed commit of the following: commit e888ce524f286f3c34e14e0086336b65a95fa020 Author: Ainar Garipov <[email protected]> Date: Mon May 17 16:34:10 2021 +0300 all: fix some races </s> remove github.com/AdguardTeam/dnsproxy v0.37.2 h1:3lgizD+lZI6uqxFiQykd1/hV7Ji4vSJBMejl1rbFAXU= github.com/AdguardTeam/dnsproxy v0.37.2/go.mod h1:xkJWEuTr550gPDmB9azsciKZzSXjf9wMn+Ji54PQ4gE= </s> add github.com/AdguardTeam/dnsproxy v0.37.4 h1:YIoJkIp828LKmmmgxXvZHUKfGLsqTQAK8g+4DXbDbyU= github.com/AdguardTeam/dnsproxy v0.37.4/go.mod h1:xkJWEuTr550gPDmB9azsciKZzSXjf9wMn+Ji54PQ4gE= </s> remove config.Language = language </s> add func() { config.Lock() defer config.Unlock() config.Language = language }() </s> add config.Lock() defer config.Unlock() </s> remove resp := statusResponse{ DNSAddrs: dnsAddrs, DNSPort: config.DNS.Port, HTTPPort: config.BindPort, IsRunning: isRunning(), Version: version.Version(), Language: config.Language, } </s> add var resp statusResponse func() { config.RLock() defer config.RUnlock() resp = statusResponse{ DNSAddrs: dnsAddrs, DNSPort: config.DNS.Port, HTTPPort: config.BindPort, IsRunning: isRunning(), Version: version.Version(), Language: config.Language, } }()
https://github.com/AdguardTeam/AdGuardHome/commit/5acae6e204ab3f5d92449c1231dee754c1db9abb
go.mod
keep keep keep keep replace replace keep keep keep keep keep
<mask> dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= <mask> git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= <mask> github.com/AdguardTeam/dhcp v0.0.0-20210517101438-550ef4cd8c6e h1:M6YnFP12o0/SjBEPt6b2r8ZkIy/wsV14TK8X9Tb6DEE= <mask> github.com/AdguardTeam/dhcp v0.0.0-20210517101438-550ef4cd8c6e/go.mod h1:TKl4jN3Voofo4UJIicyNhWGp/nlQqQkFxmwIFTvBkKI= <mask> github.com/AdguardTeam/dnsproxy v0.37.2 h1:3lgizD+lZI6uqxFiQykd1/hV7Ji4vSJBMejl1rbFAXU= <mask> github.com/AdguardTeam/dnsproxy v0.37.2/go.mod h1:xkJWEuTr550gPDmB9azsciKZzSXjf9wMn+Ji54PQ4gE= <mask> github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= <mask> github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= <mask> github.com/AdguardTeam/golibs v0.4.4/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= <mask> github.com/AdguardTeam/golibs v0.4.5 h1:RRA9ZsmbJEN4OllAx0BcfvSbRBxxpWluJijBYmtp13U= <mask> github.com/AdguardTeam/golibs v0.4.5/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= </s> Pull request: all: fix some races Updates #3087. Squashed commit of the following: commit e888ce524f286f3c34e14e0086336b65a95fa020 Author: Ainar Garipov <[email protected]> Date: Mon May 17 16:34:10 2021 +0300 all: fix some races </s> remove github.com/AdguardTeam/dnsproxy v0.37.2 </s> add github.com/AdguardTeam/dnsproxy v0.37.4 </s> remove config.Language = language </s> add func() { config.Lock() defer config.Unlock() config.Language = language }() </s> add config.Lock() defer config.Unlock() </s> remove resp := statusResponse{ DNSAddrs: dnsAddrs, DNSPort: config.DNS.Port, HTTPPort: config.BindPort, IsRunning: isRunning(), Version: version.Version(), Language: config.Language, } </s> add var resp statusResponse func() { config.RLock() defer config.RUnlock() resp = statusResponse{ DNSAddrs: dnsAddrs, DNSPort: config.DNS.Port, HTTPPort: config.BindPort, IsRunning: isRunning(), Version: version.Version(), Language: config.Language, } }()
https://github.com/AdguardTeam/AdGuardHome/commit/5acae6e204ab3f5d92449c1231dee754c1db9abb
go.sum
keep keep keep keep replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> <mask> return <mask> } <mask> <mask> resp := statusResponse{ <mask> DNSAddrs: dnsAddrs, <mask> DNSPort: config.DNS.Port, <mask> HTTPPort: config.BindPort, <mask> IsRunning: isRunning(), <mask> Version: version.Version(), <mask> Language: config.Language, <mask> } <mask> <mask> var c *dnsforward.FilteringConfig <mask> if Context.dnsServer != nil { <mask> c = &dnsforward.FilteringConfig{} <mask> Context.dnsServer.WriteDiskConfig(c) </s> Pull request: all: fix some races Updates #3087. Squashed commit of the following: commit e888ce524f286f3c34e14e0086336b65a95fa020 Author: Ainar Garipov <[email protected]> Date: Mon May 17 16:34:10 2021 +0300 all: fix some races </s> remove config.Language = language </s> add func() { config.Lock() defer config.Unlock() config.Language = language }() </s> add config.Lock() defer config.Unlock() </s> remove github.com/AdguardTeam/dnsproxy v0.37.2 h1:3lgizD+lZI6uqxFiQykd1/hV7Ji4vSJBMejl1rbFAXU= github.com/AdguardTeam/dnsproxy v0.37.2/go.mod h1:xkJWEuTr550gPDmB9azsciKZzSXjf9wMn+Ji54PQ4gE= </s> add github.com/AdguardTeam/dnsproxy v0.37.4 h1:YIoJkIp828LKmmmgxXvZHUKfGLsqTQAK8g+4DXbDbyU= github.com/AdguardTeam/dnsproxy v0.37.4/go.mod h1:xkJWEuTr550gPDmB9azsciKZzSXjf9wMn+Ji54PQ4gE= </s> remove github.com/AdguardTeam/dnsproxy v0.37.2 </s> add github.com/AdguardTeam/dnsproxy v0.37.4
https://github.com/AdguardTeam/AdGuardHome/commit/5acae6e204ab3f5d92449c1231dee754c1db9abb
internal/home/control.go
keep add keep keep keep keep
<mask> <mask> func startDNSServer() error { <mask> if isRunning() { <mask> return fmt.Errorf("unable to start forwarding DNS server: Already running") <mask> } <mask> </s> Pull request: all: fix some races Updates #3087. Squashed commit of the following: commit e888ce524f286f3c34e14e0086336b65a95fa020 Author: Ainar Garipov <[email protected]> Date: Mon May 17 16:34:10 2021 +0300 all: fix some races </s> remove resp := statusResponse{ DNSAddrs: dnsAddrs, DNSPort: config.DNS.Port, HTTPPort: config.BindPort, IsRunning: isRunning(), Version: version.Version(), Language: config.Language, } </s> add var resp statusResponse func() { config.RLock() defer config.RUnlock() resp = statusResponse{ DNSAddrs: dnsAddrs, DNSPort: config.DNS.Port, HTTPPort: config.BindPort, IsRunning: isRunning(), Version: version.Version(), Language: config.Language, } }() </s> remove config.Language = language </s> add func() { config.Lock() defer config.Unlock() config.Language = language }() </s> remove github.com/AdguardTeam/dnsproxy v0.37.2 h1:3lgizD+lZI6uqxFiQykd1/hV7Ji4vSJBMejl1rbFAXU= github.com/AdguardTeam/dnsproxy v0.37.2/go.mod h1:xkJWEuTr550gPDmB9azsciKZzSXjf9wMn+Ji54PQ4gE= </s> add github.com/AdguardTeam/dnsproxy v0.37.4 h1:YIoJkIp828LKmmmgxXvZHUKfGLsqTQAK8g+4DXbDbyU= github.com/AdguardTeam/dnsproxy v0.37.4/go.mod h1:xkJWEuTr550gPDmB9azsciKZzSXjf9wMn+Ji54PQ4gE= </s> remove github.com/AdguardTeam/dnsproxy v0.37.2 </s> add github.com/AdguardTeam/dnsproxy v0.37.4
https://github.com/AdguardTeam/AdGuardHome/commit/5acae6e204ab3f5d92449c1231dee754c1db9abb
internal/home/dns.go
keep keep keep keep replace keep keep keep
<mask> <mask> return <mask> } <mask> <mask> config.Language = language <mask> onConfigModified() <mask> returnOK(w) <mask> } </s> Pull request: all: fix some races Updates #3087. Squashed commit of the following: commit e888ce524f286f3c34e14e0086336b65a95fa020 Author: Ainar Garipov <[email protected]> Date: Mon May 17 16:34:10 2021 +0300 all: fix some races </s> remove resp := statusResponse{ DNSAddrs: dnsAddrs, DNSPort: config.DNS.Port, HTTPPort: config.BindPort, IsRunning: isRunning(), Version: version.Version(), Language: config.Language, } </s> add var resp statusResponse func() { config.RLock() defer config.RUnlock() resp = statusResponse{ DNSAddrs: dnsAddrs, DNSPort: config.DNS.Port, HTTPPort: config.BindPort, IsRunning: isRunning(), Version: version.Version(), Language: config.Language, } }() </s> add config.Lock() defer config.Unlock() </s> remove github.com/AdguardTeam/dnsproxy v0.37.2 h1:3lgizD+lZI6uqxFiQykd1/hV7Ji4vSJBMejl1rbFAXU= github.com/AdguardTeam/dnsproxy v0.37.2/go.mod h1:xkJWEuTr550gPDmB9azsciKZzSXjf9wMn+Ji54PQ4gE= </s> add github.com/AdguardTeam/dnsproxy v0.37.4 h1:YIoJkIp828LKmmmgxXvZHUKfGLsqTQAK8g+4DXbDbyU= github.com/AdguardTeam/dnsproxy v0.37.4/go.mod h1:xkJWEuTr550gPDmB9azsciKZzSXjf9wMn+Ji54PQ4gE= </s> remove github.com/AdguardTeam/dnsproxy v0.37.2 </s> add github.com/AdguardTeam/dnsproxy v0.37.4
https://github.com/AdguardTeam/AdGuardHome/commit/5acae6e204ab3f5d92449c1231dee754c1db9abb
internal/home/i18n.go
keep keep keep keep replace keep keep keep keep keep
<mask> import { Trans, withNamespaces } from 'react-i18next'; <mask> import flow from 'lodash/flow'; <mask> <mask> import { <mask> renderField, <mask> renderRadioField, <mask> renderSelectField, <mask> required, <mask> ipv4, <mask> ipv6, </s> * client: fix render field for DNS settings </s> remove component={renderField} </s> add component={renderInputField} </s> remove component={renderField} </s> add component={renderInputField} </s> remove component={renderField} </s> add component={renderInputField}
https://github.com/AdguardTeam/AdGuardHome/commit/5ba45b91c9cfde84fc0866e6b3fca679504975e7
client/src/components/Settings/Dns/Config/Form.js
keep keep keep keep replace keep keep keep keep keep
<mask> </div> <mask> <Field <mask> name="ratelimit" <mask> type="number" <mask> component={renderField} <mask> className="form-control" <mask> placeholder={t('form_enter_rate_limit')} <mask> normalize={toNumber} <mask> validate={[required, biggerOrEqualZero]} <mask> /> </s> * client: fix render field for DNS settings </s> remove component={renderField} </s> add component={renderInputField} </s> remove component={renderField} </s> add component={renderInputField} </s> remove renderField, </s> add renderInputField,
https://github.com/AdguardTeam/AdGuardHome/commit/5ba45b91c9cfde84fc0866e6b3fca679504975e7
client/src/components/Settings/Dns/Config/Form.js
keep keep keep keep replace keep keep keep keep keep
<mask> <Trans>blocking_ipv4_desc</Trans> <mask> </div> <mask> <Field <mask> name="blocking_ipv4" <mask> component={renderField} <mask> className="form-control" <mask> placeholder={t('form_enter_ip')} <mask> validate={[ipv4, required]} <mask> /> <mask> </div> </s> * client: fix render field for DNS settings </s> remove component={renderField} </s> add component={renderInputField} </s> remove component={renderField} </s> add component={renderInputField} </s> remove renderField, </s> add renderInputField,
https://github.com/AdguardTeam/AdGuardHome/commit/5ba45b91c9cfde84fc0866e6b3fca679504975e7
client/src/components/Settings/Dns/Config/Form.js