Skip to content

Commit

Permalink
all: upd go & tools, imp code
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Nov 7, 2024
1 parent 99cdeca commit 7558664
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'name': 'build'

'env':
'GO_VERSION': '1.23.2'
'GO_VERSION': '1.23.3'

'on':
'push':
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'name': 'lint'

'env':
'GO_VERSION': '1.23.2'
'GO_VERSION': '1.23.3'

'on':
'push':
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ NOTE: Add new changes BELOW THIS COMMENT.

### Security

- Go version has been updated to prevent the possibility of exploiting the Go vulnerabilities fixed in [Go 1.23.2][go-1.23.2].
- Go version has been updated to prevent the possibility of exploiting the Go vulnerabilities fixed in [Go 1.23.3][go-1.23.3].

### Added

Expand All @@ -39,7 +39,7 @@ NOTE: Add new changes BELOW THIS COMMENT.
[#2]: https://github.com/AdguardTeam/AdGuardDNSClient/issues/2
[#3]: https://github.com/AdguardTeam/AdGuardDNSClient/issues/3

[go-1.23.2]: https://groups.google.com/g/golang-announce/c/NKEc8VT7Fz0
[go-1.23.3]: https://groups.google.com/g/golang-announce/c/X5KodEJYuqI
[go-59229]: https://github.com/golang/go/issues/59229

<!--
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DIST_DIR = dist
GOAMD64 = v1
GOPROXY = https://proxy.golang.org|direct
GOTELEMETRY = off
GOTOOLCHAIN = go1.23.2
GOTOOLCHAIN = go1.23.3
GPG_KEY = [email protected]
GPG_KEY_PASSPHRASE = not-a-real-password
MSI = 1
Expand Down
6 changes: 3 additions & 3 deletions bamboo-specs/bamboo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'key': 'DNSCLIENT'
'name': 'AdGuardDNSClient'
'variables':
'dockerGo': 'adguard/go-builder:1.23.2--1'
'dockerGo': 'adguard/go-builder:1.23.3--1'
'maintainer': 'Adguard Go Team'
'name': 'AdGuardDNSClient'
'channel': 'development'
Expand Down Expand Up @@ -361,7 +361,7 @@
# "candidate" pseudo-channel is used to generate version.
- '^rc-v[0-9]+\.[0-9]+\.[0-9]+':
'variables':
'dockerGo': 'adguard/go-builder:1.23.2-1'
'dockerGo': 'adguard/go-builder:1.23.3-1'
'channel': 'candidate'
'stages':
- 'Go Lint':
Expand Down Expand Up @@ -392,7 +392,7 @@
# Set the default release channel on the final branch to release, as
# these are the ones that actually get released.
'variables':
'dockerGo': 'adguard/go-builder:1.23.2--1'
'dockerGo': 'adguard/go-builder:1.23.3--1'
'channel': 'release'
'stages':
- 'Go Lint':
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/AdguardTeam/AdGuardDNSClient

go 1.23.2
go 1.23.3

require (
github.com/AdguardTeam/dnsproxy v0.73.3-0.20241004151328-c7c7b977a2a3
github.com/AdguardTeam/golibs v0.30.1
github.com/AdguardTeam/golibs v0.30.2
github.com/c2h5oh/datasize v0.0.0-20231215233829-aa82cc1e6500
github.com/miekg/dns v1.1.62
github.com/stretchr/testify v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/AdguardTeam/dnsproxy v0.73.3-0.20241004151328-c7c7b977a2a3 h1:IGXwBjdKDzUm007QzZyxSllMnkbdXe7K79x7JWcBW/E=
github.com/AdguardTeam/dnsproxy v0.73.3-0.20241004151328-c7c7b977a2a3/go.mod h1:356iHROxo+SOdBVifp1MXEh6qHyydtzGCcsQMfx+ZVs=
github.com/AdguardTeam/golibs v0.30.1 h1:/yv7dq2h7WXw/jTDxkE3FP9zHerRT+i03PZRHJX4fPU=
github.com/AdguardTeam/golibs v0.30.1/go.mod h1:FkwcNQEJoGsgDGXcalrVa/4gWbE68KsmE2guXWtBQUE=
github.com/AdguardTeam/golibs v0.30.2 h1:urU/NAyIvQOeArBqDmKCDpaRkfTCJ26uSiSuDMKQfuY=
github.com/AdguardTeam/golibs v0.30.2/go.mod h1:FkwcNQEJoGsgDGXcalrVa/4gWbE68KsmE2guXWtBQUE=
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=
Expand Down
28 changes: 15 additions & 13 deletions internal/agdcslog/agdcslog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package agdcslog_test
import (
"bytes"
"context"
"fmt"
"log/slog"
"strings"
"sync"
"testing"
"time"

"github.com/AdguardTeam/AdGuardDNSClient/internal/agdcslog"
"github.com/AdguardTeam/golibs/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand All @@ -27,21 +27,23 @@ type testLogger struct {
onClose func() (err error)
}

// newTestLogger returns a new mock logger with placeholder methods.
// newTestLogger returns a new mock logger with all its methods set to panic.
func newTestLogger() (l *testLogger) {
const err errors.Error = "not implemented"

notImplLog := func(_ string) (_ error) {
panic(err)
}

return &testLogger{
onInfo: notImplLog,
onWarning: notImplLog,
onError: notImplLog,
onDebug: notImplLog,
onInfo: func(msg string) (_ error) {
panic(fmt.Errorf("unexpected call to Info(%q)", msg))
},
onWarning: func(msg string) (_ error) {
panic(fmt.Errorf("unexpected call to Warning(%q)", msg))
},
onError: func(msg string) (_ error) {
panic(fmt.Errorf("unexpected call to Error(%q)", msg))
},
onDebug: func(msg string) (_ error) {
panic(fmt.Errorf("unexpected call to Debug(%q)", msg))
},
onClose: func() (_ error) {
panic(err)
panic(fmt.Errorf("unexpected call to Close"))
},
}
}
Expand Down
4 changes: 3 additions & 1 deletion internal/cmd/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/AdguardTeam/AdGuardDNSClient/internal/dnssvc"
"github.com/AdguardTeam/golibs/container"
"github.com/AdguardTeam/golibs/errors"
"github.com/AdguardTeam/golibs/logutil/slogutil"
"github.com/AdguardTeam/golibs/netutil"
)

Expand Down Expand Up @@ -71,7 +72,8 @@ func (c *dnsConfig) validate() (err error) {
// must be valid.
func (c *dnsConfig) toInternal(logger *slog.Logger) (conf *dnssvc.Config) {
return &dnssvc.Config{
Logger: logger,
BaseLogger: logger,
Logger: logger.With(slogutil.KeyPrefix, "dnssvc"),
// TODO(e.burkov): Consider making configurable.
PrivateSubnets: netutil.SubnetSetFunc(netutil.IsLocallyServed),
Cache: c.Cache.toInternal(),
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ func (c upstreamGroupsConfig) validate() (err error) {
return errors.Join(errs...)
}

// validateGroups appends the errors of validating groups within c to errs.
func (c upstreamGroupsConfig) validateGroups(errs []error) (withGroupErrs []error) {
// validateGroups appends the errors of validating groups within c to errs and
// returns the result.
func (c upstreamGroupsConfig) validateGroups(errs []error) (res []error) {
ms := matchSet{}
for _, name := range slices.Sorted(maps.Keys(c)) {
g := c[name]
Expand Down
7 changes: 5 additions & 2 deletions internal/dnssvc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import (

// Config is the configuration for [DNSService].
type Config struct {
// Logger is used as the base logger for the DNS service. It must not be
// nil.
// BaseLogger used as the base logger for the DNS subservices. It must not
// be nil.
BaseLogger *slog.Logger

// Logger is the logger for the DNS service. It must not be nil.
Logger *slog.Logger

// PrivateSubnets is the set of IP networks considered private. The PTR
Expand Down
4 changes: 2 additions & 2 deletions internal/dnssvc/dnssvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func New(conf *Config) (svc *DNSService, err error) {
}

svc = &DNSService{
logger: conf.Logger.With(slogutil.KeyPrefix, "dnssvc"),
logger: conf.Logger,
clientGetter: conf.ClientGetter,
clients: newClientStorage(clients),
}
Expand Down Expand Up @@ -107,7 +107,7 @@ func newProxyConfig(
}

return &proxy.Config{
Logger: conf.Logger.With(slogutil.KeyPrefix, "dnsproxy"),
Logger: conf.BaseLogger.With(slogutil.KeyPrefix, "dnsproxy"),
UpstreamMode: proxy.UpstreamModeLoadBalance,
UDPListenAddr: udp,
TCPListenAddr: tcp,
Expand Down
1 change: 1 addition & 0 deletions internal/dnssvc/dnssvc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ func TestDNSService(t *testing.T) {
// Create and start the service.

svc, err := dnssvc.New(&dnssvc.Config{
BaseLogger: slogutil.NewDiscardLogger(),
Logger: slogutil.NewDiscardLogger(),
PrivateSubnets: privateNets,
Bootstrap: &dnssvc.BootstrapConfig{},
Expand Down
12 changes: 6 additions & 6 deletions internal/tools/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/AdguardTeam/AdGuardDNSClient/internal/tools

go 1.23.2
go 1.23.3

require (
github.com/fzipp/gocyclo v0.6.0
Expand All @@ -21,7 +21,7 @@ require (
require (
cloud.google.com/go v0.116.0 // indirect
cloud.google.com/go/ai v0.8.2 // indirect
cloud.google.com/go/auth v0.10.0 // indirect
cloud.google.com/go/auth v0.10.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.5 // indirect
cloud.google.com/go/compute/metadata v0.5.2 // indirect
cloud.google.com/go/longrunning v0.6.2 // indirect
Expand Down Expand Up @@ -55,13 +55,13 @@ require (
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/telemetry v0.0.0-20241028140143-9c0d19e65ba0 // indirect
golang.org/x/telemetry v0.0.0-20241106142447-58a1122356f5 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.7.0 // indirect
google.golang.org/api v0.203.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
google.golang.org/api v0.205.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
20 changes: 10 additions & 10 deletions internal/tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ cloud.google.com/go v0.116.0 h1:B3fRrSDkLRt5qSHWe40ERJvhvnQwdZiHu0bJOpldweE=
cloud.google.com/go v0.116.0/go.mod h1:cEPSRWPzZEswwdr9BxE6ChEn01dWlTaF05LiC2Xs70U=
cloud.google.com/go/ai v0.8.2 h1:LEaQwqBv+k2ybrcdTtCTc9OPZXoEdcQaGrfvDYS6Bnk=
cloud.google.com/go/ai v0.8.2/go.mod h1:Wb3EUUGWwB6yHBaUf/+oxUq/6XbCaU1yh0GrwUS8lr4=
cloud.google.com/go/auth v0.10.0 h1:tWlkvFAh+wwTOzXIjrwM64karR1iTBZ/GRr0S/DULYo=
cloud.google.com/go/auth v0.10.0/go.mod h1:xxA5AqpDrvS+Gkmo9RqrGGRh6WSNKKOXhY3zNOr38tI=
cloud.google.com/go/auth v0.10.1 h1:TnK46qldSfHWt2a0b/hciaiVJsmDXWy9FqyUan0uYiI=
cloud.google.com/go/auth v0.10.1/go.mod h1:xxA5AqpDrvS+Gkmo9RqrGGRh6WSNKKOXhY3zNOr38tI=
cloud.google.com/go/auth/oauth2adapt v0.2.5 h1:2p29+dePqsCHPP1bqDJcKj4qxRyYCcbzKpFyKGt3MTk=
cloud.google.com/go/auth/oauth2adapt v0.2.5/go.mod h1:AlmsELtlEBnaNTL7jCj8VQFLy6mbZv0s4Q7NGBeQ5E8=
cloud.google.com/go/compute/metadata v0.5.2 h1:UxK4uu/Tn+I3p2dYWTfiX4wva7aYlKixAHn3fyqngqo=
Expand Down Expand Up @@ -179,8 +179,8 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/telemetry v0.0.0-20241028140143-9c0d19e65ba0 h1:od0RE4kmouF+x/o4zkTTSvBnGPZ2azGgCUmZdrbnEXM=
golang.org/x/telemetry v0.0.0-20241028140143-9c0d19e65ba0/go.mod h1:8nZWdGp9pq73ZI//QJyckMQab3yq7hoWi7SI0UIusVI=
golang.org/x/telemetry v0.0.0-20241106142447-58a1122356f5 h1:TCDqnvbBsFapViksHcHySl/sW4+rTGNIAoJJesHRuMM=
golang.org/x/telemetry v0.0.0-20241106142447-58a1122356f5/go.mod h1:8nZWdGp9pq73ZI//QJyckMQab3yq7hoWi7SI0UIusVI=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
Expand All @@ -205,17 +205,17 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.203.0 h1:SrEeuwU3S11Wlscsn+LA1kb/Y5xT8uggJSkIhD08NAU=
google.golang.org/api v0.203.0/go.mod h1:BuOVyCSYEPwJb3npWvDnNmFI92f3GeRnHNkETneT3SI=
google.golang.org/api v0.205.0 h1:LFaxkAIpDb/GsrWV20dMMo5MR0h8UARTbn24LmD+0Pg=
google.golang.org/api v0.205.0/go.mod h1:NrK1EMqO8Xk6l6QwRAmrXXg2v6dzukhlOyvkYtnvUuc=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 h1:2oV8dfuIkM1Ti7DwXc0BJfnwr9csz4TDXI9EmiI+Rbw=
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38/go.mod h1:vuAjtvlwkDKF6L1GQ0SokiRLCGFfeBUXWr/aFFkHACc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 h1:zciRKQ4kBpFgpfC5QQCVtnnNAcLIqweL7plyZRQHVpI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 h1:M0KvPgPmDZHPlbRbaNU1APr28TvwvvdUPlSv7PUvy8g=
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:dguCy7UOdZhTvLzDyt15+rOrawrpM4q7DD9dQ1P11P4=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 h1:XVhgTWWV3kGQlwJHR3upFWZeTsei6Oks1apkZSeonIE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
Expand Down

0 comments on commit 7558664

Please sign in to comment.