File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ type Config struct {
22
22
Debug DebugConfig `yaml:"debug"`
23
23
Indexer IndexerConfig `yaml:"indexer"`
24
24
State StateConfig `yaml:"state"`
25
+ Tls TlsConfig `yaml:"tls"`
25
26
Profiles []string `yaml:"profiles" envconfig:"PROFILES"`
26
27
}
27
28
@@ -33,6 +34,7 @@ type LoggingConfig struct {
33
34
type DnsConfig struct {
34
35
ListenAddress string `yaml:"address" envconfig:"DNS_LISTEN_ADDRESS"`
35
36
ListenPort uint `yaml:"port" envconfig:"DNS_LISTEN_PORT"`
37
+ ListenTlsPort uint `yaml:"tlsPort" envconfig:"DNS_LISTEN_TLS_PORT"`
36
38
RecursionEnabled bool `yaml:"recursionEnabled" envconfig:"DNS_RECURSION"`
37
39
FallbackServers []string `yaml:"fallbackServers" envconfig:"DNS_FALLBACK_SERVERS"`
38
40
}
@@ -61,6 +63,11 @@ type StateConfig struct {
61
63
Directory string `yaml:"dir" envconfig:"STATE_DIR"`
62
64
}
63
65
66
+ type TlsConfig struct {
67
+ CertFilePath string `yaml:"certFilePath" envconfig:"TLS_CERT_FILE_PATH"`
68
+ KeyFilePath string `yaml:"keyFilePath" envconfig:"TLS_KEY_FILE_PATH"`
69
+ }
70
+
64
71
// Singleton config instance with default values
65
72
var globalConfig = & Config {
66
73
Logging : LoggingConfig {
@@ -69,6 +76,7 @@ var globalConfig = &Config{
69
76
Dns : DnsConfig {
70
77
ListenAddress : "" ,
71
78
ListenPort : 8053 ,
79
+ ListenTlsPort : 8853 ,
72
80
// hdns.io
73
81
FallbackServers : []string {
74
82
"103.196.38.38" ,
Original file line number Diff line number Diff line change @@ -60,6 +60,17 @@ func Start() error {
60
60
ReusePort : true ,
61
61
}
62
62
go startListener (serverTcp )
63
+ // TLS listener
64
+ if cfg .Tls .CertFilePath != "" && cfg .Tls .KeyFilePath != "" {
65
+ listenTlsAddr := fmt .Sprintf ("%s:%d" , cfg .Dns .ListenAddress , cfg .Dns .ListenTlsPort )
66
+ serverTls := & dns.Server {
67
+ Addr : listenTlsAddr ,
68
+ Net : "tcp-tls" ,
69
+ TsigSecret : nil ,
70
+ ReusePort : false ,
71
+ }
72
+ go startListener (serverTls )
73
+ }
63
74
return nil
64
75
}
65
76
You can’t perform that action at this time.
0 commit comments