File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ type Config struct {
3838type LoggingConfig struct {
3939 Healthchecks bool `yaml:"healthchecks" envconfig:"LOGGING_HEALTHCHECKS"`
4040 Level string `yaml:"level" envconfig:"LOGGING_LEVEL"`
41+ QueryLog bool `yaml:"queryLog" envconfig:"LOGGING_QUERY_LOG"`
4142}
4243
4344type DnsConfig struct {
@@ -76,6 +77,7 @@ var globalConfig = &Config{
7677 Logging : LoggingConfig {
7778 Level : "info" ,
7879 Healthchecks : false ,
80+ QueryLog : true ,
7981 },
8082 Dns : DnsConfig {
8183 ListenAddress : "" ,
Original file line number Diff line number Diff line change @@ -38,6 +38,16 @@ func handleQuery(w dns.ResponseWriter, r *dns.Msg) {
3838 cfg := config .GetConfig ()
3939 m := new (dns.Msg )
4040
41+ if cfg .Logging .QueryLog {
42+ for _ , q := range r .Question {
43+ logger .Infof ("query: name: %s, type: %s, class: %s" ,
44+ q .Name ,
45+ dns .Type (q .Qtype ).String (),
46+ dns .Class (q .Qclass ).String (),
47+ )
48+ }
49+ }
50+
4151 // Split query name into labels and lookup each domain and parent until we get a hit
4252 queryLabels := dns .SplitDomainName (r .Question [0 ].Name )
4353 for startLabelIdx := 0 ; startLabelIdx < len (queryLabels ); startLabelIdx ++ {
You can’t perform that action at this time.
0 commit comments