+ client_proto
This commit is contained in:
parent
0adbce5d38
commit
0904eeffa8
@ -1200,6 +1200,7 @@ When a new DNS request is received and processed, we store information about thi
|
||||
"QH":"...", // target host name without the last dot
|
||||
"QT":"...", // question type
|
||||
"QC":"...", // question class
|
||||
"CP":"" | "doh", // client connection protocol
|
||||
"Answer":"base64 data",
|
||||
"OrigAnswer":"base64 data",
|
||||
"Result":{
|
||||
@ -1275,6 +1276,7 @@ Response:
|
||||
"upstream":"...", // Upstream URL starting with tcp://, tls://, https://, or with an IP address
|
||||
"answer_dnssec": true,
|
||||
"client":"127.0.0.1",
|
||||
"client_proto": "" (plain) | "doh",
|
||||
"elapsedMs":"0.098403",
|
||||
"filterId":1,
|
||||
"question":{
|
||||
|
@ -39,6 +39,11 @@ func processQueryLogsAndStats(ctx *dnsContext) int {
|
||||
Elapsed: elapsed,
|
||||
ClientIP: getIP(d.Addr),
|
||||
}
|
||||
|
||||
if d.HTTPRequest != nil {
|
||||
p.ClientProto = "doh"
|
||||
}
|
||||
|
||||
if d.Upstream != nil {
|
||||
p.Upstream = d.Upstream.Address()
|
||||
}
|
||||
|
@ -37,6 +37,9 @@ func decodeLogEntry(ent *logEntry, str string) {
|
||||
case "QC":
|
||||
ent.QClass = v
|
||||
|
||||
case "CP":
|
||||
ent.ClientProto = v
|
||||
|
||||
case "Answer":
|
||||
ent.Answer, err = base64.StdEncoding.DecodeString(v)
|
||||
case "OrigAnswer":
|
||||
|
@ -67,6 +67,7 @@ func (l *queryLog) logEntryToJSONEntry(entry *logEntry) map[string]interface{} {
|
||||
"elapsedMs": strconv.FormatFloat(entry.Elapsed.Seconds()*1000, 'f', -1, 64),
|
||||
"time": entry.Time.Format(time.RFC3339Nano),
|
||||
"client": l.getClientIP(entry.IP),
|
||||
"client_proto": entry.ClientProto,
|
||||
}
|
||||
jsonEntry["question"] = map[string]interface{}{
|
||||
"host": entry.QHost,
|
||||
|
@ -38,6 +38,8 @@ type logEntry struct {
|
||||
QType string `json:"QT"`
|
||||
QClass string `json:"QC"`
|
||||
|
||||
ClientProto string `json:"CP"` // "" or "doh"
|
||||
|
||||
Answer []byte `json:",omitempty"` // sometimes empty answers happen like binerdunt.top or rev2.globalrootservers.net
|
||||
OrigAnswer []byte `json:",omitempty"`
|
||||
|
||||
@ -122,6 +124,7 @@ func (l *queryLog) Add(params AddParams) {
|
||||
Result: *params.Result,
|
||||
Elapsed: params.Elapsed,
|
||||
Upstream: params.Upstream,
|
||||
ClientProto: params.ClientProto,
|
||||
}
|
||||
q := params.Question.Question[0]
|
||||
entry.QHost = strings.ToLower(q.Name[:len(q.Name)-1]) // remove the last dot
|
||||
|
@ -47,7 +47,8 @@ type AddParams struct {
|
||||
Result *dnsfilter.Result // Filtering result (optional)
|
||||
Elapsed time.Duration // Time spent for processing the request
|
||||
ClientIP net.IP
|
||||
Upstream string
|
||||
Upstream string // Upstream server URL
|
||||
ClientProto string // Protocol for the client connection: "" (plain), "doh"
|
||||
}
|
||||
|
||||
// New - create a new instance of the query log
|
||||
|
Loading…
Reference in New Issue
Block a user