diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ea50f60b2..ce673f173 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,7 +1,7 @@ name: Build 'env': - 'GO_VERSION': '1.20.12' + 'GO_VERSION': '1.21.7' 'on': 'push': diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 98facfa25..24aed319e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,7 +1,7 @@ 'name': Docker 'env': - 'GO_VERSION': '1.20.12' + 'GO_VERSION': '1.21.7' 'on': 'push': diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 347191b94..ae523b2f9 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,7 +1,7 @@ 'name': 'lint' 'env': - 'GO_VERSION': '1.20.12' + 'GO_VERSION': '1.21.7' 'on': 'push': diff --git a/Makefile b/Makefile index 3a1389559..60699d1d8 100644 --- a/Makefile +++ b/Makefile @@ -4,19 +4,27 @@ # See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html. .POSIX: -# 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. +# 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: 4 + +# 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} BRANCH = $$( git rev-parse --abbrev-ref HEAD ) +DIST_DIR = build GOAMD64 = v1 GOPROXY = https://goproxy.cn|https://proxy.golang.org|direct -DIST_DIR = build +GOTOOLCHAIN = go1.21.7 OUT = dnsproxy RACE = 0 REVISION = $$( git rev-parse --short HEAD ) @@ -29,6 +37,7 @@ ENV = env\ GO="$(GO.MACRO)"\ GOAMD64='$(GOAMD64)'\ GOPROXY='$(GOPROXY)'\ + GOTOOLCHAIN='$(GOTOOLCHAIN)'\ OUT='$(OUT)'\ PATH="$${PWD}/bin:$$( "$(GO.MACRO)" env GOPATH )/bin:$${PATH}"\ RACE='$(RACE)'\ @@ -52,6 +61,8 @@ go-lint: ; $(ENV) "$(SHELL)" ./scripts/make/go-lint.sh go-test: ; $(ENV) RACE='1' "$(SHELL)" ./scripts/make/go-test.sh go-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-tools.sh +go-upd-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-upd-tools.sh + go-check: go-tools go-lint go-test # A quick check to make sure that all operating systems relevant to the diff --git a/README.md b/README.md index f636d2514..e5db2d1dd 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ There are several options how to install `dnsproxy`. ## How to build -You will need Go v1.20 or later. +You will need Go v1.21 or later. ```shell $ make build diff --git a/bamboo-specs/bamboo.yaml b/bamboo-specs/bamboo.yaml index 8dfc3a3fc..efec70f2b 100644 --- a/bamboo-specs/bamboo.yaml +++ b/bamboo-specs/bamboo.yaml @@ -10,7 +10,7 @@ # exact patch version as opposed to a minor one to make sure that this exact # version is actually used and not whatever the docker daemon on the CI has # cached a few months ago. - 'dockerGo': 'golang:1.20.12' + 'dockerGo': 'golang:1.21.7' 'maintainer': 'Adguard Go Team' 'name': 'dnsproxy' diff --git a/go.mod b/go.mod index 7de938790..49e9c3b62 100644 --- a/go.mod +++ b/go.mod @@ -1,21 +1,21 @@ module github.com/AdguardTeam/dnsproxy -go 1.20 +go 1.21.7 require ( - github.com/AdguardTeam/golibs v0.19.0 + github.com/AdguardTeam/golibs v0.20.0 github.com/ameshkov/dnscrypt/v2 v2.2.7 github.com/ameshkov/dnsstamps v1.0.3 github.com/beefsack/go-rate v0.0.0-20220214233405-116f4ca011a0 github.com/bluele/gcache v0.0.2 github.com/jessevdk/go-flags v1.5.0 - github.com/miekg/dns v1.1.56 + github.com/miekg/dns v1.1.58 github.com/patrickmn/go-cache v2.1.0+incompatible - github.com/quic-go/quic-go v0.39.1 + github.com/quic-go/quic-go v0.41.0 github.com/stretchr/testify v1.8.4 - golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 - golang.org/x/net v0.19.0 - golang.org/x/sys v0.15.0 + golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 + golang.org/x/net v0.20.0 + golang.org/x/sys v0.16.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -24,18 +24,17 @@ require ( github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect - github.com/google/pprof v0.0.0-20230912144702-c363fe2c2ed8 // indirect + github.com/google/pprof v0.0.0-20240130152714-0ed6a68c8d9e // indirect github.com/kr/text v0.2.0 // indirect github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect - github.com/onsi/ginkgo/v2 v2.12.1 // indirect + github.com/onsi/ginkgo/v2 v2.15.0 // 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-20 v0.3.4 // indirect - go.uber.org/mock v0.3.0 // indirect - golang.org/x/crypto v0.16.0 // indirect - golang.org/x/mod v0.14.0 // indirect + go.uber.org/mock v0.4.0 // indirect + golang.org/x/crypto v0.18.0 // indirect + golang.org/x/mod v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.16.0 // indirect + golang.org/x/tools v0.17.0 // indirect gonum.org/v1/gonum v0.14.0 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect ) diff --git a/go.sum b/go.sum index 7d0876d13..143d378ca 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/AdguardTeam/golibs v0.19.0 h1:y/x+Xn3pDg1ZfQ+QEZapPJqaeVYUIMp/EODMtVhn7PM= -github.com/AdguardTeam/golibs v0.19.0/go.mod h1:3WunclLLfrVAq7fYQRhd6f168FHOEMssnipVXCxDL/w= +github.com/AdguardTeam/golibs v0.20.0 h1:A9FIdYq7wUKhFYy3z+YZ/Aw5oFUYgW+xgaVAJ0pnnPY= +github.com/AdguardTeam/golibs v0.20.0/go.mod h1:3WunclLLfrVAq7fYQRhd6f168FHOEMssnipVXCxDL/w= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635 h1:52m0LGchQBBVqJRyYYufQuIbVqRawmubW3OFGqK1ekw= @@ -16,61 +16,65 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/pprof v0.0.0-20230912144702-c363fe2c2ed8 h1:gpptm606MZYGaMHMsB4Srmb6EbW/IVHnt04rcMXnkBQ= -github.com/google/pprof v0.0.0-20230912144702-c363fe2c2ed8/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/pprof v0.0.0-20240130152714-0ed6a68c8d9e h1:E+3PBMCXn0ma79O7iCrne0iUpKtZ7rIcZvoz+jNtNtw= +github.com/google/pprof v0.0.0-20240130152714-0ed6a68c8d9e/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE= -github.com/miekg/dns v1.1.56/go.mod h1:cRm6Oo2C8TY9ZS/TqsSrseAcncm74lfK5G+ikN2SWWY= +github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4= +github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY= 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.12.1 h1:uHNEO1RP2SpuZApSkel9nEh1/Mu+hmQe7Q+Pepg5OYA= -github.com/onsi/ginkgo/v2 v2.12.1/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= +github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= +github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= +github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= 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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 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-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg= -github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.39.1 h1:d/m3oaN/SD2c+f7/yEjZxe2zEVotXprnrCCJ2y/ZZFE= -github.com/quic-go/quic-go v0.39.1/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q= +github.com/quic-go/quic-go v0.41.0 h1:aD8MmHfgqTURWNJy48IYFg2OnxwHT3JL7ahGs73lb4k= +github.com/quic-go/quic-go v0.41.0/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo= -go.uber.org/mock v0.3.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 h1:+iq7lrkxmFNBM7xx+Rae2W6uyPfhPeDWD+n+JgppptE= -golang.org/x/exp v0.0.0-20231219180239-dc181d75b848/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo= +golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= +golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= -golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= +golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= gonum.org/v1/gonum v0.14.0 h1:2NiG67LD1tEH0D7kM+ps2V+fXmsAnpUeec7n8tcr4S0= gonum.org/v1/gonum v0.14.0/go.mod h1:AoWeoz0becf9QMWtE8iWXNXc27fK4fNeHNf/oMejGfU= google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/bootstrap/bootstrap.go b/internal/bootstrap/bootstrap.go index ae08de9d1..4e897fe2c 100644 --- a/internal/bootstrap/bootstrap.go +++ b/internal/bootstrap/bootstrap.go @@ -8,13 +8,13 @@ import ( "net" "net/netip" "net/url" + "slices" "time" proxynetutil "github.com/AdguardTeam/dnsproxy/internal/netutil" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/netutil" - "golang.org/x/exp/slices" ) // Network is a network type for use in [Resolver]'s methods. diff --git a/internal/bootstrap/resolver.go b/internal/bootstrap/resolver.go index 9891adc25..bc2dece64 100644 --- a/internal/bootstrap/resolver.go +++ b/internal/bootstrap/resolver.go @@ -4,11 +4,11 @@ import ( "context" "net" "net/netip" + "slices" "time" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" - "golang.org/x/exp/slices" ) // Resolver resolves the hostnames to IP addresses. Note, that [net.Resolver] diff --git a/internal/netutil/netutil.go b/internal/netutil/netutil.go index 21faae213..dd9bf8866 100644 --- a/internal/netutil/netutil.go +++ b/internal/netutil/netutil.go @@ -7,9 +7,8 @@ package netutil import ( "net/netip" + "slices" "strings" - - "golang.org/x/exp/slices" ) // PreferIPv4 compares two addresses, preferring IPv4 addresses over IPv6 ones. diff --git a/internal/netutil/netutil_test.go b/internal/netutil/netutil_test.go index ae7906eb1..7bbf3f84a 100644 --- a/internal/netutil/netutil_test.go +++ b/internal/netutil/netutil_test.go @@ -2,11 +2,11 @@ package netutil_test import ( "net/netip" + "slices" "testing" "github.com/AdguardTeam/dnsproxy/internal/netutil" "github.com/stretchr/testify/assert" - "golang.org/x/exp/slices" ) func TestSortNetIPAddrs(t *testing.T) { diff --git a/internal/tools/go.mod b/internal/tools/go.mod index 76a2c55b5..33e8143ea 100644 --- a/internal/tools/go.mod +++ b/internal/tools/go.mod @@ -1,34 +1,34 @@ module github.com/AdguardTeam/dnsproxy/internal/tools -go 1.20 +go 1.21.7 require ( github.com/fzipp/gocyclo v0.6.0 github.com/golangci/misspell v0.4.1 github.com/gordonklaus/ineffassign v0.1.0 - github.com/kisielk/errcheck v1.6.3 + github.com/kisielk/errcheck v1.7.0 github.com/kyoh86/looppointer v0.2.1 github.com/securego/gosec/v2 v2.18.2 github.com/uudashr/gocognit v1.1.2 - golang.org/x/tools v0.16.0 - golang.org/x/vuln v1.0.1 + golang.org/x/tools v0.17.0 + golang.org/x/vuln v1.0.4 honnef.co/go/tools v0.4.6 - mvdan.cc/gofumpt v0.5.0 - mvdan.cc/unparam v0.0.0-20230917202934-3ee2d22f45fb + mvdan.cc/gofumpt v0.6.0 + mvdan.cc/unparam v0.0.0-20240104100049-c549a3470d14 ) require ( github.com/BurntSushi/toml v1.3.2 // indirect - github.com/ccojocar/zxcvbn-go v1.0.1 // indirect + github.com/ccojocar/zxcvbn-go v1.0.2 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/uuid v1.4.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/gookit/color v1.5.4 // indirect github.com/kyoh86/nolint v0.0.1 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect - golang.org/x/exp/typeparams v0.0.0-20231127185646-65229373498e // indirect - golang.org/x/mod v0.14.0 // indirect - golang.org/x/sync v0.5.0 // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/exp/typeparams v0.0.0-20240205201215-2c58cdc269a3 // indirect + golang.org/x/mod v0.15.0 // indirect + golang.org/x/sync v0.6.0 // indirect + golang.org/x/sys v0.17.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/internal/tools/go.sum b/internal/tools/go.sum index 82c69078d..450eea75e 100644 --- a/internal/tools/go.sum +++ b/internal/tools/go.sum @@ -1,41 +1,55 @@ github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/ccojocar/zxcvbn-go v1.0.1 h1:+sxrANSCj6CdadkcMnvde/GWU1vZiiXRbqYSCalV4/4= -github.com/ccojocar/zxcvbn-go v1.0.1/go.mod h1:g1qkXtUSvHP8lhHp5GrSmTz6uWALGRMQdw6Qnz/hi60= +github.com/ccojocar/zxcvbn-go v1.0.2 h1:na/czXU8RrhXO4EZme6eQJLR4PzcGsahsBOAwU6I3Vg= +github.com/ccojocar/zxcvbn-go v1.0.2/go.mod h1:g1qkXtUSvHP8lhHp5GrSmTz6uWALGRMQdw6Qnz/hi60= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/golangci/misspell v0.4.1 h1:+y73iSicVy2PqyX7kmUefHusENlrP9YwuHZHPLGQj/g= github.com/golangci/misspell v0.4.1/go.mod h1:9mAN1quEo3DlpbaIKKyEvRxK1pwqR9s/Sea1bJCtlNI= github.com/google/go-cmdtest v0.4.1-0.20220921163831-55ab3332a786 h1:rcv+Ippz6RAtvaGgKxc+8FQIpxHgsF+HBzPyYL2cyVU= +github.com/google/go-cmdtest v0.4.1-0.20220921163831-55ab3332a786/go.mod h1:apVn/GCasLZUVpAJ6oWAuyP7Ne7CEsQbTnc0plM3m+o= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= github.com/gordonklaus/ineffassign v0.1.0 h1:y2Gd/9I7MdY1oEIt+n+rowjBNDcLQq3RsH5hwJd0f9s= github.com/gordonklaus/ineffassign v0.1.0/go.mod h1:Qcp2HIAYhR7mNUVSIxZww3Guk4it82ghYcEXIAk+QT0= -github.com/kisielk/errcheck v1.6.3 h1:dEKh+GLHcWm2oN34nMvDzn1sqI0i0WxPvrgiJA5JuM8= -github.com/kisielk/errcheck v1.6.3/go.mod h1:nXw/i/MfnvRHqXa7XXmQMUB0oNFGuBrNI8d8NLy0LPw= +github.com/kisielk/errcheck v1.7.0 h1:+SbscKmWJ5mOK/bO1zS60F5I9WwZDWOfRsC4RwfwRV0= +github.com/kisielk/errcheck v1.7.0/go.mod h1:1kLL+jV4e+CFfueBmI1dSK2ADDyQnlrnrY/FqKluHJQ= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kyoh86/looppointer v0.2.1 h1:Jx9fnkBj/JrIryBLMTYNTj9rvc2SrPS98Dg0w7fxdJg= github.com/kyoh86/looppointer v0.2.1/go.mod h1:q358WcM8cMWU+5vzqukvaZtnJi1kw/MpRHQm3xvTrjw= github.com/kyoh86/nolint v0.0.1 h1:GjNxDEkVn2wAxKHtP7iNTrRxytRZ1wXxLV5j4XzGfRU= github.com/kyoh86/nolint v0.0.1/go.mod h1:1ZiZZ7qqrZ9dZegU96phwVcdQOMKIqRzFJL3ewq9gtI= github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= +github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= github.com/onsi/gomega v1.28.1 h1:MijcGUbfYuznzK/5R4CPNoUP/9Xvuo20sXfEm6XxoTA= +github.com/onsi/gomega v1.28.1/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/securego/gosec/v2 v2.18.2 h1:DkDt3wCiOtAHf1XkiXZBhQ6m6mK/b9T/wD257R3/c+I= github.com/securego/gosec/v2 v2.18.2/go.mod h1:xUuqSF6i0So56Y2wwohWAmB07EdBkUN6crbLlHwbyJs= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/uudashr/gocognit v1.1.2 h1:l6BAEKJqQH2UpKAPKdMfZf5kE4W/2xk8pfU1OVLvniI= github.com/uudashr/gocognit v1.1.2/go.mod h1:aAVdLURqcanke8h3vg35BC++eseDm66Z7KmchI5et4k= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= @@ -49,26 +63,26 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= -golang.org/x/exp/typeparams v0.0.0-20231127185646-65229373498e h1:Iel2aGgaO80fSb1N54L7SE6XMeVvYy6caKt8u/5LvR8= -golang.org/x/exp/typeparams v0.0.0-20231127185646-65229373498e/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= +golang.org/x/exp/typeparams v0.0.0-20240205201215-2c58cdc269a3 h1:1hsZWSQgrpqFJbqlg8HNhQ2/U/7IQELXYWTjuCfHNcM= +golang.org/x/exp/typeparams v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -79,24 +93,24 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 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.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= -golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= -golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= -golang.org/x/vuln v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU= -golang.org/x/vuln v1.0.1/go.mod h1:bb2hMwln/tqxg32BNY4CcxHWtHXuYa3SbIBmtsyjxtM= +golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= +golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/vuln v1.0.4 h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I= +golang.org/x/vuln v1.0.4/go.mod h1:NbJdUQhX8jY++FtuhrXs2Eyx0yePo9pF7nPlIjo9aaQ= 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= @@ -106,7 +120,7 @@ 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.6 h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8= honnef.co/go/tools v0.4.6/go.mod h1:+rnGS1THNh8zMwnd2oVOTL9QF6vmfyG6ZXBULae2uc0= -mvdan.cc/gofumpt v0.5.0 h1:0EQ+Z56k8tXjj/6TQD25BFNKQXpCvT0rnansIc7Ug5E= -mvdan.cc/gofumpt v0.5.0/go.mod h1:HBeVDtMKRZpXyxFciAirzdKklDlGu8aAy1wEbH5Y9js= -mvdan.cc/unparam v0.0.0-20230917202934-3ee2d22f45fb h1:xiF91GJnDSbyPdiZB5d52N2VpZfGhjM4Ji75cjzuooQ= -mvdan.cc/unparam v0.0.0-20230917202934-3ee2d22f45fb/go.mod h1:ZzZjEpJDOmx8TdVU6umamY3Xy0UAQUI2DHbf05USVbI= +mvdan.cc/gofumpt v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo= +mvdan.cc/gofumpt v0.6.0/go.mod h1:4L0wf+kgIPZtcCWXynNS2e6bhmj73umwnuXSZarixzA= +mvdan.cc/unparam v0.0.0-20240104100049-c549a3470d14 h1:zCr3iRRgdk5eIikZNDphGcM6KGVTx3Yu+/Uu9Es254w= +mvdan.cc/unparam v0.0.0-20240104100049-c549a3470d14/go.mod h1:ZzZjEpJDOmx8TdVU6umamY3Xy0UAQUI2DHbf05USVbI= diff --git a/main.go b/main.go index b6f23706f..0cce681da 100644 --- a/main.go +++ b/main.go @@ -191,7 +191,11 @@ type Options struct { // If true, all AAAA requests will be replied with NoError RCode and empty answer IPv6Disabled bool `yaml:"ipv6-disabled" long:"ipv6-disabled" description:"If specified, all AAAA requests will be replied with NoError RCode and empty answer" optional:"yes" optional-value:"true"` - // Transform responses that contain at least one of the given IP addresses into NXDOMAIN + // Transform responses that contain at least one of the given IP addresses + // into NXDOMAIN. + // + // TODO(a.garipov): Find a way to use [netutil.Prefix]. Currently, package + // go-flags doesn't support text unmarshalers. BogusNXDomain []string `yaml:"bogus-nxdomain" long:"bogus-nxdomain" description:"Transform the responses containing at least a single IP that matches specified addresses and CIDRs into NXDOMAIN. Can be specified multiple times."` // UDP buffer size value diff --git a/proxy/cache.go b/proxy/cache.go index dec6a80ef..ba6c49208 100644 --- a/proxy/cache.go +++ b/proxy/cache.go @@ -5,6 +5,7 @@ import ( "encoding/binary" "math" "net" + "slices" "strings" "sync" "time" @@ -14,7 +15,6 @@ import ( "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/mathutil" "github.com/miekg/dns" - "golang.org/x/exp/slices" ) // defaultCacheSize is the size of cache in bytes by default. diff --git a/proxy/proxy.go b/proxy/proxy.go index 151b79955..91fe49da3 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -9,6 +9,7 @@ import ( "net" "net/http" "net/netip" + "slices" "sync" "sync/atomic" "time" @@ -26,7 +27,6 @@ import ( "github.com/quic-go/quic-go" "github.com/quic-go/quic-go/http3" "golang.org/x/exp/rand" - "golang.org/x/exp/slices" ) const ( diff --git a/proxy/proxycache.go b/proxy/proxycache.go index 391990f86..f5d6a9792 100644 --- a/proxy/proxycache.go +++ b/proxy/proxycache.go @@ -2,9 +2,9 @@ package proxy import ( "net" + "slices" "github.com/AdguardTeam/golibs/log" - "golang.org/x/exp/slices" ) // cacheForContext returns cache object for the given context. diff --git a/proxy/ratelimit.go b/proxy/ratelimit.go index b2f07dc5c..52af63a1b 100644 --- a/proxy/ratelimit.go +++ b/proxy/ratelimit.go @@ -2,12 +2,12 @@ package proxy import ( "net/netip" + "slices" "time" "github.com/AdguardTeam/golibs/log" rate "github.com/beefsack/go-rate" gocache "github.com/patrickmn/go-cache" - "golang.org/x/exp/slices" ) func (p *Proxy) limiterForIP(ip string) interface{} { diff --git a/proxy/upstreams.go b/proxy/upstreams.go index 241d2f9cc..3afc6e0f1 100644 --- a/proxy/upstreams.go +++ b/proxy/upstreams.go @@ -3,6 +3,7 @@ package proxy import ( "fmt" "io" + "slices" "strings" "github.com/AdguardTeam/dnsproxy/upstream" @@ -10,7 +11,6 @@ import ( "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/netutil" "github.com/AdguardTeam/golibs/stringutil" - "golang.org/x/exp/slices" ) // UpstreamConfig is a wrapper for a list of default upstreams, a map of diff --git a/scripts/make/go-lint.sh b/scripts/make/go-lint.sh index 380bd2775..ca3c73335 100644 --- a/scripts/make/go-lint.sh +++ b/scripts/make/go-lint.sh @@ -30,33 +30,6 @@ set -f -u -# Warnings - -go_version="$( "${GO:-go}" version )" -readonly go_version - -go_min_version='go1.20.12' -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. -for example: - - export GO='${go_min_version}' -" -readonly go_min_version go_version_msg - -case "$go_version" -in -('go version'*"$go_min_version"*) - # Go on. - ;; -(*) - echo "$go_version_msg" 1>&2 - ;; -esac - - - # Simple analyzers # blocklist_imports is a simple check against unwanted packages. The following @@ -74,18 +47,20 @@ esac # # See https://github.com/golang/go/issues/45200. # -# * Package sort is replaced by golang.org/x/exp/slices. +# * Package sort is replaced by package slices. # # * Package unsafe is… unsafe. # +# * Package golang.org/x/exp/slices has been moved into stdlib. +# # * Package golang.org/x/net/context has been moved into stdlib. # # Currently, the only standard exception are files generated from protobuf # schemas, which use package reflect. If your project needs more exceptions, # add and document them. # -# TODO(a.garipov): Add deprecated packages golang.org/x/exp/maps and -# golang.org/x/exp/slices once all projects switch to Go 1.21. +# TODO(a.garipov): Add deprecated package golang.org/x/exp/maps once all +# projects switch to Go 1.22. blocklist_imports() { git grep\ -e '[[:space:]]"errors"$'\ @@ -94,6 +69,7 @@ blocklist_imports() { -e '[[:space:]]"reflect"$'\ -e '[[:space:]]"sort"$'\ -e '[[:space:]]"unsafe"$'\ + -e '[[:space:]]"golang.org/x/exp/slices"$'\ -e '[[:space:]]"golang.org/x/net/context"$'\ -n\ -- '*.go'\ diff --git a/scripts/make/go-upd-tools.sh b/scripts/make/go-upd-tools.sh new file mode 100644 index 000000000..7486661d6 --- /dev/null +++ b/scripts/make/go-upd-tools.sh @@ -0,0 +1,33 @@ +#!/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 + +if [ "$verbose" -gt '1' ] +then + env + set -x + x_flags='-x=1' +elif [ "$verbose" -gt '0' ] +then + set -x + x_flags='-x=0' +else + set +x + x_flags='-x=0' +fi +readonly x_flags + +set -e -f -u + +go="${GO:-go}" +readonly go + +cd ./internal/tools/ +"$go" get -u +"$go" mod tidy diff --git a/scripts/make/helper.sh b/scripts/make/helper.sh index 6d7fe778f..b814fac00 100644 --- a/scripts/make/helper.sh +++ b/scripts/make/helper.sh @@ -47,7 +47,7 @@ trap not_found EXIT run_linter() ( set +e - if [ "$VERBOSE" -lt '2' ] + if [ "${VERBOSE:-0}" -lt '2' ] then set +x fi diff --git a/scripts/make/txt-lint.sh b/scripts/make/txt-lint.sh index bb9aadf3d..8312f585d 100644 --- a/scripts/make/txt-lint.sh +++ b/scripts/make/txt-lint.sh @@ -36,10 +36,7 @@ trailing_newlines() { readonly nl # NOTE: Adjust for your project. - # TODO(d.kolyshev): Remove "vendor" after moving out from vendor dir usage. - git ls-files\ - ':!vendor/*'\ - | while read -r f + git ls-files | while read -r f do if [ "$( tail -c -1 "$f" )" != "$nl" ] then @@ -52,10 +49,7 @@ trailing_newlines() { # trailing whitespace in plain-text files. trailing_whitespace() { # NOTE: Adjust for your project. - # TODO(d.kolyshev): Remove "vendor" after moving out from vendor dir usage. - git ls-files\ - ':!vendor/*'\ - | while read -r f + git ls-files | while read -r f do grep -e '[[:space:]]$' -n -- "$f"\ | sed -e "s:^:${f}\::" -e 's/ \+$/>>>&<< 0 { + err = stream.SetDeadline(time.Now().Add(p.timeout)) + if err != nil { + return nil, fmt.Errorf("setting deadline: %w", err) + } + } + _, err = stream.Write(proxyutil.AddPrefix(buf)) if err != nil { return nil, fmt.Errorf("failed to write to a QUIC stream: %w", err) } // The client MUST send the DNS query over the selected stream, and MUST - // indicate through the STREAM FIN mechanism that no further data will - // be sent on that stream. Note, that stream.Close() closes the - // write-direction of the stream, but does not prevent reading from it. + // indicate through the STREAM FIN mechanism that no further data will be + // sent on that stream. Note, that stream.Close() closes the write-direction + // of the stream, but does not prevent reading from it. err = stream.Close() if err != nil { log.Debug("dnsproxy: closing quic stream: %s", err) @@ -237,12 +242,6 @@ func (p *dnsOverQUIC) exchangeQUIC(req *dns.Msg) (resp *dns.Msg, err error) { return p.readMsg(stream) } -// shouldRetry checks what error we received and decides whether it is required -// to re-open the connection and retry sending the request. -func (p *dnsOverQUIC) shouldRetry(err error) (ok bool) { - return isQUICRetryError(err) -} - // getBytesPool returns (creates if needed) a pool we store byte buffers in. func (p *dnsOverQUIC) getBytesPool() (pool *sync.Pool) { p.bytesPoolMu.Lock() @@ -425,6 +424,8 @@ func (p *dnsOverQUIC) readMsg(stream quic.Stream) (m *dns.Msg, err error) { return nil, fmt.Errorf("reading response from %s: %w", p.addr, err) } + stream.CancelRead(0) + // All DNS messages (queries and responses) sent over DoQ connections MUST // be encoded as a 2-octet length field followed by the message content as // specified in [RFC1035]. @@ -504,6 +505,11 @@ func isQUICRetryError(err error) (ok bool) { return true } + if errors.Is(err, os.ErrDeadlineExceeded) { + // A timeout that could happen when the server has been restarted. + return true + } + return false } diff --git a/upstream/quic_test.go b/upstream/doq_test.go similarity index 81% rename from upstream/quic_test.go rename to upstream/doq_test.go index cb82c5d34..3d9326d10 100644 --- a/upstream/quic_test.go +++ b/upstream/doq_test.go @@ -3,7 +3,6 @@ package upstream import ( "context" "crypto/tls" - "crypto/x509" "encoding/binary" "fmt" "io" @@ -14,6 +13,7 @@ import ( "time" "github.com/AdguardTeam/dnsproxy/proxyutil" + "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/testutil" "github.com/miekg/dns" @@ -23,18 +23,21 @@ import ( ) func TestUpstreamDoQ(t *testing.T) { - srv := startDoQServer(t, 0) - t.Cleanup(srv.Shutdown) + tlsConf, rootCAs := createServerTLSConfig(t, "127.0.0.1") + + srv := startDoQServer(t, tlsConf, 0) + testutil.CleanupAndRequireSuccess(t, srv.Shutdown) address := fmt.Sprintf("quic://%s", srv.addr) var lastState tls.ConnectionState opts := &Options{ - InsecureSkipVerify: true, VerifyConnection: func(state tls.ConnectionState) error { lastState = state return nil }, + RootCAs: rootCAs, + InsecureSkipVerify: true, } u, err := AddressToUpstream(address, opts) require.NoError(t, err) @@ -74,12 +77,20 @@ func TestUpstreamDoQ(t *testing.T) { } func TestUpstreamDoQ_serverRestart(t *testing.T) { + // Use the same tlsConf for all servers to preserve the data necessary for + // 0-RTT connections. + tlsConf, rootCAs := createServerTLSConfig(t, "127.0.0.1") + // Run the first server instance. - srv := startDoQServer(t, 0) + srv := startDoQServer(t, tlsConf, 0) // Create a DNS-over-QUIC upstream. address := fmt.Sprintf("quic://%s", srv.addr) - u, err := AddressToUpstream(address, &Options{InsecureSkipVerify: true, Timeout: time.Second}) + u, err := AddressToUpstream(address, &Options{ + InsecureSkipVerify: true, + Timeout: 250 * time.Millisecond, + RootCAs: rootCAs, + }) require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, u.Close) @@ -89,42 +100,46 @@ func TestUpstreamDoQ_serverRestart(t *testing.T) { // Now let's restart the server on the same address. _, portStr, err := net.SplitHostPort(srv.addr) require.NoError(t, err) + port, err := strconv.Atoi(portStr) require.NoError(t, err) // Shutdown the first server. - srv.Shutdown() + require.NoError(t, srv.Shutdown()) // Start the new one on the same port. - srv = startDoQServer(t, port) + srv = startDoQServer(t, tlsConf, port) // Check that everything works after restart. checkUpstream(t, u, address) // Stop the server again. - srv.Shutdown() + require.NoError(t, srv.Shutdown()) // Now try to send a message and make sure that it returns an error. _, err = u.Exchange(createTestMessage()) require.Error(t, err) // Start the server one more time. - srv = startDoQServer(t, port) - defer srv.Shutdown() + srv = startDoQServer(t, tlsConf, port) + testutil.CleanupAndRequireSuccess(t, srv.Shutdown) // Check that everything works after the second restart. checkUpstream(t, u, address) } func TestUpstreamDoQ_0RTT(t *testing.T) { - srv := startDoQServer(t, 0) - t.Cleanup(srv.Shutdown) + tlsConf, rootCAs := createServerTLSConfig(t, "127.0.0.1") + + srv := startDoQServer(t, tlsConf, 0) + testutil.CleanupAndRequireSuccess(t, srv.Shutdown) tracer := &quicTracer{} address := fmt.Sprintf("quic://%s", srv.addr) u, err := AddressToUpstream(address, &Options{ InsecureSkipVerify: true, QUICTracer: tracer.TracerForConnection, + RootCAs: rootCAs, }) require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, u.Close) @@ -166,12 +181,6 @@ func TestUpstreamDoQ_0RTT(t *testing.T) { // testDoHServer is an instance of a test DNS-over-QUIC server. type testDoQServer struct { - // tlsConfig is the TLS configuration that is used for this server. - tlsConfig *tls.Config - - // rootCAs is the pool with root certificates used by the test server. - rootCAs *x509.CertPool - // listener is the QUIC connections listener. listener *quic.EarlyListener @@ -180,21 +189,28 @@ type testDoQServer struct { } // Shutdown stops the test server. -func (s *testDoQServer) Shutdown() { - _ = s.listener.Close() +func (s *testDoQServer) Shutdown() (err error) { + return s.listener.Close() } // Serve serves DoQ requests. func (s *testDoQServer) Serve() { for { - conn, err := s.listener.Accept(context.Background()) - if err == quic.ErrServerClosed { - // Finish serving on ErrServerClosed error. - return - } - + var conn quic.EarlyConnection + var err error + func() { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + conn, err = s.listener.Accept(ctx) + }() if err != nil { - log.Debug("error while accepting a new connection: %v", err) + if errors.Is(err, quic.ErrServerClosed) { + log.Debug("test doq: accepting: %s", err) + } else { + log.Error("test doq: accepting: %s", err) + } + + return } go s.handleQUICConnection(conn) @@ -214,6 +230,8 @@ func (s *testDoQServer) handleQUICConnection(conn quic.EarlyConnection) { go func() { qErr := s.handleQUICStream(stream) if qErr != nil { + log.Error("test doq: handling from %s: %s", conn.RemoteAddr(), qErr) + _ = conn.CloseWithError(QUICCodeNoError, "") } }() @@ -231,6 +249,8 @@ func (s *testDoQServer) handleQUICStream(stream quic.Stream) (err error) { return err } + stream.CancelRead(0) + req := &dns.Msg{} packetLen := binary.BigEndian.Uint16(buf[:2]) err = req.Unpack(buf[2 : packetLen+2]) @@ -252,13 +272,12 @@ func (s *testDoQServer) handleQUICStream(stream quic.Stream) (err error) { } // startDoQServer starts a test DoQ server. -func startDoQServer(t *testing.T, port int) (s *testDoQServer) { - tlsConfig, rootCAs := createServerTLSConfig(t, "127.0.0.1") - tlsConfig.NextProtos = []string{NextProtoDQ} +func startDoQServer(t *testing.T, tlsConf *tls.Config, port int) (s *testDoQServer) { + tlsConf.NextProtos = []string{NextProtoDQ} listen, err := quic.ListenAddrEarly( fmt.Sprintf("127.0.0.1:%d", port), - tlsConfig, + tlsConf, &quic.Config{ // Necessary for 0-RTT. RequireAddressValidation: func(net.Addr) (ok bool) { @@ -270,10 +289,8 @@ func startDoQServer(t *testing.T, port int) (s *testDoQServer) { require.NoError(t, err) s = &testDoQServer{ - addr: listen.Addr().String(), - tlsConfig: tlsConfig, - rootCAs: rootCAs, - listener: listen, + addr: listen.Addr().String(), + listener: listen, } go s.Serve() diff --git a/upstream/hostsresolver.go b/upstream/hostsresolver.go index 75a2236ff..d41207055 100644 --- a/upstream/hostsresolver.go +++ b/upstream/hostsresolver.go @@ -5,11 +5,11 @@ import ( "fmt" "io/fs" "net/netip" + "slices" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/hostsfile" "github.com/AdguardTeam/golibs/log" - "golang.org/x/exp/slices" ) // HostsResolver is a [Resolver] that looks into system hosts files, see diff --git a/upstream/parallel.go b/upstream/parallel.go index 64f508b08..f27cce311 100644 --- a/upstream/parallel.go +++ b/upstream/parallel.go @@ -4,12 +4,12 @@ import ( "context" "fmt" "net/netip" + "slices" "time" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/miekg/dns" - "golang.org/x/exp/slices" ) const ( @@ -117,8 +117,7 @@ func ExchangeAll(ups []Upstream, req *dns.Msg) (res []ExchangeAllResult, err err } if len(errs) == upsNum { - // TODO(e.burkov): Use [errors.Join] in Go 1.20. - return res, errors.List("all upstreams failed to exchange", errs...) + return res, fmt.Errorf("all upstreams failed: %w", errors.Join(errs...)) } return slices.Clip(res), nil diff --git a/upstream/upstream_test.go b/upstream/upstream_test.go index c214f0cb2..193d7ba3f 100644 --- a/upstream/upstream_test.go +++ b/upstream/upstream_test.go @@ -9,17 +9,14 @@ import ( "crypto/x509/pkix" "encoding/pem" "fmt" - "io" "math/big" "net" "net/netip" "net/url" - "os" "sync" "testing" "time" - "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/netutil" "github.com/AdguardTeam/golibs/testutil" "github.com/ameshkov/dnsstamps" @@ -31,10 +28,7 @@ import ( // TODO(ameshkov): make tests here not depend on external servers. func TestMain(m *testing.M) { - // Disable logging in tests. - log.SetOutput(io.Discard) - - os.Exit(m.Run()) + testutil.DiscardLogOutput(m) } func TestUpstream_bootstrapTimeout(t *testing.T) {