+ 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
|
"QH":"...", // target host name without the last dot
|
||||||
"QT":"...", // question type
|
"QT":"...", // question type
|
||||||
"QC":"...", // question class
|
"QC":"...", // question class
|
||||||
|
"CP":"" | "doh", // client connection protocol
|
||||||
"Answer":"base64 data",
|
"Answer":"base64 data",
|
||||||
"OrigAnswer":"base64 data",
|
"OrigAnswer":"base64 data",
|
||||||
"Result":{
|
"Result":{
|
||||||
@ -1275,6 +1276,7 @@ Response:
|
|||||||
"upstream":"...", // Upstream URL starting with tcp://, tls://, https://, or with an IP address
|
"upstream":"...", // Upstream URL starting with tcp://, tls://, https://, or with an IP address
|
||||||
"answer_dnssec": true,
|
"answer_dnssec": true,
|
||||||
"client":"127.0.0.1",
|
"client":"127.0.0.1",
|
||||||
|
"client_proto": "" (plain) | "doh",
|
||||||
"elapsedMs":"0.098403",
|
"elapsedMs":"0.098403",
|
||||||
"filterId":1,
|
"filterId":1,
|
||||||
"question":{
|
"question":{
|
||||||
|
@ -39,6 +39,11 @@ func processQueryLogsAndStats(ctx *dnsContext) int {
|
|||||||
Elapsed: elapsed,
|
Elapsed: elapsed,
|
||||||
ClientIP: getIP(d.Addr),
|
ClientIP: getIP(d.Addr),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d.HTTPRequest != nil {
|
||||||
|
p.ClientProto = "doh"
|
||||||
|
}
|
||||||
|
|
||||||
if d.Upstream != nil {
|
if d.Upstream != nil {
|
||||||
p.Upstream = d.Upstream.Address()
|
p.Upstream = d.Upstream.Address()
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,9 @@ func decodeLogEntry(ent *logEntry, str string) {
|
|||||||
case "QC":
|
case "QC":
|
||||||
ent.QClass = v
|
ent.QClass = v
|
||||||
|
|
||||||
|
case "CP":
|
||||||
|
ent.ClientProto = v
|
||||||
|
|
||||||
case "Answer":
|
case "Answer":
|
||||||
ent.Answer, err = base64.StdEncoding.DecodeString(v)
|
ent.Answer, err = base64.StdEncoding.DecodeString(v)
|
||||||
case "OrigAnswer":
|
case "OrigAnswer":
|
||||||
|
@ -63,10 +63,11 @@ func (l *queryLog) logEntryToJSONEntry(entry *logEntry) map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jsonEntry := map[string]interface{}{
|
jsonEntry := map[string]interface{}{
|
||||||
"reason": entry.Result.Reason.String(),
|
"reason": entry.Result.Reason.String(),
|
||||||
"elapsedMs": strconv.FormatFloat(entry.Elapsed.Seconds()*1000, 'f', -1, 64),
|
"elapsedMs": strconv.FormatFloat(entry.Elapsed.Seconds()*1000, 'f', -1, 64),
|
||||||
"time": entry.Time.Format(time.RFC3339Nano),
|
"time": entry.Time.Format(time.RFC3339Nano),
|
||||||
"client": l.getClientIP(entry.IP),
|
"client": l.getClientIP(entry.IP),
|
||||||
|
"client_proto": entry.ClientProto,
|
||||||
}
|
}
|
||||||
jsonEntry["question"] = map[string]interface{}{
|
jsonEntry["question"] = map[string]interface{}{
|
||||||
"host": entry.QHost,
|
"host": entry.QHost,
|
||||||
|
@ -38,6 +38,8 @@ type logEntry struct {
|
|||||||
QType string `json:"QT"`
|
QType string `json:"QT"`
|
||||||
QClass string `json:"QC"`
|
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
|
Answer []byte `json:",omitempty"` // sometimes empty answers happen like binerdunt.top or rev2.globalrootservers.net
|
||||||
OrigAnswer []byte `json:",omitempty"`
|
OrigAnswer []byte `json:",omitempty"`
|
||||||
|
|
||||||
@ -119,9 +121,10 @@ func (l *queryLog) Add(params AddParams) {
|
|||||||
IP: l.getClientIP(params.ClientIP.String()),
|
IP: l.getClientIP(params.ClientIP.String()),
|
||||||
Time: now,
|
Time: now,
|
||||||
|
|
||||||
Result: *params.Result,
|
Result: *params.Result,
|
||||||
Elapsed: params.Elapsed,
|
Elapsed: params.Elapsed,
|
||||||
Upstream: params.Upstream,
|
Upstream: params.Upstream,
|
||||||
|
ClientProto: params.ClientProto,
|
||||||
}
|
}
|
||||||
q := params.Question.Question[0]
|
q := params.Question.Question[0]
|
||||||
entry.QHost = strings.ToLower(q.Name[:len(q.Name)-1]) // remove the last dot
|
entry.QHost = strings.ToLower(q.Name[:len(q.Name)-1]) // remove the last dot
|
||||||
|
@ -41,13 +41,14 @@ type Config struct {
|
|||||||
|
|
||||||
// AddParams - parameters for Add()
|
// AddParams - parameters for Add()
|
||||||
type AddParams struct {
|
type AddParams struct {
|
||||||
Question *dns.Msg
|
Question *dns.Msg
|
||||||
Answer *dns.Msg // The response we sent to the client (optional)
|
Answer *dns.Msg // The response we sent to the client (optional)
|
||||||
OrigAnswer *dns.Msg // The response from an upstream server (optional)
|
OrigAnswer *dns.Msg // The response from an upstream server (optional)
|
||||||
Result *dnsfilter.Result // Filtering result (optional)
|
Result *dnsfilter.Result // Filtering result (optional)
|
||||||
Elapsed time.Duration // Time spent for processing the request
|
Elapsed time.Duration // Time spent for processing the request
|
||||||
ClientIP net.IP
|
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
|
// New - create a new instance of the query log
|
||||||
|
Loading…
Reference in New Issue
Block a user