From b979a3980a74174ee4722fe529c10c23ff744aa8 Mon Sep 17 00:00:00 2001 From: JulesD Date: Fri, 14 Apr 2023 09:25:06 -0400 Subject: [PATCH] add a custom interface for the resolver instead of forcing *net.Resolver (#187) --- pkg/smokescreen/config.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/smokescreen/config.go b/pkg/smokescreen/config.go index ec3f86a8..a1da77aa 100644 --- a/pkg/smokescreen/config.go +++ b/pkg/smokescreen/config.go @@ -29,13 +29,20 @@ type RuleRange struct { Port int } +// Resolver implements the interface needed by smokescreen and implemented by *net.Resolver +// This will allow different resolvers to also be provided +type Resolver interface { + LookupPort(ctx context.Context, network, service string) (port int, err error) + LookupIP(ctx context.Context, network, host string) ([]net.IP, error) +} + type Config struct { Ip string Port uint16 Listener net.Listener DenyRanges []RuleRange AllowRanges []RuleRange - Resolver *net.Resolver + Resolver Resolver ConnectTimeout time.Duration ExitTimeout time.Duration MetricsClient metrics.MetricsClientInterface @@ -228,6 +235,7 @@ func NewConfig() *Config { }) return &Config{ + Resolver: &net.Resolver{}, CrlByAuthorityKeyId: make(map[string]*pkix.CertificateList), clientCasBySubjectKeyId: make(map[string]*x509.Certificate), Log: log.New(),