Plugin dnstap: add support for "extra" field in payload (#6226)

* dnstap: add 'extra' field

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* dnstap: add setup_test for 'extra' field

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* udnstap: update document and test

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* dnstap: update setup_test for more coverage

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* dnstap: add TapMessageWithMetadata function to Dnstap

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* dnstap: adapt dnstap and forward plugins to use TapMessageWithMetadata

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* change TapMessageWithMetadata function

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* tab inconsistency fix

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* fix replacer to support empty state

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* add replacer test for empty status parameter

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* dnstap: update unit test for 'extra' field

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* clean up code

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* gofmt fix & static analysis fix

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

* dnstap: refactor

Signed-off-by: chenyuheng <chenyuheng99@qq.com>

---------

Signed-off-by: chenyuheng <chenyuheng99@qq.com>
This commit is contained in:
Yuheng
2023-08-14 14:01:13 -04:00
committed by GitHub
parent eec26e59c6
commit 90d55611a2
10 changed files with 196 additions and 64 deletions

View File

@@ -256,6 +256,12 @@ func TestLabels(t *testing.T) {
if repl != expect[lbl] {
t.Errorf("Expected value %q, got %q", expect[lbl], repl)
}
// test empty state and nil recorder won't panic
repl_empty := replacer.Replace(ctx, request.Request{}, nil, lbl)
if repl_empty != EmptyValue {
t.Errorf("Expected empty value %q, got %q", EmptyValue, repl_empty)
}
}
}