Skip to content

Commit

Permalink
ConditionalUpstreamConfig -> ConditionalUpstream
Browse files Browse the repository at this point in the history
  • Loading branch information
kwitsch authored and ThinkChaos committed Nov 22, 2023
1 parent 26d5f62 commit 00d4341
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions config/conditional_upstream.go
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/sirupsen/logrus"
)

// ConditionalUpstreamConfig conditional upstream configuration
type ConditionalUpstreamConfig struct {
// ConditionalUpstream conditional upstream configuration
type ConditionalUpstream struct {
RewriterConfig `yaml:",inline"`
Mapping ConditionalUpstreamMapping `yaml:"mapping"`
}
Expand All @@ -19,12 +19,12 @@ type ConditionalUpstreamMapping struct {
}

// IsEnabled implements `config.Configurable`.
func (c *ConditionalUpstreamConfig) IsEnabled() bool {
func (c *ConditionalUpstream) IsEnabled() bool {
return len(c.Mapping.Upstreams) != 0
}

// LogConfig implements `config.Configurable`.
func (c *ConditionalUpstreamConfig) LogConfig(logger *logrus.Entry) {
func (c *ConditionalUpstream) LogConfig(logger *logrus.Entry) {
for key, val := range c.Mapping.Upstreams {
logger.Infof("%s = %v", key, val)
}
Expand Down
8 changes: 4 additions & 4 deletions config/conditional_upstream_test.go
Expand Up @@ -9,12 +9,12 @@ import (
)

var _ = Describe("ConditionalUpstreamConfig", func() {
var cfg ConditionalUpstreamConfig
var cfg ConditionalUpstream

suiteBeforeEach()

BeforeEach(func() {
cfg = ConditionalUpstreamConfig{
cfg = ConditionalUpstream{
Mapping: ConditionalUpstreamMapping{
Upstreams: map[string][]Upstream{
"fritz.box": {Upstream{Net: NetProtocolTcpUdp, Host: "fbTest"}},
Expand All @@ -27,7 +27,7 @@ var _ = Describe("ConditionalUpstreamConfig", func() {

Describe("IsEnabled", func() {
It("should be false by default", func() {
cfg := ConditionalUpstreamConfig{}
cfg := ConditionalUpstream{}
Expect(defaults.Set(&cfg)).Should(Succeed())

Expect(cfg.IsEnabled()).Should(BeFalse())
Expand All @@ -41,7 +41,7 @@ var _ = Describe("ConditionalUpstreamConfig", func() {

When("disabled", func() {
It("should be false", func() {
cfg := ConditionalUpstreamConfig{
cfg := ConditionalUpstream{
Mapping: ConditionalUpstreamMapping{Upstreams: map[string][]Upstream{}},
}

Expand Down
48 changes: 24 additions & 24 deletions config/config.go
Expand Up @@ -189,30 +189,30 @@ func (b *BootstrappedUpstreamConfig) UnmarshalYAML(unmarshal func(interface{}) e
//
//nolint:maligned
type Config struct {
Upstreams Upstreams `yaml:"upstreams"`
ConnectIPVersion IPVersion `yaml:"connectIPVersion"`
CustomDNS CustomDNS `yaml:"customDNS"`
Conditional ConditionalUpstreamConfig `yaml:"conditional"`
Blocking BlockingConfig `yaml:"blocking"`
ClientLookup ClientLookupConfig `yaml:"clientLookup"`
Caching CachingConfig `yaml:"caching"`
QueryLog QueryLogConfig `yaml:"queryLog"`
Prometheus MetricsConfig `yaml:"prometheus"`
Redis RedisConfig `yaml:"redis"`
Log log.Config `yaml:"log"`
Ports PortsConfig `yaml:"ports"`
DoHUserAgent string `yaml:"dohUserAgent"`
MinTLSServeVer string `yaml:"minTlsServeVersion" default:"1.2"`
StartVerifyUpstream bool `yaml:"startVerifyUpstream" default:"false"`
CertFile string `yaml:"certFile"`
KeyFile string `yaml:"keyFile"`
BootstrapDNS BootstrapDNSConfig `yaml:"bootstrapDns"`
HostsFile HostsFileConfig `yaml:"hostsFile"`
FQDNOnly FQDNOnly `yaml:"fqdnOnly"`
Filtering FilteringConfig `yaml:"filtering"`
EDE EDE `yaml:"ede"`
ECS ECS `yaml:"ecs"`
SUDN SUDN `yaml:"specialUseDomains"`
Upstreams Upstreams `yaml:"upstreams"`
ConnectIPVersion IPVersion `yaml:"connectIPVersion"`
CustomDNS CustomDNS `yaml:"customDNS"`
Conditional ConditionalUpstream `yaml:"conditional"`
Blocking BlockingConfig `yaml:"blocking"`
ClientLookup ClientLookupConfig `yaml:"clientLookup"`
Caching CachingConfig `yaml:"caching"`
QueryLog QueryLogConfig `yaml:"queryLog"`
Prometheus MetricsConfig `yaml:"prometheus"`
Redis RedisConfig `yaml:"redis"`
Log log.Config `yaml:"log"`
Ports PortsConfig `yaml:"ports"`
DoHUserAgent string `yaml:"dohUserAgent"`
MinTLSServeVer string `yaml:"minTlsServeVersion" default:"1.2"`
StartVerifyUpstream bool `yaml:"startVerifyUpstream" default:"false"`
CertFile string `yaml:"certFile"`
KeyFile string `yaml:"keyFile"`
BootstrapDNS BootstrapDNSConfig `yaml:"bootstrapDns"`
HostsFile HostsFileConfig `yaml:"hostsFile"`
FQDNOnly FQDNOnly `yaml:"fqdnOnly"`
Filtering FilteringConfig `yaml:"filtering"`
EDE EDE `yaml:"ede"`
ECS ECS `yaml:"ecs"`
SUDN SUDN `yaml:"specialUseDomains"`

// Deprecated options
Deprecated struct {
Expand Down
4 changes: 2 additions & 2 deletions resolver/conditional_upstream_resolver.go
Expand Up @@ -15,7 +15,7 @@ import (

// ConditionalUpstreamResolver delegates DNS question to other DNS resolver dependent on domain name in question
type ConditionalUpstreamResolver struct {
configurable[*config.ConditionalUpstreamConfig]
configurable[*config.ConditionalUpstream]
NextResolver
typed

Expand All @@ -24,7 +24,7 @@ type ConditionalUpstreamResolver struct {

// NewConditionalUpstreamResolver returns new resolver instance
func NewConditionalUpstreamResolver(
ctx context.Context, cfg config.ConditionalUpstreamConfig, bootstrap *Bootstrap, shouldVerifyUpstreams bool,
ctx context.Context, cfg config.ConditionalUpstream, bootstrap *Bootstrap, shouldVerifyUpstreams bool,
) (*ConditionalUpstreamResolver, error) {
m := make(map[string]Resolver, len(cfg.Mapping.Upstreams))

Expand Down
4 changes: 2 additions & 2 deletions resolver/conditional_upstream_resolver_test.go
Expand Up @@ -65,7 +65,7 @@ var _ = Describe("ConditionalUpstreamResolver", Label("conditionalResolver"), fu
})
DeferCleanup(refuseTestUpstream.Close)

sut, _ = NewConditionalUpstreamResolver(ctx, config.ConditionalUpstreamConfig{
sut, _ = NewConditionalUpstreamResolver(ctx, config.ConditionalUpstream{
Mapping: config.ConditionalUpstreamMapping{
Upstreams: map[string][]config.Upstream{
"fritz.box": {fbTestUpstream.Start()},
Expand Down Expand Up @@ -194,7 +194,7 @@ var _ = Describe("ConditionalUpstreamResolver", Label("conditionalResolver"), fu
It("errors during construction", func() {
b := newTestBootstrap(ctx, &dns.Msg{MsgHdr: dns.MsgHdr{Rcode: dns.RcodeServerFailure}})

r, err := NewConditionalUpstreamResolver(ctx, config.ConditionalUpstreamConfig{
r, err := NewConditionalUpstreamResolver(ctx, config.ConditionalUpstream{
Mapping: config.ConditionalUpstreamMapping{
Upstreams: map[string][]config.Upstream{
".": {config.Upstream{Host: "example.com"}},
Expand Down
2 changes: 1 addition & 1 deletion server/server_test.go
Expand Up @@ -127,7 +127,7 @@ var _ = BeforeSuite(func() {
},
},
},
Conditional: config.ConditionalUpstreamConfig{
Conditional: config.ConditionalUpstream{
Mapping: config.ConditionalUpstreamMapping{
Upstreams: map[string][]config.Upstream{
"net.cn": {upstreamClient},
Expand Down

0 comments on commit 00d4341

Please sign in to comment.