Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Config struct {
Debug DebugConfig `yaml:"debug"`
Indexer IndexerConfig `yaml:"indexer"`
State StateConfig `yaml:"state"`
Tls TlsConfig `yaml:"tls"`
Profiles []string `yaml:"profiles" envconfig:"PROFILES"`
}

Expand All @@ -33,6 +34,7 @@ type LoggingConfig struct {
type DnsConfig struct {
ListenAddress string `yaml:"address" envconfig:"DNS_LISTEN_ADDRESS"`
ListenPort uint `yaml:"port" envconfig:"DNS_LISTEN_PORT"`
ListenTlsPort uint `yaml:"tlsPort" envconfig:"DNS_LISTEN_TLS_PORT"`
RecursionEnabled bool `yaml:"recursionEnabled" envconfig:"DNS_RECURSION"`
FallbackServers []string `yaml:"fallbackServers" envconfig:"DNS_FALLBACK_SERVERS"`
}
Expand Down Expand Up @@ -61,6 +63,11 @@ type StateConfig struct {
Directory string `yaml:"dir" envconfig:"STATE_DIR"`
}

type TlsConfig struct {
CertFilePath string `yaml:"certFilePath" envconfig:"TLS_CERT_FILE_PATH"`
KeyFilePath string `yaml:"keyFilePath" envconfig:"TLS_KEY_FILE_PATH"`
}

// Singleton config instance with default values
var globalConfig = &Config{
Logging: LoggingConfig{
Expand All @@ -69,6 +76,7 @@ var globalConfig = &Config{
Dns: DnsConfig{
ListenAddress: "",
ListenPort: 8053,
ListenTlsPort: 8853,
// hdns.io
FallbackServers: []string{
"103.196.38.38",
Expand Down
11 changes: 11 additions & 0 deletions internal/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ func Start() error {
ReusePort: true,
}
go startListener(serverTcp)
// TLS listener
if cfg.Tls.CertFilePath != "" && cfg.Tls.KeyFilePath != "" {
listenTlsAddr := fmt.Sprintf("%s:%d", cfg.Dns.ListenAddress, cfg.Dns.ListenTlsPort)
serverTls := &dns.Server{
Addr: listenTlsAddr,
Net: "tcp-tls",
TsigSecret: nil,
ReusePort: false,
}
go startListener(serverTls)
}
return nil
}

Expand Down