mw/logs: add rflags to logging (#845)

Add the DNS message response flags as {rflags} to the default logging
Also complete the replacer testing that is was commented out.
And (unrelated) Switch erratic and whoami to ease testing.

Note: {flags} could and should be added as well - but we can leave that
as a beginners bug.
This commit is contained in:
Miek Gieben
2017-08-07 03:49:40 -07:00
committed by GitHub
parent bcb2eb1ecc
commit 050eccd69e
6 changed files with 104 additions and 115 deletions

View File

@@ -55,26 +55,28 @@ response placeholders.
The following place holders are supported:
* `{type}`: qtype of the request.
* `{name}`: qname of the request.
* `{class}`: qclass of the request.
* `{proto}`: protocol used (tcp or udp).
* `{when}`: time of the query.
* `{remote}`: client's IP address.
* `{size}`: request size in bytes.
* `{port}`: client's port.
* `{duration}`: response duration.
* `{>bufsize}`: the EDNS0 buffer size advertised.
* `{>do}`: is the EDNS0 DO (DNSSEC OK) bit set.
* `{type}`: qtype of the request
* `{name}`: qname of the request
* `{class}`: qclass of the request
* `{proto}`: protocol used (tcp or udp)
* `{when}`: time of the query
* `{remote}`: client's IP address
* `{size}`: request size in bytes
* `{port}`: client's port
* `{duration}`: response duration
* `{rcode}`: response RCODE
* `{rsize}`: response size
* `{>rflags}`: response flags, each set flag will be displayed, e.g. "aa, tc". This includes the qr
bit as well.
* `{>bufsize}`: the EDNS0 buffer size advertised in the query
* `{>do}`: is the EDNS0 DO (DNSSEC OK) bit set in the query
* `{>id}`: query ID
* `{>opcode}`: query OPCODE.
* `{rcode}`: response RCODE.
* `{rsize}`: response size.
* `{>opcode}`: query OPCODE
The default Common Log Format is:
~~~ txt
`{remote} - [{when}] "{type} {class} {name} {proto} {size} {>do} {>bufsize}" {rcode} {rsize} {duration}`
`{remote} - [{when}] "{type} {class} {name} {proto} {size} {>do} {>bufsize}" {rcode} {>rflags} {rsize} {duration}`
~~~
## Examples

View File

@@ -78,10 +78,10 @@ type Rule struct {
}
const (
// DefaultLogFilename is the default output name.
// DefaultLogFilename is the default output name. This is the only supported value.
DefaultLogFilename = "stdout"
// CommonLogFormat is the common log format.
CommonLogFormat = `{remote} ` + CommonLogEmptyValue + ` [{when}] "{type} {class} {name} {proto} {size} {>do} {>bufsize}" {rcode} {rsize} {duration}`
CommonLogFormat = `{remote} ` + CommonLogEmptyValue + ` [{when}] "{type} {class} {name} {proto} {size} {>do} {>bufsize}" {rcode} {>rflags} {rsize} {duration}`
// CommonLogEmptyValue is the common empty log value.
CommonLogEmptyValue = "-"
// CombinedLogFormat is the combined log format.