From 91dee0986ba2cb9ab91af32de6ac5567f813b1b7 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Tue, 21 Feb 2023 16:38:22 +0300 Subject: [PATCH 1/5] Pull request 1743: upd-sorting Merge in DNS/adguard-home from upd-sorting to master Squashed commit of the following: commit 7bd21de65c50168d5ad83ff46e63f4cbca365d23 Author: Ainar Garipov Date: Tue Feb 21 10:57:17 2023 +0300 all: upd sorting, go-lint --- internal/dnsforward/config.go | 16 +-- internal/dnsforward/config_test.go | 4 +- internal/filtering/blocked_test.go | 38 ------- internal/filtering/rewrites.go | 43 +++----- internal/filtering/safebrowsing.go | 6 +- internal/home/clients.go | 9 +- internal/home/config.go | 6 +- internal/querylog/qlog_test.go | 72 ------------- internal/querylog/search.go | 6 +- internal/stats/unit.go | 6 +- scripts/make/go-lint.sh | 167 +++++++++++------------------ scripts/make/helper.sh | 84 +++++++++++++++ scripts/make/txt-lint.sh | 36 ++----- 13 files changed, 191 insertions(+), 302 deletions(-) delete mode 100644 internal/filtering/blocked_test.go create mode 100644 scripts/make/helper.sh diff --git a/internal/dnsforward/config.go b/internal/dnsforward/config.go index b48eb776ccb..9e8eb7df6ef 100644 --- a/internal/dnsforward/config.go +++ b/internal/dnsforward/config.go @@ -7,7 +7,6 @@ import ( "net" "net/netip" "os" - "sort" "strings" "time" @@ -23,6 +22,7 @@ import ( "github.com/AdguardTeam/golibs/stringutil" "github.com/AdguardTeam/golibs/timeutil" "github.com/ameshkov/dnscrypt/v2" + "golang.org/x/exp/slices" ) // BlockingMode is an enum of all allowed blocking modes. @@ -510,7 +510,7 @@ func (s *Server) prepareTLS(proxyConfig *proxy.Config) (err error) { if len(cert.DNSNames) != 0 { s.conf.dnsNames = cert.DNSNames log.Debug("dnsforward: using certificate's SAN as DNS names: %v", cert.DNSNames) - sort.Strings(s.conf.dnsNames) + slices.Sort(s.conf.dnsNames) } else { s.conf.dnsNames = append(s.conf.dnsNames, cert.Subject.CommonName) log.Debug("dnsforward: using certificate's CN as DNS name: %s", cert.Subject.CommonName) @@ -526,16 +526,6 @@ func (s *Server) prepareTLS(proxyConfig *proxy.Config) (err error) { return nil } -// isInSorted returns true if s is in the sorted slice strs. -func isInSorted(strs []string, s string) (ok bool) { - i := sort.SearchStrings(strs, s) - if i == len(strs) || strs[i] != s { - return false - } - - return true -} - // isWildcard returns true if host is a wildcard hostname. func isWildcard(host string) (ok bool) { return len(host) >= 2 && host[0] == '*' && host[1] == '.' @@ -554,7 +544,7 @@ func anyNameMatches(dnsNames []string, sni string) (ok bool) { return false } - if isInSorted(dnsNames, sni) { + if _, ok = slices.BinarySearch(dnsNames, sni); ok { return true } diff --git a/internal/dnsforward/config_test.go b/internal/dnsforward/config_test.go index f98e2c22575..007a7fee053 100644 --- a/internal/dnsforward/config_test.go +++ b/internal/dnsforward/config_test.go @@ -1,15 +1,15 @@ package dnsforward import ( - "sort" "testing" "github.com/stretchr/testify/assert" + "golang.org/x/exp/slices" ) func TestAnyNameMatches(t *testing.T) { dnsNames := []string{"host1", "*.host2", "1.2.3.4"} - sort.Strings(dnsNames) + slices.Sort(dnsNames) testCases := []struct { name string diff --git a/internal/filtering/blocked_test.go b/internal/filtering/blocked_test.go deleted file mode 100644 index 575f75cc72a..00000000000 --- a/internal/filtering/blocked_test.go +++ /dev/null @@ -1,38 +0,0 @@ -//go:build ignore -// +build ignore - -package filtering - -import ( - "fmt" - "sort" - "testing" -) - -// This is a simple tool that takes a list of services and prints them to the output. -// It is supposed to be used to update: -// client/src/helpers/constants.js -// client/src/components/ui/Icons.js -// -// Usage: -// 1. go run ./internal/filtering/blocked_test.go -// 2. Use the output to replace `SERVICES` array in "client/src/helpers/constants.js". -// 3. You'll need to enter services names manually. -// 4. Don't forget to add missing icons to "client/src/components/ui/Icons.js". -// -// TODO(ameshkov): Rework generator: have a JSON file with all the metadata we need -// then use this JSON file to generate JS and Go code -func TestGenServicesArray(t *testing.T) { - services := make([]svc, len(serviceRulesArray)) - copy(services, serviceRulesArray) - - sort.Slice(services, func(i, j int) bool { - return services[i].name < services[j].name - }) - - fmt.Println("export const SERVICES = [") - for _, s := range services { - fmt.Printf(" {\n id: '%s',\n name: '%s',\n },\n", s.name, s.name) - } - fmt.Println("];") -} diff --git a/internal/filtering/rewrites.go b/internal/filtering/rewrites.go index 873272a19f5..3e10da5574e 100644 --- a/internal/filtering/rewrites.go +++ b/internal/filtering/rewrites.go @@ -1,11 +1,8 @@ -// DNS Rewrites - package filtering import ( "fmt" "net" - "sort" "strings" "github.com/AdguardTeam/golibs/errors" @@ -14,6 +11,8 @@ import ( "golang.org/x/exp/slices" ) +// Legacy DNS rewrites + // LegacyRewrite is a single legacy DNS rewrite record. // // Instances of *LegacyRewrite must never be nil. @@ -123,38 +122,24 @@ func matchDomainWildcard(host, wildcard string) (ok bool) { return isWildcard(wildcard) && strings.HasSuffix(host, wildcard[1:]) } -// rewritesSorted is a slice of legacy rewrites for sorting. -// -// The sorting priority: -// -// 1. A and AAAA > CNAME -// 2. wildcard > exact -// 3. lower level wildcard > higher level wildcard +// legacyRewriteSortsBefore sorts rewirtes according to the following priority: // -// TODO(a.garipov): Replace with slices.Sort. -type rewritesSorted []*LegacyRewrite - -// Len implements the sort.Interface interface for rewritesSorted. -func (a rewritesSorted) Len() (l int) { return len(a) } - -// Swap implements the sort.Interface interface for rewritesSorted. -func (a rewritesSorted) Swap(i, j int) { a[i], a[j] = a[j], a[i] } - -// Less implements the sort.Interface interface for rewritesSorted. -func (a rewritesSorted) Less(i, j int) (less bool) { - ith, jth := a[i], a[j] - if ith.Type == dns.TypeCNAME && jth.Type != dns.TypeCNAME { +// 1. A and AAAA > CNAME; +// 2. wildcard > exact; +// 3. lower level wildcard > higher level wildcard; +func legacyRewriteSortsBefore(a, b *LegacyRewrite) (sortsBefore bool) { + if a.Type == dns.TypeCNAME && b.Type != dns.TypeCNAME { return true - } else if ith.Type != dns.TypeCNAME && jth.Type == dns.TypeCNAME { + } else if a.Type != dns.TypeCNAME && b.Type == dns.TypeCNAME { return false } - if iw, jw := isWildcard(ith.Domain), isWildcard(jth.Domain); iw != jw { - return jw + if aIsWld, bIsWld := isWildcard(a.Domain), isWildcard(b.Domain); aIsWld != bIsWld { + return bIsWld } - // Both are either wildcards or not. - return len(ith.Domain) > len(jth.Domain) + // Both are either wildcards or both aren't. + return len(a.Domain) > len(b.Domain) } // prepareRewrites normalizes and validates all legacy DNS rewrites. @@ -196,7 +181,7 @@ func findRewrites( return nil, matched } - sort.Sort(rewritesSorted(rewrites)) + slices.SortFunc(rewrites, legacyRewriteSortsBefore) for i, r := range rewrites { if isWildcard(r.Domain) { diff --git a/internal/filtering/safebrowsing.go b/internal/filtering/safebrowsing.go index 2e648346152..3fb814d7e95 100644 --- a/internal/filtering/safebrowsing.go +++ b/internal/filtering/safebrowsing.go @@ -8,7 +8,6 @@ import ( "fmt" "net" "net/http" - "sort" "strings" "sync" "time" @@ -19,6 +18,7 @@ import ( "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/stringutil" "github.com/miekg/dns" + "golang.org/x/exp/slices" "golang.org/x/net/publicsuffix" ) @@ -241,8 +241,8 @@ func (c *sbCtx) processTXT(resp *dns.Msg) (bool, [][]byte) { } func (c *sbCtx) storeCache(hashes [][]byte) { - sort.Slice(hashes, func(a, b int) bool { - return bytes.Compare(hashes[a], hashes[b]) == -1 + slices.SortFunc(hashes, func(a, b []byte) (sortsBefore bool) { + return bytes.Compare(a, b) == -1 }) var curData []byte diff --git a/internal/home/clients.go b/internal/home/clients.go index 5d0a9ef25d0..2ae81377763 100644 --- a/internal/home/clients.go +++ b/internal/home/clients.go @@ -6,7 +6,6 @@ import ( "fmt" "net" "net/netip" - "sort" "strings" "sync" "time" @@ -271,7 +270,7 @@ func (clients *clientsContainer) addFromConfig(objects []*clientObject) { } } - sort.Strings(cli.Tags) + slices.Sort(cli.Tags) _, err := clients.Add(cli) if err != nil { @@ -311,7 +310,9 @@ func (clients *clientsContainer) forConfig() (objs []*clientObject) { // above loop can generate different orderings when writing to the config // file: this produces lots of diffs in config files, so sort objects by // name before writing. - sort.Slice(objs, func(i, j int) bool { return objs[i].Name < objs[j].Name }) + slices.SortStableFunc(objs, func(a, b *clientObject) (sortsBefore bool) { + return a.Name < b.Name + }) return objs } @@ -590,7 +591,7 @@ func (clients *clientsContainer) check(c *Client) (err error) { } } - sort.Strings(c.Tags) + slices.Sort(c.Tags) err = dnsforward.ValidateUpstreams(c.Upstreams) if err != nil { diff --git a/internal/home/config.go b/internal/home/config.go index 69baa18c90b..c484f1854d6 100644 --- a/internal/home/config.go +++ b/internal/home/config.go @@ -6,7 +6,6 @@ import ( "net/netip" "os" "path/filepath" - "sort" "sync" "github.com/AdguardTeam/AdGuardHome/internal/aghalg" @@ -21,6 +20,7 @@ import ( "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/timeutil" "github.com/google/renameio/maybe" + "golang.org/x/exp/slices" yaml "gopkg.in/yaml.v3" ) @@ -490,7 +490,7 @@ func (c *configuration) write() (err error) { config.Stats.Interval = statsConf.LimitDays config.Stats.Enabled = statsConf.Enabled config.Stats.Ignored = statsConf.Ignored.Values() - sort.Strings(config.Stats.Ignored) + slices.Sort(config.Stats.Ignored) } if Context.queryLog != nil { @@ -502,7 +502,7 @@ func (c *configuration) write() (err error) { config.QueryLog.Interval = timeutil.Duration{Duration: dc.RotationIvl} config.QueryLog.MemSize = dc.MemSize config.QueryLog.Ignored = dc.Ignored.Values() - sort.Strings(config.QueryLog.Ignored) + slices.Sort(config.Stats.Ignored) } if Context.filters != nil { diff --git a/internal/querylog/qlog_test.go b/internal/querylog/qlog_test.go index 75f025364c4..cb9ea3f0de2 100644 --- a/internal/querylog/qlog_test.go +++ b/internal/querylog/qlog_test.go @@ -2,11 +2,8 @@ package querylog import ( "fmt" - "math/rand" "net" - "sort" "testing" - "time" "github.com/AdguardTeam/AdGuardHome/internal/filtering" "github.com/AdguardTeam/dnsproxy/proxyutil" @@ -352,72 +349,3 @@ func assertLogEntry(t *testing.T, entry *logEntry, host string, answer, client n ip := proxyutil.IPFromRR(msg.Answer[0]).To16() assert.Equal(t, answer, ip) } - -func testEntries() (entries []*logEntry) { - rsrc := rand.NewSource(time.Now().UnixNano()) - rgen := rand.New(rsrc) - - entries = make([]*logEntry, 1000) - for i := range entries { - min := rgen.Intn(60) - sec := rgen.Intn(60) - entries[i] = &logEntry{ - Time: time.Date(2020, 1, 1, 0, min, sec, 0, time.UTC), - } - } - - return entries -} - -// logEntriesByTimeDesc is a wrapper over []*logEntry for sorting. -// -// NOTE(a.garipov): Weirdly enough, on my machine this gets consistently -// outperformed by sort.Slice, see the benchmark below. I'm leaving this -// implementation here, in tests, in case we want to make sure it outperforms on -// most machines, but for now this is unused in the actual code. -type logEntriesByTimeDesc []*logEntry - -// Len implements the sort.Interface interface for logEntriesByTimeDesc. -func (les logEntriesByTimeDesc) Len() (n int) { return len(les) } - -// Less implements the sort.Interface interface for logEntriesByTimeDesc. -func (les logEntriesByTimeDesc) Less(i, j int) (less bool) { - return les[i].Time.After(les[j].Time) -} - -// Swap implements the sort.Interface interface for logEntriesByTimeDesc. -func (les logEntriesByTimeDesc) Swap(i, j int) { les[i], les[j] = les[j], les[i] } - -func BenchmarkLogEntry_sort(b *testing.B) { - b.Run("methods", func(b *testing.B) { - for i := 0; i < b.N; i++ { - b.StopTimer() - entries := testEntries() - b.StartTimer() - - sort.Stable(logEntriesByTimeDesc(entries)) - } - }) - - b.Run("reflect", func(b *testing.B) { - for i := 0; i < b.N; i++ { - b.StopTimer() - entries := testEntries() - b.StartTimer() - - sort.SliceStable(entries, func(i, j int) (less bool) { - return entries[i].Time.After(entries[j].Time) - }) - } - }) -} - -func TestLogEntriesByTime_sort(t *testing.T) { - entries := testEntries() - sort.Sort(logEntriesByTimeDesc(entries)) - - for i := range entries[1:] { - assert.False(t, entries[i+1].Time.After(entries[i].Time), - "%s %s", entries[i+1].Time, entries[i].Time) - } -} diff --git a/internal/querylog/search.go b/internal/querylog/search.go index c1df5d5fc57..035fcfc94ce 100644 --- a/internal/querylog/search.go +++ b/internal/querylog/search.go @@ -2,10 +2,10 @@ package querylog import ( "io" - "sort" "time" "github.com/AdguardTeam/golibs/log" + "golang.org/x/exp/slices" ) // client finds the client info, if any, by its ClientID and IP address, @@ -98,8 +98,8 @@ func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest tim // weird on the frontend. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2293. - sort.SliceStable(entries, func(i, j int) (less bool) { - return entries[i].Time.After(entries[j].Time) + slices.SortStableFunc(entries, func(a, b *logEntry) (sortsBefore bool) { + return a.Time.After(b.Time) }) if params.offset > 0 { diff --git a/internal/stats/unit.go b/internal/stats/unit.go index 99e044298b6..5a5ada4f964 100644 --- a/internal/stats/unit.go +++ b/internal/stats/unit.go @@ -5,13 +5,13 @@ import ( "encoding/binary" "encoding/gob" "fmt" - "sort" "time" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/stringutil" "go.etcd.io/bbolt" + "golang.org/x/exp/slices" ) // TODO(a.garipov): Rewrite all of this. Add proper error handling and @@ -180,8 +180,8 @@ func convertMapToSlice(m map[string]uint64, max int) (s []countPair) { s = append(s, countPair{Name: k, Count: v}) } - sort.Slice(s, func(i, j int) bool { - return s[j].Count < s[i].Count + slices.SortFunc(s, func(a, b countPair) (sortsBefore bool) { + return a.Count < b.Count }) if max > len(s) { max = len(s) diff --git a/scripts/make/go-lint.sh b/scripts/make/go-lint.sh index 2fb947c6e28..933d16a8fc7 100644 --- a/scripts/make/go-lint.sh +++ b/scripts/make/go-lint.sh @@ -1,8 +1,13 @@ #!/bin/sh +# This comment is used to simplify checking local copies of the script. Bump +# this number every time a significant change is made to this script. +# +# AdGuard-Project-Version: 3 + verbose="${VERBOSE:-0}" +readonly verbose -# Set verbosity. if [ "$verbose" -gt '0' ] then set -x @@ -16,34 +21,12 @@ else set -e fi -# We don't need glob expansions and we want to see errors about unset variables. set -f -u -# Deferred Helpers - -not_found_msg=' -looks like a binary not found error. -make sure you have installed the linter binaries using: - - $ make go-tools -' -readonly not_found_msg - -# TODO(a.garipov): Put it into a separate script and source it both here and in -# txt-lint.sh? -not_found() { - if [ "$?" -eq '127' ] - then - # Code 127 is the exit status a shell uses when a command or - # a file is not found, according to the Bash Hackers wiki. - # - # See https://wiki.bash-hackers.org/dict/terms/exit_status. - echo "$not_found_msg" 1>&2 - fi -} -trap not_found EXIT +# Source the common helpers, including not_found and run_linter. +. ./scripts/make/helper.sh @@ -52,7 +35,7 @@ trap not_found EXIT go_version="$( "${GO:-go}" version )" readonly go_version -go_min_version='go1.19' +go_min_version='go1.19.6' go_version_msg=" warning: your go version (${go_version}) is different from the recommended minimal one (${go_min_version}). if you have the version installed, please set the GO environment variable. @@ -74,7 +57,7 @@ esac -# Simple Analyzers +# Simple analyzers # blocklist_imports is a simple check against unwanted packages. The following # packages are banned: @@ -91,6 +74,8 @@ esac # # See https://github.com/golang/go/issues/45200. # +# * Package sort is replaced by golang.org/x/exp/slices. +# # * Package unsafe is… unsafe. # # * Package golang.org/x/net/context has been moved into stdlib. @@ -101,6 +86,7 @@ blocklist_imports() { -e '[[:space:]]"io/ioutil"$'\ -e '[[:space:]]"log"$'\ -e '[[:space:]]"reflect"$'\ + -e '[[:space:]]"sort"$'\ -e '[[:space:]]"unsafe"$'\ -e '[[:space:]]"golang.org/x/net/context"$'\ -n\ @@ -158,96 +144,67 @@ underscores() { -# Helpers - -# exit_on_output exits with a nonzero exit code if there is anything in the -# command's combined output. -exit_on_output() ( - set +e - - if [ "$VERBOSE" -lt '2' ] - then - set +x - fi - - cmd="$1" - shift - - output="$( "$cmd" "$@" 2>&1 )" - exitcode="$?" - if [ "$exitcode" -ne '0' ] - then - echo "'$cmd' failed with code $exitcode" - fi - - if [ "$output" != '' ] - then - if [ "$*" != '' ] - then - echo "combined output of linter '$cmd $*':" - else - echo "combined output of linter '$cmd':" - fi - - echo "$output" - - if [ "$exitcode" -eq '0' ] - then - exitcode='1' - fi - fi - - return "$exitcode" -) - - - # Checks -exit_on_output blocklist_imports +run_linter -e blocklist_imports -exit_on_output method_const +run_linter -e method_const -exit_on_output underscores +run_linter -e underscores -exit_on_output gofumpt --extra -e -l . +run_linter -e gofumpt --extra -e -l . -# TODO(a.garipov): golint is deprecated, and seems to cause more and more -# issues with each release. Find a suitable replacement. -# -# golint --set_exit_status ./... +# TODO(a.garipov): golint is deprecated, find a suitable replacement. -"$GO" vet ./... +run_linter "$GO" vet ./... -govulncheck ./... +run_linter govulncheck ./... # Apply more lax standards to the code we haven't properly refactored yet. -gocyclo --over 17 ./internal/querylog/ -gocyclo --over 13 ./internal/dhcpd ./internal/filtering/ ./internal/home/ - -# Apply stricter standards to new or somewhat refactored code. -gocyclo --over 10 ./internal/aghio/ ./internal/aghnet/ ./internal/aghos/\ - ./internal/aghtest/ ./internal/dnsforward/ ./internal/filtering/rewrite/\ - ./internal/stats/ ./internal/tools/ ./internal/updater/ ./internal/next/\ - ./internal/version/ ./scripts/blocked-services/ ./scripts/vetted-filters/\ - ./main.go - -ineffassign ./... - -unparam ./... - -git ls-files -- '*.go' '*.mod' '*.sh' 'Makefile' | xargs misspell --error - -looppointer ./... - -nilness ./... - -exit_on_output shadow --strict ./... +run_linter gocyclo --over 17 ./internal/querylog/ +run_linter gocyclo --over 13\ + ./internal/dhcpd\ + ./internal/filtering/\ + ./internal/home/\ + ; + +# Apply the normal standards to new or somewhat refactored code. +run_linter gocyclo --over 10\ + ./internal/aghio/\ + ./internal/aghnet/\ + ./internal/aghos/\ + ./internal/aghtest/\ + ./internal/dnsforward/\ + ./internal/filtering/rewrite/\ + ./internal/stats/\ + ./internal/tools/\ + ./internal/updater/\ + ./internal/next/\ + ./internal/version/\ + ./scripts/blocked-services/\ + ./scripts/vetted-filters/\ + ./main.go\ + ; + +run_linter ineffassign ./... + +run_linter unparam ./... + +git ls-files -- 'Makefile' '*.go' '*.mod' '*.sh' '*.yaml' '*.yml'\ + | xargs misspell --error + +run_linter looppointer ./... + +run_linter nilness ./... + +# TODO(a.garipov): Add fieldalignment? + +run_linter -e shadow --strict ./... # TODO(a.garipov): Enable in v0.108.0. -# gosec --quiet ./... +# run_linter gosec --quiet ./... # TODO(a.garipov): Enable --blank? -errcheck --asserts ./... +run_linter errcheck --asserts ./... -staticcheck ./... +run_linter staticcheck ./... diff --git a/scripts/make/helper.sh b/scripts/make/helper.sh new file mode 100644 index 00000000000..6d7fe778fdf --- /dev/null +++ b/scripts/make/helper.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +# Common script helpers +# +# This file contains common script helpers. It should be sourced in scripts +# right after the initial environment processing. + +# This comment is used to simplify checking local copies of the script. Bump +# this number every time a remarkable change is made to this script. +# +# AdGuard-Project-Version: 2 + + + +# Deferred helpers + +not_found_msg=' +looks like a binary not found error. +make sure you have installed the linter binaries using: + + $ make go-tools +' +readonly not_found_msg + +not_found() { + if [ "$?" -eq '127' ] + then + # Code 127 is the exit status a shell uses when a command or a file is + # not found, according to the Bash Hackers wiki. + # + # See https://wiki.bash-hackers.org/dict/terms/exit_status. + echo "$not_found_msg" 1>&2 + fi +} +trap not_found EXIT + + + +# Helpers + +# run_linter runs the given linter with two additions: +# +# 1. If the first argument is "-e", run_linter exits with a nonzero exit code +# if there is anything in the command's combined output. +# +# 2. In any case, run_linter adds the program's name to its combined output. +run_linter() ( + set +e + + if [ "$VERBOSE" -lt '2' ] + then + set +x + fi + + cmd="${1:?run_linter: provide a command}" + shift + + exit_on_output='0' + if [ "$cmd" = '-e' ] + then + exit_on_output='1' + cmd="${1:?run_linter: provide a command}" + shift + fi + + readonly cmd + + output="$( "$cmd" "$@" )" + exitcode="$?" + + readonly output + + if [ "$output" != '' ] + then + echo "$output" | sed -e "s/^/${cmd}: /" + + if [ "$exitcode" -eq '0' ] && [ "$exit_on_output" -eq '1' ] + then + exitcode='1' + fi + fi + + return "$exitcode" +) diff --git a/scripts/make/txt-lint.sh b/scripts/make/txt-lint.sh index aa959506558..23434e4e06b 100644 --- a/scripts/make/txt-lint.sh +++ b/scripts/make/txt-lint.sh @@ -1,9 +1,13 @@ #!/bin/sh +# This comment is used to simplify checking local copies of the script. Bump +# this number every time a remarkable change is made to this script. +# +# AdGuard-Project-Version: 2 + verbose="${VERBOSE:-0}" readonly verbose -# Set verbosity. if [ "$verbose" -gt '0' ] then set -x @@ -20,31 +24,9 @@ fi # We don't need glob expansions and we want to see errors about unset variables. set -f -u - - -# Deferred Helpers - -not_found_msg=' -looks like a binary not found error. -make sure you have installed the linter binaries using: - - $ make go-tools -' -readonly not_found_msg - -# TODO(a.garipov): Put it into a separate script and source it both here and in -# go-lint.sh? -not_found() { - if [ "$?" -eq '127' ] - then - # Code 127 is the exit status a shell uses when a command or - # a file is not found, according to the Bash Hackers wiki. - # - # See https://wiki.bash-hackers.org/dict/terms/exit_status. - echo "$not_found_msg" 1>&2 - fi -} -trap not_found EXIT +# Source the common helpers, including not_found. +. ./scripts/make/helper.sh git ls-files -- '*.md' '*.yaml' '*.yml' 'client/src/__locales/en.json'\ - | xargs misspell --error + | xargs misspell --error\ + | sed -e 's/^/misspell: /' From 20531de7604975260e9e06381ffb965dfb15eb18 Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Tue, 21 Feb 2023 16:52:33 +0300 Subject: [PATCH 2/5] Pull request: Pull request: 4884 Update golibs Merge in DNS/adguard-home from 4884-upd-golibs to master Updates #4884. Squashed commit of the following: commit 4d076021c2e500a75d0b3662643c0c26fd53f6c3 Merge: d780ad00 91dee098 Author: Eugene Burkov Date: Tue Feb 21 16:47:08 2023 +0300 Merge branch 'master' into 4884-upd-golibs commit d780ad008b8925a1f499d70f827b79be597c60b5 Author: Eugene Burkov Date: Tue Feb 21 14:17:11 2023 +0300 dnsforward: imp tests commit ff9963da35d0220af461cdec66a38134f85ec956 Author: Eugene Burkov Date: Tue Feb 21 13:50:05 2023 +0300 all: log changes commit 5703f7a52a364c2d075ed2d862a38587c2650cae Author: Eugene Burkov Date: Tue Feb 21 13:36:43 2023 +0300 all: upd golibs and fix breaking changes --- CHANGELOG.md | 5 +++++ go.mod | 4 ++-- go.sum | 8 ++++---- internal/aghnet/arpdb_bsd.go | 2 +- internal/aghnet/arpdb_linux.go | 2 +- internal/aghnet/hostscontainer.go | 2 +- internal/dhcpd/v4_unix.go | 4 ++-- internal/dhcpd/v4_unix_test.go | 4 ++-- internal/dnsforward/clientid.go | 2 +- internal/dnsforward/clientid_test.go | 6 +++--- internal/dnsforward/config.go | 3 ++- internal/dnsforward/config_test.go | 4 ++++ internal/dnsforward/dns.go | 4 ++-- internal/dnsforward/dnsforward_test.go | 3 ++- internal/dnsforward/http_test.go | 3 ++- 15 files changed, 34 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7c0566373b..5529e7083e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,12 +25,17 @@ NOTE: Add new changes BELOW THIS COMMENT. ### Fixed +- Requirements to domain names in domain-specific upstream configurations have + been relaxed to meet those from [RFC 3696][rfc3696] ([#4884]). - Panic when using unencrypted DNS-over-HTTPS ([#5518]). - Failing service installation via script on FreeBSD ([#5431]). +[#4884]: https://github.com/AdguardTeam/AdGuardHome/issues/4884 [#5518]: https://github.com/AdguardTeam/AdGuardHome/issues/5518 [#5431]: https://github.com/AdguardTeam/AdGuardHome/issues/5431 +[rfc3696]: https://datatracker.ietf.org/doc/html/rfc3696 + diff --git a/go.mod b/go.mod index 2d54d4c4bf1..6c2f1dad263 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,8 @@ go 1.19 require ( // TODO(a.garipov): Use v0.48.0 when it's released. - github.com/AdguardTeam/dnsproxy v0.47.1-0.20230207130636-533058b17239 - github.com/AdguardTeam/golibs v0.11.4 + github.com/AdguardTeam/dnsproxy v0.48.0 + github.com/AdguardTeam/golibs v0.12.0 github.com/AdguardTeam/urlfilter v0.16.1 github.com/NYTimes/gziphandler v1.1.1 github.com/ameshkov/dnscrypt/v2 v2.2.5 diff --git a/go.sum b/go.sum index 68a4b1ab595..346caa8d6fd 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,9 @@ -github.com/AdguardTeam/dnsproxy v0.47.1-0.20230207130636-533058b17239 h1:n1oOiywOvdeqWLto809bK1rK1EPDkpaSfT/r1OiCVaQ= -github.com/AdguardTeam/dnsproxy v0.47.1-0.20230207130636-533058b17239/go.mod h1:+Sdi5ISrjDFbeCsKNqzcC1Ag7pJ5Hh9y+UBNb3dfqJ4= +github.com/AdguardTeam/dnsproxy v0.48.0 h1:sGViYy2pV0cEp2zCsxPjFd9rlgD0+yELpIeLkBxHAoI= +github.com/AdguardTeam/dnsproxy v0.48.0/go.mod h1:9OHoeaVod+moWwrLjHF95RQnFWGi/6B1tfKsxWc/yGE= github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.10.4/go.mod h1:rSfQRGHIdgfxriDDNgNJ7HmE5zRoURq8R+VdR81Zuzw= -github.com/AdguardTeam/golibs v0.11.4 h1:IltyvxwCTN+xxJF5sh6VadF8Zfbf8elgCm9dgijSVzM= -github.com/AdguardTeam/golibs v0.11.4/go.mod h1:87bN2x4VsTritptE3XZg9l8T6gznWsIxHBcQ1DeRIXA= +github.com/AdguardTeam/golibs v0.12.0 h1:z4Q3Mz0pHJ2Zag4B0RBaIXEUue1TPOKkbRiYkwC4r7I= +github.com/AdguardTeam/golibs v0.12.0/go.mod h1:87bN2x4VsTritptE3XZg9l8T6gznWsIxHBcQ1DeRIXA= github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU= github.com/AdguardTeam/urlfilter v0.16.1 h1:ZPi0rjqo8cQf2FVdzo6cqumNoHZx2KPXj2yZa1A5BBw= github.com/AdguardTeam/urlfilter v0.16.1/go.mod h1:46YZDOV1+qtdRDuhZKVPSSp7JWWes0KayqHrKAFBdEI= diff --git a/internal/aghnet/arpdb_bsd.go b/internal/aghnet/arpdb_bsd.go index c4048939ae8..50287785c48 100644 --- a/internal/aghnet/arpdb_bsd.go +++ b/internal/aghnet/arpdb_bsd.go @@ -67,7 +67,7 @@ func parseArpA(sc *bufio.Scanner, lenHint int) (ns []Neighbor) { } host := fields[0] - err = netutil.ValidateDomainName(host) + err = netutil.ValidateHostname(host) if err != nil { log.Debug("arpdb: parsing arp output: host: %s", err) } else { diff --git a/internal/aghnet/arpdb_linux.go b/internal/aghnet/arpdb_linux.go index e6e51febee3..d3ebe4a7458 100644 --- a/internal/aghnet/arpdb_linux.go +++ b/internal/aghnet/arpdb_linux.go @@ -198,7 +198,7 @@ func parseArpA(sc *bufio.Scanner, lenHint int) (ns []Neighbor) { } host := fields[0] - if verr := netutil.ValidateDomainName(host); verr != nil { + if verr := netutil.ValidateHostname(host); verr != nil { log.Debug("arpdb: parsing arp output: host: %s", verr) } else { n.Name = host diff --git a/internal/aghnet/hostscontainer.go b/internal/aghnet/hostscontainer.go index 62886730c9e..c53f9d7ce8e 100644 --- a/internal/aghnet/hostscontainer.go +++ b/internal/aghnet/hostscontainer.go @@ -343,7 +343,7 @@ func (hp *hostsParser) parseLine(line string) (ip netip.Addr, hosts []string) { // See https://github.com/AdguardTeam/AdGuardHome/issues/3946. // // TODO(e.burkov): Investigate if hosts may contain DNS-SD domains. - err = netutil.ValidateDomainName(f) + err = netutil.ValidateHostname(f) if err != nil { log.Error("%s: host %q is invalid, ignoring", hostsContainerPref, f) diff --git a/internal/dhcpd/v4_unix.go b/internal/dhcpd/v4_unix.go index d83e0125d53..64ebf25dd20 100644 --- a/internal/dhcpd/v4_unix.go +++ b/internal/dhcpd/v4_unix.go @@ -108,7 +108,7 @@ func (s *v4Server) validHostnameForClient(cliHostname string, ip net.IP) (hostna hostname = aghnet.GenerateHostname(ip) } - err = netutil.ValidateDomainName(hostname) + err = netutil.ValidateHostname(hostname) if err != nil { log.Info("dhcpv4: %s", err) hostname = "" @@ -372,7 +372,7 @@ func (s *v4Server) AddStaticLease(l *Lease) (err error) { return err } - err = netutil.ValidateDomainName(hostname) + err = netutil.ValidateHostname(hostname) if err != nil { return fmt.Errorf("validating hostname: %w", err) } diff --git a/internal/dhcpd/v4_unix_test.go b/internal/dhcpd/v4_unix_test.go index 411e36d9629..8c1255e1472 100644 --- a/internal/dhcpd/v4_unix_test.go +++ b/internal/dhcpd/v4_unix_test.go @@ -251,8 +251,8 @@ func TestV4Server_AddRemove_static(t *testing.T) { }, name: "bad_hostname", wantErrMsg: `dhcpv4: adding static lease: validating hostname: ` + - `bad domain name "bad-lbl-.local": ` + - `bad domain name label "bad-lbl-": bad domain name label rune '-'`, + `bad hostname "bad-lbl-.local": ` + + `bad hostname label "bad-lbl-": bad hostname label rune '-'`, }} for _, tc := range testCases { diff --git a/internal/dnsforward/clientid.go b/internal/dnsforward/clientid.go index b48d4a4c3ea..a7f2902a3bc 100644 --- a/internal/dnsforward/clientid.go +++ b/internal/dnsforward/clientid.go @@ -14,7 +14,7 @@ import ( // ValidateClientID returns an error if id is not a valid ClientID. func ValidateClientID(id string) (err error) { - err = netutil.ValidateDomainNameLabel(id) + err = netutil.ValidateHostnameLabel(id) if err != nil { // Replace the domain name label wrapper with our own. return fmt.Errorf("invalid clientid %q: %w", id, errors.Unwrap(err)) diff --git a/internal/dnsforward/clientid_test.go b/internal/dnsforward/clientid_test.go index 458b66d336c..5391ddc04ad 100644 --- a/internal/dnsforward/clientid_test.go +++ b/internal/dnsforward/clientid_test.go @@ -119,7 +119,7 @@ func TestServer_clientIDFromDNSContext(t *testing.T) { cliSrvName: "!!!.example.com", wantClientID: "", wantErrMsg: `clientid check: invalid clientid "!!!": ` + - `bad domain name label rune '!'`, + `bad hostname label rune '!'`, inclHTTPTLS: false, strictSNI: true, }, { @@ -131,7 +131,7 @@ func TestServer_clientIDFromDNSContext(t *testing.T) { wantClientID: "", wantErrMsg: `clientid check: invalid clientid "abcdefghijklmno` + `pqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789": ` + - `domain name label is too long: got 72, max 63`, + `hostname label is too long: got 72, max 63`, inclHTTPTLS: false, strictSNI: true, }, { @@ -330,7 +330,7 @@ func TestClientIDFromDNSContextHTTPS(t *testing.T) { path: "/dns-query/!!!", cliSrvName: "example.com", wantClientID: "", - wantErrMsg: `clientid check: invalid clientid "!!!": bad domain name label rune '!'`, + wantErrMsg: `clientid check: invalid clientid "!!!": bad hostname label rune '!'`, }, { name: "both_ids", path: "/dns-query/right", diff --git a/internal/dnsforward/config.go b/internal/dnsforward/config.go index 9e8eb7df6ef..eeeb4c400bc 100644 --- a/internal/dnsforward/config.go +++ b/internal/dnsforward/config.go @@ -540,7 +540,8 @@ func matchesDomainWildcard(host, pat string) (ok bool) { // anyNameMatches returns true if sni, the client's SNI value, matches any of // the DNS names and patterns from certificate. dnsNames must be sorted. func anyNameMatches(dnsNames []string, sni string) (ok bool) { - if netutil.ValidateDomainName(sni) != nil { + // Check sni is either a valid hostname or a valid IP address. + if netutil.ValidateHostname(sni) != nil && net.ParseIP(sni) == nil { return false } diff --git a/internal/dnsforward/config_test.go b/internal/dnsforward/config_test.go index 007a7fee053..a13a567bc86 100644 --- a/internal/dnsforward/config_test.go +++ b/internal/dnsforward/config_test.go @@ -31,6 +31,10 @@ func TestAnyNameMatches(t *testing.T) { name: "match", dnsName: "1.2.3.4", want: true, + }, { + name: "mismatch_bad_ip", + dnsName: "1.2.3.256", + want: false, }, { name: "mismatch", dnsName: "host2", diff --git a/internal/dnsforward/dns.go b/internal/dnsforward/dns.go index 8d924f3bbd3..9289eb45881 100644 --- a/internal/dnsforward/dns.go +++ b/internal/dnsforward/dns.go @@ -230,7 +230,7 @@ func (s *Server) onDHCPLeaseChanged(flags int) { for _, l := range ll { // TODO(a.garipov): Remove this after we're finished with the client // hostname validations in the DHCP server code. - err := netutil.ValidateDomainName(l.Hostname) + err := netutil.ValidateHostname(l.Hostname) if err != nil { log.Debug("dnsforward: skipping invalid hostname %q from dhcp: %s", l.Hostname, err) @@ -468,7 +468,7 @@ func (s *Server) processRestrictLocal(dctx *dnsContext) (rc resultCode) { return resultCodeError } - log.Debug("dnsforward: request is for a service domain") + log.Debug("dnsforward: request is not for arpa domain") return resultCodeSuccess } diff --git a/internal/dnsforward/dnsforward_test.go b/internal/dnsforward/dnsforward_test.go index a95b03dfb1d..6d928422d7b 100644 --- a/internal/dnsforward/dnsforward_test.go +++ b/internal/dnsforward/dnsforward_test.go @@ -1171,7 +1171,8 @@ func TestNewServer(t *testing.T) { LocalDomain: "!!!", }, wantErrMsg: `local domain: bad domain name "!!!": ` + - `bad domain name label "!!!": bad domain name label rune '!'`, + `bad top-level domain name label "!!!": ` + + `bad top-level domain name label rune '!'`, }} for _, tc := range testCases { diff --git a/internal/dnsforward/http_test.go b/internal/dnsforward/http_test.go index 5e0b801803e..db3356dc90d 100644 --- a/internal/dnsforward/http_test.go +++ b/internal/dnsforward/http_test.go @@ -337,7 +337,8 @@ func TestValidateUpstreams(t *testing.T) { }, { name: "bad_domain", wantErr: `bad upstream for domain "[/!/]8.8.8.8": domain at index 0: ` + - `bad domain name "!": bad domain name label "!": bad domain name label rune '!'`, + `bad domain name "!": bad top-level domain name label "!": ` + + `bad top-level domain name label rune '!'`, set: []string{"[/!/]8.8.8.8"}, }} From ff9b24ad6912e894d2992c07e7d017bc269e8bd5 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Tue, 21 Feb 2023 17:07:12 +0300 Subject: [PATCH 3/5] Pull request 1747: chlog-and-proj-skel Merge in DNS/adguard-home from chlog-and-proj-skel to master Squashed commit of the following: commit 8e7c3e2eb50c559bdcd5862e72c16511dd8272da Author: Ainar Garipov Date: Tue Feb 21 16:52:10 2023 +0300 all: upd proj skel --- CHANGELOG.md | 29 ++++++++++++++++++++-------- Makefile | 32 +++++++++++++++++++------------ internal/tools/tools.go | 1 - main.go | 1 - main_next.go | 1 - scripts/hooks/pre-commit | 14 +++++++++++--- scripts/make/go-build.sh | 28 +++++++++++++++++++++------ scripts/make/go-deps.sh | 15 +++++++++------ scripts/make/go-test.sh | 16 ++++++++++++++-- scripts/make/go-tools.sh | 41 ++++++++++++++++++++++++++++++++-------- 10 files changed, 130 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5529e7083e1..1eb99005437 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,11 +14,11 @@ and this project adheres to @@ -27,11 +27,9 @@ NOTE: Add new changes BELOW THIS COMMENT. - Requirements to domain names in domain-specific upstream configurations have been relaxed to meet those from [RFC 3696][rfc3696] ([#4884]). -- Panic when using unencrypted DNS-over-HTTPS ([#5518]). - Failing service installation via script on FreeBSD ([#5431]). [#4884]: https://github.com/AdguardTeam/AdGuardHome/issues/4884 -[#5518]: https://github.com/AdguardTeam/AdGuardHome/issues/5518 [#5431]: https://github.com/AdguardTeam/AdGuardHome/issues/5431 [rfc3696]: https://datatracker.ietf.org/doc/html/rfc3696 @@ -42,6 +40,20 @@ NOTE: Add new changes ABOVE THIS COMMENT. +## [v0.107.25] - 2023-02-21 + +See also the [v0.107.25 GitHub milestone][ms-v0.107.25]. + +### Fixed + +- Panic when using unencrypted DNS-over-HTTPS ([#5518]). + +[#5518]: https://github.com/AdguardTeam/AdGuardHome/issues/5518 + +[ms-v0.107.25]: https://github.com/AdguardTeam/AdGuardHome/milestone/61?closed=1 + + + ## [v0.107.24] - 2023-02-15 See also the [v0.107.24 GitHub milestone][ms-v0.107.24]. @@ -1682,11 +1694,12 @@ See also the [v0.104.2 GitHub milestone][ms-v0.104.2]. -[Unreleased]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.24...HEAD +[Unreleased]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.25...HEAD +[v0.107.25]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.24...v0.107.25 [v0.107.24]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.23...v0.107.24 [v0.107.23]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.22...v0.107.23 [v0.107.22]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.21...v0.107.22 diff --git a/Makefile b/Makefile index ad895f1641b..864734d449d 100644 --- a/Makefile +++ b/Makefile @@ -4,17 +4,26 @@ # See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html. .POSIX: +# This comment is used to simplify checking local copies of the +# Makefile. Bump this number every time a significant change is made to +# this Makefile. +# +# AdGuard-Project-Version: 2 + +# Don't name these macros "GO" etc., because GNU Make apparently makes +# them exported environment variables with the literal value of +# "${GO:-go}" and so on, which is not what we need. Use a dot in the +# name to make sure that users don't have an environment variable with +# the same name. +# +# See https://unix.stackexchange.com/q/646255/105635. +GO.MACRO = $${GO:-go} +VERBOSE.MACRO = $${VERBOSE:-0} + CHANNEL = development CLIENT_DIR = client COMMIT = $$( git rev-parse --short HEAD ) DIST_DIR = dist -# Don't name this macro "GO", because GNU Make apparenly makes it an -# exported environment variable with the literal value of "${GO:-go}", -# which is not what we need. Use a dot in the name to make sure that -# users don't have an environment variable with the same name. -# -# See https://unix.stackexchange.com/q/646255/105635. -GO.MACRO = $${GO:-go} GOPROXY = https://goproxy.cn|https://proxy.golang.org|direct GOSUMDB = sum.golang.google.cn GPG_KEY = devteam@adguard.com @@ -25,7 +34,6 @@ NPM_INSTALL_FLAGS = $(NPM_FLAGS) --quiet --no-progress --ignore-engines\ --ignore-optional --ignore-platform --ignore-scripts RACE = 0 SIGN = 1 -VERBOSE = 0 VERSION = v0.0.0 YARN = yarn @@ -59,13 +67,13 @@ ENV = env\ RACE='$(RACE)'\ SIGN='$(SIGN)'\ NEXTAPI='$(NEXTAPI)'\ - VERBOSE='$(VERBOSE)'\ + VERBOSE="$(VERBOSE.MACRO)"\ VERSION='$(VERSION)'\ # Keep the line above blank. -# Keep this target first, so that a naked make invocation triggers -# a full build. +# Keep this target first, so that a naked make invocation triggers a +# full build. build: deps quick-build quick-build: js-build go-build @@ -119,4 +127,4 @@ go-os-check: openapi-lint: ; cd ./openapi/ && $(YARN) test openapi-show: ; cd ./openapi/ && $(YARN) start -txt-lint: ; $(ENV) "$(SHELL)" ./scripts/make/txt-lint.sh +txt-lint: ; $(ENV) "$(SHELL)" ./scripts/make/txt-lint.sh diff --git a/internal/tools/tools.go b/internal/tools/tools.go index 230d6c4b3b8..88f55fa988b 100644 --- a/internal/tools/tools.go +++ b/internal/tools/tools.go @@ -1,5 +1,4 @@ //go:build tools -// +build tools package tools diff --git a/main.go b/main.go index 6246b19eea4..85c2795e758 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,4 @@ //go:build !next -// +build !next package main diff --git a/main_next.go b/main_next.go index d9773d4750b..bf3fa8eab8f 100644 --- a/main_next.go +++ b/main_next.go @@ -1,5 +1,4 @@ //go:build next -// +build next package main diff --git a/scripts/hooks/pre-commit b/scripts/hooks/pre-commit index a76639af1e4..cfb72448684 100755 --- a/scripts/hooks/pre-commit +++ b/scripts/hooks/pre-commit @@ -2,10 +2,18 @@ set -e -f -u -# Only show interactive prompts if there is a terminal attached. This -# should work on all of our supported Unix systems. +# This comment is used to simplify checking local copies of the script. +# Bump this number every time a significant change is made to this +# script. +# +# AdGuard-Project-Version: 1 + +# Only show interactive prompts if there a terminal is attached to +# stdout. While this technically doesn't guarantee that reading from +# /dev/tty works, this should work reasonably well on all of our +# supported development systems and in most terminal emulators. is_tty='0' -if [ -e /dev/tty ] +if [ -t '1' ] then is_tty='1' fi diff --git a/scripts/make/go-build.sh b/scripts/make/go-build.sh index 8d993d66fb5..7f629cd8549 100644 --- a/scripts/make/go-build.sh +++ b/scripts/make/go-build.sh @@ -6,6 +6,11 @@ # only has superficial knowledge of the POSIX shell language and alike. # Experienced readers may find it overly verbose. +# This comment is used to simplify checking local copies of the script. Bump +# this number every time a significant change is made to this script. +# +# AdGuard-Project-Version: 1 + # The default verbosity level is 0. Show every command that is run and every # package that is processed if the caller requested verbosity level greater than # 0. Also show subcommands if the requested verbosity level is greater than 1. @@ -111,17 +116,17 @@ readonly o_flags # must be enabled. if [ "${RACE:-0}" -eq '0' ] then - cgo_enabled='0' + CGO_ENABLED='0' race_flags='--race=0' else - cgo_enabled='1' + CGO_ENABLED='1' race_flags='--race=1' fi -readonly cgo_enabled race_flags +readonly CGO_ENABLED race_flags +export CGO_ENABLED -CGO_ENABLED="$cgo_enabled" GO111MODULE='on' -export CGO_ENABLED GO111MODULE +export GO111MODULE # Build the new binary if requested. if [ "${NEXTAPI:-0}" -eq '0' ] @@ -132,5 +137,16 @@ else fi readonly tags_flags -"$go" build --ldflags "$ldflags" "$race_flags" "$tags_flags" --trimpath "$o_flags" "$v_flags"\ +if [ "$verbose" -gt '0' ] +then + "$go" env +fi + +"$go" build\ + --ldflags "$ldflags"\ + "$race_flags"\ + "$tags_flags"\ + --trimpath\ + "$o_flags"\ + "$v_flags"\ "$x_flags" diff --git a/scripts/make/go-deps.sh b/scripts/make/go-deps.sh index 58ba720b86f..f12d2df7dd7 100644 --- a/scripts/make/go-deps.sh +++ b/scripts/make/go-deps.sh @@ -1,5 +1,10 @@ #!/bin/sh +# This comment is used to simplify checking local copies of the script. Bump +# this number every time a significant change is made to this script. +# +# AdGuard-Project-Version: 1 + verbose="${VERBOSE:-0}" readonly verbose @@ -7,14 +12,14 @@ if [ "$verbose" -gt '1' ] then env set -x - x_flags='-x' + x_flags='-x=1' elif [ "$verbose" -gt '0' ] then set -x - x_flags='' + x_flags='-x=0' else set +x - x_flags='' + x_flags='-x=0' fi readonly x_flags @@ -23,6 +28,4 @@ set -e -f -u go="${GO:-go}" readonly go -# Don't use quotes with flag variables because we want an empty space if those -# aren't set. -"$go" mod download $x_flags +"$go" mod download "$x_flags" diff --git a/scripts/make/go-test.sh b/scripts/make/go-test.sh index e37c7f1894e..03d2c100997 100644 --- a/scripts/make/go-test.sh +++ b/scripts/make/go-test.sh @@ -1,5 +1,10 @@ #!/bin/sh +# This comment is used to simplify checking local copies of the script. Bump +# this number every time a significant change is made to this script. +# +# AdGuard-Project-Version: 1 + verbose="${VERBOSE:-0}" readonly verbose @@ -43,5 +48,12 @@ shuffle_flags='--shuffle=on' timeout_flags="${TIMEOUT_FLAGS:---timeout=90s}" readonly count_flags cover_flags shuffle_flags timeout_flags -"$go" test "$count_flags" "$cover_flags" "$race_flags" "$shuffle_flags" "$timeout_flags"\ - "$x_flags" "$v_flags" ./... +"$go" test\ + "$count_flags"\ + "$cover_flags"\ + "$shuffle_flags"\ + "$race_flags"\ + "$timeout_flags"\ + "$x_flags"\ + "$v_flags"\ + ./... diff --git a/scripts/make/go-tools.sh b/scripts/make/go-tools.sh index a66d5c06d72..ba512dc3597 100644 --- a/scripts/make/go-tools.sh +++ b/scripts/make/go-tools.sh @@ -1,22 +1,27 @@ #!/bin/sh +# This comment is used to simplify checking local copies of the script. Bump +# this number every time a significant change is made to this script. +# +# AdGuard-Project-Version: 2 + verbose="${VERBOSE:-0}" readonly verbose if [ "$verbose" -gt '1' ] then set -x - v_flags='-v' - x_flags='-x' + v_flags='-v=1' + x_flags='-x=1' elif [ "$verbose" -gt '0' ] then set -x - v_flags='-v' - x_flags='' + v_flags='-v=1' + x_flags='-x=0' else set +x - v_flags='' - x_flags='' + v_flags='-v=0' + x_flags='-x=0' fi readonly v_flags x_flags @@ -27,6 +32,25 @@ readonly go # TODO(a.garipov): Add goconst? +# Remove only the actual binaries in the bin/ directory, as developers may add +# their own scripts there. Most commonly, a script named “go” for tools that +# call the go binary and need a particular version. +rm -f\ + bin/errcheck\ + bin/fieldalignment\ + bin/gocyclo\ + bin/gofumpt\ + bin/gosec\ + bin/govulncheck\ + bin/ineffassign\ + bin/looppointer\ + bin/misspell\ + bin/nilness\ + bin/shadow\ + bin/staticcheck\ + bin/unparam\ + ; + # Reset GOARCH and GOOS to make sure we install the tools for the native # architecture even when we're cross-compiling the main binary, and also to # prevent the "cannot install cross-compiled binaries when GOBIN is set" error. @@ -37,14 +61,15 @@ env\ GOWORK='off'\ "$go" install\ --modfile=./internal/tools/go.mod\ - $v_flags\ - $x_flags\ + "$v_flags"\ + "$x_flags"\ github.com/fzipp/gocyclo/cmd/gocyclo\ github.com/golangci/misspell/cmd/misspell\ github.com/gordonklaus/ineffassign\ github.com/kisielk/errcheck\ github.com/kyoh86/looppointer/cmd/looppointer\ github.com/securego/gosec/v2/cmd/gosec\ + golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment\ golang.org/x/tools/go/analysis/passes/nilness/cmd/nilness\ golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow\ golang.org/x/vuln/cmd/govulncheck\ From 76a513cdaf3fa2e951843f8779b79d56975916df Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Tue, 21 Feb 2023 18:06:37 +0300 Subject: [PATCH 4/5] Pull request 1748: upd-all Merge in DNS/adguard-home from upd-all to master Squashed commit of the following: commit 7014e7631933f7d5cb58ec6fd1a221f497983e98 Author: Ainar Garipov Date: Tue Feb 21 17:57:35 2023 +0300 all: upd i18n, filters, trackers, services, tools --- client/src/__locales/tr.json | 2 +- client/src/__locales/zh-cn.json | 2 +- client/src/helpers/filters/filters.js | 2 +- client/src/helpers/trackers/trackers.json | 168 ++++++++++++++++++++-- go.mod | 8 +- go.sum | 18 +-- internal/filtering/servicelist.go | 30 +++- internal/tools/go.mod | 6 +- internal/tools/go.sum | 12 +- scripts/make/Dockerfile | 2 +- 10 files changed, 209 insertions(+), 41 deletions(-) diff --git a/client/src/__locales/tr.json b/client/src/__locales/tr.json index 72acb887ba1..d4e3b1727f6 100644 --- a/client/src/__locales/tr.json +++ b/client/src/__locales/tr.json @@ -449,7 +449,7 @@ "access_disallowed_title": "İzin verilmeyen istemciler", "access_disallowed_desc": "CIDR'lerin, IP adreslerinin veya İstemci Kimliklerin listesi. Bu listede girişler varsa, AdGuard Home bu istemcilerden gelen istekleri keser. İzin verilen istemcilerde girişler varsa, bu alan yok sayılır.", "access_blocked_title": "İzin verilmeyen alan adları", - "access_blocked_desc": "Bu işlem filtrelerle ilgili değildir. AdGuard Home, bu alan adlarından gelen DNS sorgularını yanıtsız bırakır ve bu sorgular sorgu günlüğünde görünmez. Tam alan adlarını, joker karakterleri veya URL filtre kurallarını belirtebilirsiniz, ör. \"example.org\", \"*.example.org\" veya \"||example.org^\".", + "access_blocked_desc": "Bu işlem filtrelerle ilgili değildir. AdGuard Home, bu alan adlarından gelen DNS sorgularını yanıtsız bırakır ve bu sorgular sorgu günlüğünde görünmez. Tam alan adlarını, joker karakterleri veya URL filtre kurallarını belirtebilirsiniz, örn. \"example.org\", \"*.example.org\" veya \"||example.org^\".", "access_settings_saved": "Erişim ayarları başarıyla kaydedildi!", "updates_checked": "AdGuard Home'un yeni bir sürümü mevcut", "updates_version_equal": "AdGuard Home yazılımı güncel durumda", diff --git a/client/src/__locales/zh-cn.json b/client/src/__locales/zh-cn.json index 27d2fcbdc41..3d417844208 100644 --- a/client/src/__locales/zh-cn.json +++ b/client/src/__locales/zh-cn.json @@ -172,7 +172,7 @@ "list_url_table_header": "清单网址", "rules_count_table_header": "规则数", "last_time_updated_table_header": "上次更新时间", - "actions_table_header": "活跃状态", + "actions_table_header": "操作", "request_table_header": "请求", "edit_table_action": "编辑", "delete_table_action": "删除", diff --git a/client/src/helpers/filters/filters.js b/client/src/helpers/filters/filters.js index 6f4af9e50dc..5ace4d7ce56 100644 --- a/client/src/helpers/filters/filters.js +++ b/client/src/helpers/filters/filters.js @@ -101,7 +101,7 @@ export default { "source": "https://adguardteam.github.io/HostlistsRegistry/assets/filter_13.txt" }, "POL_polish_filters_for_pi_hole": { - "name": "POL: Polish filters for Pi hole", + "name": "POL: Polish filters for Pi-hole", "categoryId": "regional", "homepage": "https://www.certyficate.it/", "source": "https://adguardteam.github.io/HostlistsRegistry/assets/filter_14.txt" diff --git a/client/src/helpers/trackers/trackers.json b/client/src/helpers/trackers/trackers.json index 485b759ece9..17a870e9207 100644 --- a/client/src/helpers/trackers/trackers.json +++ b/client/src/helpers/trackers/trackers.json @@ -1,5 +1,5 @@ { - "timeUpdated": "2023-02-09T12:31:34.007Z", + "timeUpdated": "2023-02-21T12:46:33.324Z", "categories": { "0": "audio_video_player", "1": "comments", @@ -6772,55 +6772,64 @@ "name": "Facebook", "categoryId": 4, "url": "https://www.facebook.com", - "companyId": "facebook" + "companyId": "meta", + "source": "AdGuard" }, "facebook_beacon": { "name": "Facebook Beacon", "categoryId": 7, "url": "http://www.facebook.com/beacon/faq.php", - "companyId": "facebook" + "companyId": "meta", + "source": "AdGuard" }, "facebook_cdn": { "name": "Facebook CDN", "categoryId": 9, "url": "https://www.facebook.com", - "companyId": "facebook" + "companyId": "meta", + "source": "AdGuard" }, "facebook_connect": { "name": "Facebook Connect", "categoryId": 6, "url": "https://developers.facebook.com/connect.php", - "companyId": "facebook" + "companyId": "meta", + "source": "AdGuard" }, "facebook_conversion_tracking": { "name": "Facebook Conversion Tracking", "categoryId": 4, "url": "http://www.facebook.com/", - "companyId": "facebook" + "companyId": "meta", + "source": "AdGuard" }, "facebook_custom_audience": { "name": "Facebook Custom Audience", "categoryId": 4, "url": "https://www.facebook.com", - "companyId": "facebook" + "companyId": "meta", + "source": "AdGuard" }, "facebook_graph": { "name": "Facebook Social Graph", "categoryId": 7, "url": "https://developers.facebook.com/docs/reference/api/", - "companyId": "facebook" + "companyId": "meta", + "source": "AdGuard" }, "facebook_impressions": { "name": "Facebook Impressions", "categoryId": 4, "url": "https://www.facebook.com/", - "companyId": "facebook" + "companyId": "meta", + "source": "AdGuard" }, "facebook_social_plugins": { "name": "Facebook Social Plugins", "categoryId": 7, "url": "https://developers.facebook.com/plugins", - "companyId": "facebook" + "companyId": "meta", + "source": "AdGuard" }, "facetz.dca": { "name": "Facetz.DCA", @@ -8909,7 +8918,8 @@ "name": "Instagram", "categoryId": 8, "url": "https://www.facebook.com/", - "companyId": "facebook" + "companyId": "meta", + "source": "AdGuard" }, "instant_check_mate": { "name": "Instant Check Mate", @@ -19240,7 +19250,7 @@ "name": "Facebook Audience Network", "categoryId": 4, "url": "https://www.facebook.com/business/products/audience-network", - "companyId": "facebook", + "companyId": "meta", "source": "AdGuard" }, "crashlytics": { @@ -19264,6 +19274,13 @@ "companyId": null, "source": "AdGuard" }, + "gmail": { + "name": "Gmail", + "categoryId": 13, + "url": "https://mail.google.com/", + "companyId": "google", + "source": "AdGuard" + }, "google_trust_services": { "name": "Google Trust Services", "categoryId": 5, @@ -19292,6 +19309,20 @@ "companyId": "branch_metrics_inc", "source": "AdGuard" }, + "telstra": { + "name": "Telstra", + "categoryId": 8, + "url": "https://www.telstra.com.au/", + "companyId": "telstra", + "source": "AdGuard" + }, + "medialab": { + "name": "MediaLab.AI Inc.", + "categoryId": 8, + "url": "https://medialab.la/", + "companyId": "medialab", + "source": "AdGuard" + }, "qualcomm": { "name": "Qualcomm", "categoryId": 8, @@ -19306,6 +19337,13 @@ "companyId": "solaredge", "source": "AdGuard" }, + "sectigo": { + "name": "Sectigo Limited", + "categoryId": 5, + "url": "https://www.solaredge.com/", + "companyId": "sectigo", + "source": "AdGuard" + }, "element": { "name": "Element", "categoryId": 7, @@ -19313,6 +19351,20 @@ "companyId": "element", "source": "AdGuard" }, + "oztam": { + "name": "OzTAM", + "categoryId": 8, + "url": "https://oztam.com.au/", + "companyId": "oztam", + "source": "AdGuard" + }, + "oppo": { + "name": "OPPO", + "categoryId": 101, + "url": "https://www.oppo.com/", + "companyId": "oppo", + "source": "AdGuard" + }, "outlook": { "name": "Microsoft Outlook", "categoryId": 13, @@ -19355,6 +19407,13 @@ "companyId": "lets_encrypt", "source": "AdGuard" }, + "kik": { + "name": "Kik", + "categoryId": 7, + "url": "https://kik.com/", + "companyId": "kik", + "source": "AdGuard" + }, "plex": { "name": "Plex", "categoryId": 0, @@ -19368,6 +19427,34 @@ "url": "https://matrix.org/", "companyId": "matrix", "source": "AdGuard" + }, + "ntppool": { + "name": "Network Time Protocol", + "categoryId": 5, + "url": "https://ntp.org/", + "companyId": "ntppool", + "source": "AdGuard" + }, + "whatsapp": { + "name": "WhatsApp", + "categoryId": 8, + "url": "https://www.whatsapp.com/", + "companyId": "meta", + "source": "AdGuard" + }, + "vscode": { + "name": "Visual Studio Code", + "categoryId": 8, + "url": "https://code.visualstudio.com/", + "companyId": "microsoft", + "source": "AdGuard" + }, + "msedge": { + "name": "Microsoft Edge", + "categoryId": 8, + "url": "https://www.microsoft.com/en-us/edge", + "companyId": "microsoft", + "source": "AdGuard" } }, "trackerDomains": { @@ -23698,10 +23785,24 @@ "zwaar.net": "zwaar", "zwaar.org": "zwaar", "extend.tv": "zypmedia", + "whatsapp.net": "whatsapp", + "whatsapp.com": "whatsapp", + "telstra.com.au": "telstra", + "telstra.com": "telstra", "slack.com": "slack", "slackb.com": "slack", "slack-edge.com": "slack", "slack-imgs.com": "slack", + "addlive.io": "snap", + "feelinsonice.com": "snap", + "sc-cdn.net": "snap", + "sc-corp.net": "snap", + "sc-gw.com": "snap", + "sc-jpl.com": "snap", + "sc-prod.net": "snap", + "snap-dev.net": "snap", + "snapads.com": "snap", + "snapkit.com": "snap", "adguard.app": "adguard", "adguard.io": "adguard", "adguard.org": "adguard", @@ -23710,41 +23811,80 @@ "adguard-vpn.com": "adguard", "adguardvpn.com": "adguard", "adguard-vpn.online": "adguard", + "oppomobile.com": "oppo", + "heytapmobi.com": "oppo", + "heytapmobile.com": "oppo", + "heytapdl.com": "oppo", + "allawnos.com": "oppo", + "allawntech.com": "oppo", "nflximg.com": "netflix", "element.io": "element", "riot.im": "element", + "gvt1.com": "google_servers", + "gvt2.com": "google_servers", + "gvt3.com": "google_servers", "akadns.net": "akamai_technologies", "akamaiedge.net": "akamai_technologies", + "akaquill.net": "akamai_technologies", + "me.com": "apple", "apple.news": "apple", "apple-dns.net": "apple", "aaplimg.com": "apple", "icloud.com": "apple", + "itunes.com": "apple", "icloud-content.com": "apple", + "kik.com": "kik", + "apikik.com": "kik", + "kik-live.com": "kik", "mzstatic.com": "apple", + "cdn-apple.com": "apple", + "apple-mapkit.com": "apple", + "icons.axm-usercontent-apple.com": "apple", + "apple-cloudkit.com": "apple", + "apzones.com": "apple", + "apple-livephotoskit.com": "apple", + "safebrowsing.apple": "apple", + "safebrowsing.g.applimg.com": "apple", "matrix.org": "matrix", - "l-msedge.net": "microsoft", + "medialab.la": "medialab", + "media-lab.ai": "medialab", + "phicdn.net": "digicert_trust_seal", + "e-msedge.net": "msedge", + "l-msedge.net": "msedge", + "exp-tas.com": "vscode", + "vscode-unpkg.net": "vscode", + "v0cdn.net": "vscode", + "vscode-cdn.net": "vscode", "iadsdk.apple.com": "apple_ads", "showrss.info": "showrss", + "sectigo.com": "sectigo", "solaredge.com": "solaredge", "crashlytics.com": "crashlytics", + "cloudflare-dns.com": "cloudflare", "flurry.com": "flurry", "hockeyapp.net": "hockeyapp", "app-measurement.com": "firebase", "appmetrica.yandex.com": "yandex_appmetrica", "letsencrypt.org": "lets_encrypt", "lencr.org": "lets_encrypt", + "oztam.com.au": "oztam", "mobileapptracking.com": "branch", + "ntp.org": "ntppool", + "ntppool.org": "ntppool", "plex.tv": "plex", "plex.direct": "plex", "edgecastcdn.net": "markmonitor", "appcenter.ms": "appcenter", "unityads.unity3d.com": "unity_ads", + "usertrust.com": "trustlogo", "azure.com": "azure", "trafficmanager.net": "azure", "hotmail.com": "outlook", + "outlook.com": "outlook", "bttn.io": "button", "pki.goog": "google_trust_services", "xtracloud.net": "qualcomm", - "qualcomm.com": "qualcomm" + "qualcomm.com": "qualcomm", + "gmail.com": "gmail" } } \ No newline at end of file diff --git a/go.mod b/go.mod index 6c2f1dad263..39e40a4c544 100644 --- a/go.mod +++ b/go.mod @@ -51,16 +51,16 @@ require ( github.com/josharian/native v1.1.0 // indirect github.com/mdlayher/packet v1.1.1 // indirect github.com/mdlayher/socket v0.4.0 // indirect - github.com/onsi/ginkgo/v2 v2.8.1 // indirect + github.com/onsi/ginkgo/v2 v2.8.3 // indirect github.com/patrickmn/go-cache v2.1.0+incompatible // indirect github.com/pierrec/lz4/v4 v4.1.17 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/quic-go/qpack v0.4.0 // indirect github.com/quic-go/qtls-go1-18 v0.2.0 // indirect - github.com/quic-go/qtls-go1-19 v0.2.0 // indirect - github.com/quic-go/qtls-go1-20 v0.1.0 // indirect - github.com/u-root/uio v0.0.0-20230215032506-9aa6f7e2d72c // indirect + github.com/quic-go/qtls-go1-19 v0.2.1 // indirect + github.com/quic-go/qtls-go1-20 v0.1.1 // indirect + github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923 // indirect golang.org/x/mod v0.8.0 // indirect golang.org/x/sync v0.1.0 // indirect golang.org/x/text v0.7.0 // indirect diff --git a/go.sum b/go.sum index 346caa8d6fd..8060927f2ac 100644 --- a/go.sum +++ b/go.sum @@ -108,9 +108,9 @@ github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA= github.com/miekg/dns v1.1.50/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/onsi/ginkgo/v2 v2.8.1 h1:xFTEVwOFa1D/Ty24Ws1npBWkDYEV9BqZrsDxVrVkrrU= -github.com/onsi/ginkgo/v2 v2.8.1/go.mod h1:N1/NbDngAFcSLdyZ+/aYTYGSlq9qMCS/cNKGJjy+csc= -github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= +github.com/onsi/ginkgo/v2 v2.8.3 h1:RpbK1G8nWPNaCVFBWsOGnEQQGgASi6b8fxcWBvDYjxQ= +github.com/onsi/ginkgo/v2 v2.8.3/go.mod h1:6OaUA8BCi0aZfmzYT/q9AacwTzDpNbxILUT+TlBq6MY= +github.com/onsi/gomega v1.27.0 h1:QLidEla4bXUuZVFa4KX6JHCsuGgbi85LC/pCHrt/O08= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pierrec/lz4/v4 v4.1.14/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= @@ -125,10 +125,10 @@ github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= github.com/quic-go/qtls-go1-18 v0.2.0 h1:5ViXqBZ90wpUcZS0ge79rf029yx0dYB0McyPJwqqj7U= github.com/quic-go/qtls-go1-18 v0.2.0/go.mod h1:moGulGHK7o6O8lSPSZNoOwcLvJKJ85vVNc7oJFD65bc= -github.com/quic-go/qtls-go1-19 v0.2.0 h1:Cvn2WdhyViFUHoOqK52i51k4nDX8EwIh5VJiVM4nttk= -github.com/quic-go/qtls-go1-19 v0.2.0/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= -github.com/quic-go/qtls-go1-20 v0.1.0 h1:d1PK3ErFy9t7zxKsG3NXBJXZjp/kMLoIb3y/kV54oAI= -github.com/quic-go/qtls-go1-20 v0.1.0/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= +github.com/quic-go/qtls-go1-19 v0.2.1 h1:aJcKNMkH5ASEJB9FXNeZCyTEIHU1J7MmHyz1Q1TSG1A= +github.com/quic-go/qtls-go1-19 v0.2.1/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= +github.com/quic-go/qtls-go1-20 v0.1.1 h1:KbChDlg82d3IHqaj2bn6GfKRj84Per2VGf5XV3wSwQk= +github.com/quic-go/qtls-go1-20 v0.1.1/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= github.com/quic-go/quic-go v0.32.0 h1:lY02md31s1JgPiiyfqJijpu/UX/Iun304FI3yUqX7tA= github.com/quic-go/quic-go v0.32.0/go.mod h1:/fCsKANhQIeD5l76c2JFU+07gVE3KaA0FP+0zMWwfwo= github.com/shirou/gopsutil/v3 v3.21.8 h1:nKct+uP0TV8DjjNiHanKf8SAuub+GNsbrOtM9Nl9biA= @@ -155,8 +155,8 @@ github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ= github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= github.com/u-root/uio v0.0.0-20221213070652-c3537552635f/go.mod h1:IogEAUBXDEwX7oR/BMmCctShYs80ql4hF0ySdzGxf7E= -github.com/u-root/uio v0.0.0-20230215032506-9aa6f7e2d72c h1:PHoGTnweZP+KIg/8Zc6+iOesrIF5yHkpb4GBDxHm7yE= -github.com/u-root/uio v0.0.0-20230215032506-9aa6f7e2d72c/go.mod h1:eLL9Nub3yfAho7qB0MzZizFhTU2QkLeoVsWdHtDW264= +github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923 h1:tHNk7XK9GkmKUR6Gh8gVBKXc2MVSZ4G/NnWLtzw4gNA= +github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923/go.mod h1:eLL9Nub3yfAho7qB0MzZizFhTU2QkLeoVsWdHtDW264= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= diff --git a/internal/filtering/servicelist.go b/internal/filtering/servicelist.go index 93fe79cd8dd..e46b9383319 100644 --- a/internal/filtering/servicelist.go +++ b/internal/filtering/servicelist.go @@ -1171,6 +1171,16 @@ var blockedServices = []blockedService{{ "||zuckerberg.com^", "||zuckerberg.net^", }, +}, { + ID: "gog", + Name: "GOG", + IconSVG: []byte(""), + Rules: []string{ + "||gog-cdn-lumen.secure2.footprint.net^", + "||gog-statics.com^", + "||gog.com^", + "||gogalaxy.com^", + }, }, { ID: "hulu", Name: "Hulu", @@ -1291,6 +1301,24 @@ var blockedServices = []blockedService{{ "||lolstatic.com^", "||lolusercontent.com^", }, +}, { + ID: "line", + Name: "LINE", + IconSVG: []byte(""), + Rules: []string{ + "||gcld-line.com^", + "||lin.ee^", + "||line-apps-beta.com^", + "||line-apps-rc.com^", + "||line-apps.com^", + "||line-cdn.net^", + "||line-scdn.net^", + "||line.me^", + "||line.naver.jp^", + "||linecorp.com^", + "||linemyshop.com^", + "||lineshoppingseller.com^", + }, }, { ID: "mail_ru", Name: "Mail.ru", @@ -1363,7 +1391,6 @@ var blockedServices = []blockedService{{ "||mstdn.party^", "||mstdn.social^", "||muenchen.social^", - "||nerdculture.de^", "||newsie.social^", "||noc.social^", "||norden.social^", @@ -1382,6 +1409,7 @@ var blockedServices = []blockedService{{ "||social.anoxinon.de^", "||social.cologne^", "||social.dev-wiki.de^", + "||social.linux.pizza^", "||social.politicaconciencia.org^", "||social.vivaldi.net^", "||sself.co^", diff --git a/internal/tools/go.mod b/internal/tools/go.mod index 0b4e66297b9..d0f5245c118 100644 --- a/internal/tools/go.mod +++ b/internal/tools/go.mod @@ -9,9 +9,9 @@ require ( github.com/kisielk/errcheck v1.6.3 github.com/kyoh86/looppointer v0.2.1 github.com/securego/gosec/v2 v2.15.0 - golang.org/x/tools v0.6.0 - golang.org/x/vuln v0.0.0-20230213165600-1a019b0c7f30 - honnef.co/go/tools v0.4.1 + golang.org/x/tools v0.6.1-0.20230217175706-3102dad5faf9 + golang.org/x/vuln v0.0.0-20230217204342-b91abcc5ae3c + honnef.co/go/tools v0.4.2 mvdan.cc/gofumpt v0.4.0 mvdan.cc/unparam v0.0.0-20230125043941-70a0ce6e7b95 ) diff --git a/internal/tools/go.sum b/internal/tools/go.sum index bc821c41a91..e3c5d1aeefc 100644 --- a/internal/tools/go.sum +++ b/internal/tools/go.sum @@ -97,10 +97,10 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20201007032633-0806396f153e/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= -golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/vuln v0.0.0-20230213165600-1a019b0c7f30 h1:Q4B8LhSjZGto/+P5REBb4N51ec2H4efRqjBIeJ6nv/Y= -golang.org/x/vuln v0.0.0-20230213165600-1a019b0c7f30/go.mod h1:cBP4HMKv0X+x96j8IJWCKk0eqpakBmmHjKGSSC0NaYE= +golang.org/x/tools v0.6.1-0.20230217175706-3102dad5faf9 h1:IuFp2CklNBim6OdHXn/1P4VoeKt5pA2jcDKWlboqtlQ= +golang.org/x/tools v0.6.1-0.20230217175706-3102dad5faf9/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/vuln v0.0.0-20230217204342-b91abcc5ae3c h1:7/jJkMpaKZMxdyOQ7IP7aPbJQaDk4cOUxtXtWHQ1cSk= +golang.org/x/vuln v0.0.0-20230217204342-b91abcc5ae3c/go.mod h1:LTLnfk/dpXDNKsX6aCg/cI4LyCVnTyrQhgV/yLJuly0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -109,8 +109,8 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.4.1 h1:HPeloSr0mLOEMOkhT9Au5aeki44kvP6ka3v1xIsM6Zo= -honnef.co/go/tools v0.4.1/go.mod h1:36ZgoUOrqOk1GxwHhyryEkq8FQWkUO2xGuSMhUCcdvA= +honnef.co/go/tools v0.4.2 h1:6qXr+R5w+ktL5UkwEbPp+fEvfyoMPche6GkOpGHZcLc= +honnef.co/go/tools v0.4.2/go.mod h1:36ZgoUOrqOk1GxwHhyryEkq8FQWkUO2xGuSMhUCcdvA= mvdan.cc/gofumpt v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM= mvdan.cc/gofumpt v0.4.0/go.mod h1:PljLOHDeZqgS8opHRKLzp2It2VBuSdteAgqUfzMTxlQ= mvdan.cc/unparam v0.0.0-20230125043941-70a0ce6e7b95 h1:n/xhncJPSt0YzfOhnyn41XxUdrWQNgmLBG72FE27Fqw= diff --git a/scripts/make/Dockerfile b/scripts/make/Dockerfile index a940a155afd..848c21229dd 100644 --- a/scripts/make/Dockerfile +++ b/scripts/make/Dockerfile @@ -1,6 +1,6 @@ # A docker file for scripts/make/build-docker.sh. -FROM alpine:3.16 +FROM alpine:3.17 ARG BUILD_DATE ARG VERSION From 3a0b27e7e89e65378354feb08346a7fec24aa422 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Wed, 22 Feb 2023 12:13:07 +0300 Subject: [PATCH 5/5] Pull request 1749: 5522-fix-stat-sorting Updates #5522. Squashed commit of the following: commit dd3481cccf09f78fd85904cb69b9031371996f54 Author: Ainar Garipov Date: Tue Feb 21 20:14:29 2023 +0300 stats: fix sorting --- internal/stats/unit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/stats/unit.go b/internal/stats/unit.go index 5a5ada4f964..bf6eaf0833b 100644 --- a/internal/stats/unit.go +++ b/internal/stats/unit.go @@ -181,7 +181,7 @@ func convertMapToSlice(m map[string]uint64, max int) (s []countPair) { } slices.SortFunc(s, func(a, b countPair) (sortsBefore bool) { - return a.Count < b.Count + return a.Count > b.Count }) if max > len(s) { max = len(s)