Skip to content

Commit

Permalink
change: no dialer warning logger anymore
Browse files Browse the repository at this point in the history
- parent dialer caller can log the error
- remove warner settings field for dot and plain dialers
  • Loading branch information
qdm12 committed Nov 3, 2024
1 parent 771471b commit 277e4bf
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 17 deletions.
1 change: 0 additions & 1 deletion internal/setup/dot.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func dotServer(userSettings config.Settings, ipv6Support bool,
dialerSettings := dot.Settings{
UpstreamResolvers: upstreamResolvers,
IPVersion: ipVersion,
Warner: logger,
Metrics: metrics,
}
dialer, err := dot.New(dialerSettings)
Expand Down
3 changes: 0 additions & 3 deletions pkg/dot/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type Dialer struct {
servers []provider.DoTServer
ipv6 bool
netDialer *net.Dialer
warner Warner
metrics Metrics
}

Expand All @@ -38,7 +37,6 @@ func New(settings Settings) (dial *Dialer, err error) {
netDialer: &net.Dialer{
Timeout: settings.Timeout,
},
warner: settings.Warner,
metrics: settings.Metrics,
}, nil
}
Expand All @@ -55,7 +53,6 @@ func (d *Dialer) Dial(ctx context.Context, _, _ string) (

conn, err = d.netDialer.DialContext(ctx, "tcp", serverAddress)
if err != nil {
d.warner.Warn(err.Error())
d.metrics.DoTDialInc(serverName, serverAddress, "error")
return nil, err
}
Expand Down
5 changes: 0 additions & 5 deletions pkg/dot/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

metricsnoop "github.com/qdm12/dns/v2/pkg/dot/metrics/noop"
lognoop "github.com/qdm12/dns/v2/pkg/log/noop"
"github.com/qdm12/dns/v2/pkg/provider"
"github.com/qdm12/gosettings"
"github.com/qdm12/gosettings/validate"
Expand All @@ -27,9 +26,6 @@ type Settings struct {
// upstream DNS over TLS servers. If left unset, it defaults to
// "ipv4".
IPVersion string
// Warner is the warning logger to log dial errors.
// It defaults to a No-Op warner implementation.
Warner Warner
// Metrics is the metrics interface to record metric data.
// It defaults to a No-Op metrics implementation.
Metrics Metrics
Expand All @@ -41,7 +37,6 @@ func (s *Settings) SetDefaults() {
const defaultTimeout = 5 * time.Second
s.Timeout = gosettings.DefaultComparable(s.Timeout, defaultTimeout)
s.IPVersion = gosettings.DefaultComparable(s.IPVersion, "ipv4")
s.Warner = gosettings.DefaultComparable[Warner](s.Warner, lognoop.New())
s.Metrics = gosettings.DefaultComparable[Metrics](s.Metrics, metricsnoop.New())
}

Expand Down
3 changes: 0 additions & 3 deletions pkg/plain/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type Dialer struct {
servers []provider.PlainServer
ipv6 bool
netDialer *net.Dialer
warner Warner
metrics Metrics
}

Expand All @@ -37,7 +36,6 @@ func New(settings Settings) (dial *Dialer, err error) {
netDialer: &net.Dialer{
Timeout: settings.Timeout,
},
warner: settings.Warner,
metrics: settings.Metrics,
}, nil
}
Expand All @@ -53,7 +51,6 @@ func (d *Dialer) Dial(ctx context.Context, network, _ string) (

udpConn, err := d.netDialer.DialContext(ctx, network, serverAddress)
if err != nil {
d.warner.Warn(err.Error())
d.metrics.PlainDialInc(serverAddress, "error")
return nil, err
}
Expand Down
5 changes: 0 additions & 5 deletions pkg/plain/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"time"

lognoop "github.com/qdm12/dns/v2/pkg/log/noop"
metricsnoop "github.com/qdm12/dns/v2/pkg/plain/metrics/noop"
"github.com/qdm12/dns/v2/pkg/provider"
"github.com/qdm12/gosettings"
Expand All @@ -27,9 +26,6 @@ type Settings struct {
// upstream DNS servers. If left unset, it defaults to
// "ipv4".
IPVersion string
// Warner is the warning logger to log dial errors.
// It defaults to a No-Op warner implementation.
Warner Warner
// Metrics is the metrics interface to record metric data.
// It defaults to a No-Op metrics implementation.
Metrics Metrics
Expand All @@ -41,7 +37,6 @@ func (s *Settings) SetDefaults() {
const defaultTimeout = 5 * time.Second
s.Timeout = gosettings.DefaultComparable(s.Timeout, defaultTimeout)
s.IPVersion = gosettings.DefaultComparable(s.IPVersion, "ipv4")
s.Warner = gosettings.DefaultComparable[Warner](s.Warner, lognoop.New())
s.Metrics = gosettings.DefaultComparable[Metrics](s.Metrics, metricsnoop.New())
}

Expand Down

0 comments on commit 277e4bf

Please sign in to comment.