Skip to content

Commit

Permalink
add a custom interface for the resolver instead of forcing *net.Resol…
Browse files Browse the repository at this point in the history
…ver (stripe#187)
  • Loading branch information
JulesDT authored and matt-intercom committed Jan 4, 2024
1 parent 83ed067 commit b979a39
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/smokescreen/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit b979a39

Please # to comment.