Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sudn): refactor and expand supported special use domains RFCs
- Loading branch information
1 parent
6028a64
commit 56633da
Showing
11 changed files
with
364 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
// SUDNConfig configuration for Special Use Domain Names | ||
type SUDNConfig struct { | ||
// These are "recommended for private use" but not mandatory. | ||
// If a user wishes to use one, it will most likely be via conditional | ||
// upstream or custom DNS, which come before SUDN in the resolver chain. | ||
// Thus defaulting to `true` and returning NXDOMAIN here should not conflict. | ||
RFC6762AppendixG bool `yaml:"rfc6762-appendixG" default:"true"` | ||
} | ||
|
||
// IsEnabled implements `config.Configurable`. | ||
func (c *SUDNConfig) IsEnabled() bool { | ||
// The Special Use RFCs are always active | ||
return true | ||
} | ||
|
||
// LogConfig implements `config.Configurable`. | ||
func (c *SUDNConfig) LogConfig(logger *logrus.Entry) { | ||
logger.Debugf("rfc6762-appendixG = %v", c.RFC6762AppendixG) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package config | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("SUDNConfig", func() { | ||
var cfg SUDNConfig | ||
|
||
suiteBeforeEach() | ||
|
||
BeforeEach(func() { | ||
var err error | ||
|
||
cfg, err = WithDefaults[SUDNConfig]() | ||
Expect(err).Should(Succeed()) | ||
}) | ||
|
||
Describe("IsEnabled", func() { | ||
It("is true", func() { | ||
Expect(cfg.IsEnabled()).Should(BeTrue()) | ||
}) | ||
}) | ||
|
||
Describe("LogConfig", func() { | ||
It("should log configuration", func() { | ||
cfg.LogConfig(logger) | ||
|
||
Expect(hook.Calls).ShouldNot(BeEmpty()) | ||
Expect(hook.Messages).Should(ContainElement(ContainSubstring("rfc6762-appendixG = true"))) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.