Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom text format with jinja templating #748

Merged
merged 1 commit into from
Jun 21, 2024
Merged

add custom text format with jinja templating #748

merged 1 commit into from
Jun 21, 2024

Conversation

dmachard
Copy link
Owner

@dmachard dmachard commented Jun 21, 2024

fix #587

New text format with jinja template

global:
  text-jinja: |+
    ;; Got {% if dm.DNS.Type == "QUERY" %}query{% else %}answer{% endif %} from {{ dm.NetworkInfo.QueryIP }}#{{ dm.NetworkInfo.QueryPort }}:
    ;; ->>HEADER<<- opcode: {{ dm.DNS.Opcode }}, status: {{ dm.DNS.Rcode }}, id: {{ dm.DNS.ID }}
    ;; flags: {{ dm.DNS.Flags.QR | yesno:"qr ," }}{{ dm.DNS.Flags.RD | yesno:"rd ," }}{{ dm.DNS.Flags.RA | yesno:"ra ," }}; QUERY: {{ dm.DNS.QuestionsCount }}, ANSWER: {{ dm.DNS.DNSRRs.Answers | length }}, AUTHORITY: {{ dm.DNS.DNSRRs.Nameservers | length }}, ADDITIONAL: {{ dm.DNS.DNSRRs.Records | length }}
    
    ;; QUESTION SECTION:
    ;{{ dm.DNS.Qname }}		{{ dm.DNS.Qclass }}	{{ dm.DNS.Qtype }}

    ;; ANSWER SECTION: {% for rr in dm.DNS.DNSRRs.Answers %}
    {{ rr.Name }}		{{ rr.TTL }} {{ rr.Class }} {{ rr.Rdatatype }} {{ rr.Rdata }}{% endfor %}

    ;; WHEN: {{ dm.DNSTap.Timestamp }}
    ;; MSG SIZE  rcvd: {{ dm.DNS.Length }}


Output example

;; Got query from 172.19.0.1#58505:
;; ->>HEADER<<- opcode: 0, status: NOERROR, id: 51670
;; flags: rd ; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.apple.com          IN      A

;; ANSWER SECTION: 

;; WHEN: 1718995587930350802
;; MSG SIZE  rcvd: 54


;; Got answer from 172.19.0.1#58505:
;; ->>HEADER<<- opcode: 0, status: NOERROR, id: 51670
;; flags: qr rd ra ; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.apple.com          IN      A

;; ANSWER SECTION: 
www.apple.com           881 IN CNAME www.apple.com.edgekey.net
www.apple.com.edgekey.net               2681 IN CNAME www.apple.com.edgekey.net.globalredir.akadns.net
www.apple.com.edgekey.net.globalredir.akadns.net                3599 IN CNAME e6858.dscx.akamaiedge.net
e6858.dscx.akamaiedge.net               19 IN A 2.21.145.39

;; WHEN: 1718995587946111311
;; MSG SIZE  rcvd: 192

@dmachard dmachard mentioned this pull request Jun 21, 2024
@dmachard dmachard merged commit b098fec into main Jun 21, 2024
55 checks passed
@dmachard dmachard deleted the custom-text branch June 24, 2024 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhanced text-format
1 participant