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 {
38
38
type LoggingConfig struct {
39
39
Healthchecks bool `yaml:"healthchecks" envconfig:"LOGGING_HEALTHCHECKS"`
40
40
Level string `yaml:"level" envconfig:"LOGGING_LEVEL"`
41
+ QueryLog bool `yaml:"queryLog" envconfig:"LOGGING_QUERY_LOG"`
41
42
}
42
43
43
44
type DnsConfig struct {
@@ -76,6 +77,7 @@ var globalConfig = &Config{
76
77
Logging : LoggingConfig {
77
78
Level : "info" ,
78
79
Healthchecks : false ,
80
+ QueryLog : true ,
79
81
},
80
82
Dns : DnsConfig {
81
83
ListenAddress : "" ,
Original file line number Diff line number Diff line change @@ -38,6 +38,16 @@ func handleQuery(w dns.ResponseWriter, r *dns.Msg) {
38
38
cfg := config .GetConfig ()
39
39
m := new (dns.Msg )
40
40
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
+
41
51
// Split query name into labels and lookup each domain and parent until we get a hit
42
52
queryLabels := dns .SplitDomainName (r .Question [0 ].Name )
43
53
for startLabelIdx := 0 ; startLabelIdx < len (queryLabels ); startLabelIdx ++ {
You can’t perform that action at this time.
0 commit comments