dnstap / dnstap-ldns

reference dnstap decoding utility
Apache License 2.0
20 stars 8 forks source link

add JSON format output #6

Closed hirachan closed 3 years ago

hirachan commented 3 years ago

-q has very few information, -y yaml has enough information but it is not easy to use by program. JSON format can be used easily for other next hop filtering applications such as fluentd.

cmikk commented 3 years ago

Thank you for your contribution. It looks good overall, but note that print_string() may generate invalid JSON strings. For example, a qname of embedded\.dot.example.com would be formatted as "embedded\.dot.example.com" which is not a valid JSON string (the \. is an invalid escape sequence). This could be addressed by using a full JSON library for output (at the cost of a dependency) or by writing and using a JSON-oriented variant of print_string.

Note that golang-dnstap has a dnstap decoding tool which supports JSON output (using the golang standard encoding/json package) , if you haven't seen it already.

hirachan commented 3 years ago

Thanks for your nice opinion. I don't think we need full JSON library, so I made print_json_string to escape ", "\" and to translate non-printable chars into\uxxxx`.

I'm sorry but I made a new PR because I moved my working branch. Please continue to discuss on new PR. So sorry that I'm newbie to PR to open source projects.

Yes, I already tried tap2fluent which is using golang-dnstap, but I found it's a bit heavier than I expected. That's why I wanted C version of this.

hirachan commented 3 years ago

Made a new PR from other branch. Please move to https://github.com/dnstap/dnstap-ldns/pull/7