mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-08 22:36:48 +02:00
add additional section
This commit is contained in:
@ -21,55 +21,74 @@ Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"id": integer,
|
||||
"opcode": string,
|
||||
"status": string,
|
||||
"id": integer,
|
||||
"opcode": string,
|
||||
"status": string,
|
||||
"flags": [
|
||||
string
|
||||
string
|
||||
],
|
||||
"query_num": integer,
|
||||
"answer_num": integer,
|
||||
"authority_num": integer,
|
||||
"additional_num": integer,
|
||||
"query_num": integer,
|
||||
"answer_num": integer,
|
||||
"authority_num": integer,
|
||||
"additional_num": integer,
|
||||
"axfr": [
|
||||
{
|
||||
"name": string,
|
||||
"class": string,
|
||||
"type": string,
|
||||
"ttl": integer,
|
||||
"data": string
|
||||
"name": string,
|
||||
"class": string,
|
||||
"type": string,
|
||||
"ttl": integer,
|
||||
"data": string
|
||||
}
|
||||
],
|
||||
"opt_pseudosection": {
|
||||
"edns": {
|
||||
"version": integer,
|
||||
"flags": [
|
||||
string
|
||||
],
|
||||
"udp": integer
|
||||
},
|
||||
"cookie": string
|
||||
},
|
||||
"question": {
|
||||
"name": string,
|
||||
"class": string,
|
||||
"type": string
|
||||
"name": string,
|
||||
"class": string,
|
||||
"type": string
|
||||
},
|
||||
"answer": [
|
||||
{
|
||||
"name": string,
|
||||
"class": string,
|
||||
"type": string,
|
||||
"ttl": integer,
|
||||
"data": string
|
||||
"name": string,
|
||||
"class": string,
|
||||
"type": string,
|
||||
"ttl": integer,
|
||||
"data": string
|
||||
}
|
||||
],
|
||||
"additional": [
|
||||
{
|
||||
"name": string,
|
||||
"class": string,
|
||||
"type": string,
|
||||
"ttl": integer,
|
||||
"data": string
|
||||
}
|
||||
],
|
||||
"authority": [
|
||||
{
|
||||
"name": string,
|
||||
"class": string,
|
||||
"type": string,
|
||||
"ttl": integer,
|
||||
"data": string
|
||||
"name": string,
|
||||
"class": string,
|
||||
"type": string,
|
||||
"ttl": integer,
|
||||
"data": string
|
||||
}
|
||||
],
|
||||
"query_time": integer, # in msec
|
||||
"server": string,
|
||||
"when": string,
|
||||
"when_epoch": integer, # naive timestamp if when field is parsable, else null
|
||||
"when_epoch_utc": integer, # timezone aware timestamp availabe for UTC, else null
|
||||
"rcvd": integer
|
||||
"size": string
|
||||
"query_time": integer, # in msec
|
||||
"server": string,
|
||||
"when": string,
|
||||
"when_epoch": integer, # naive timestamp if when field is parsable, else null
|
||||
"when_epoch_utc": integer, # timezone aware timestamp availabe for UTC, else null
|
||||
"rcvd": integer
|
||||
"size": string
|
||||
}
|
||||
]
|
||||
|
||||
@ -160,7 +179,7 @@ import jc.utils
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.8'
|
||||
version = '2.0'
|
||||
description = '`dig` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -225,6 +244,14 @@ def _process(proc_data):
|
||||
except (ValueError):
|
||||
ans['ttl'] = None
|
||||
|
||||
if 'additional' in entry:
|
||||
for add in entry['additional']:
|
||||
try:
|
||||
ttl_int = int(add['ttl'])
|
||||
add['ttl'] = ttl_int
|
||||
except (ValueError):
|
||||
add['ttl'] = None
|
||||
|
||||
if 'authority' in entry:
|
||||
for auth in entry['authority']:
|
||||
try:
|
||||
@ -321,22 +348,6 @@ def _parse_question(question):
|
||||
'type': dns_type}
|
||||
|
||||
|
||||
def _parse_authority(authority):
|
||||
# cnn.com. 3600 IN NS ns-1086.awsdns-07.org.
|
||||
authority = authority.split()
|
||||
authority_name = authority[0]
|
||||
authority_class = authority[2]
|
||||
authority_type = authority[3]
|
||||
authority_ttl = authority[1]
|
||||
authority_data = authority[4]
|
||||
|
||||
return {'name': authority_name,
|
||||
'class': authority_class,
|
||||
'type': authority_type,
|
||||
'ttl': authority_ttl,
|
||||
'data': authority_data}
|
||||
|
||||
|
||||
def _parse_answer(answer):
|
||||
# www.cnn.com. 5 IN CNAME turner-tls.map.fastly.net.
|
||||
answer = answer.split(maxsplit=4)
|
||||
@ -442,6 +453,11 @@ def parse(data, raw=False, quiet=False):
|
||||
answer_list = []
|
||||
continue
|
||||
|
||||
if line.startswith(';; ADDITIONAL SECTION:'):
|
||||
section = 'additional'
|
||||
additional_list = []
|
||||
continue
|
||||
|
||||
# parse sections
|
||||
|
||||
if not line.startswith(';') and section == 'axfr':
|
||||
@ -460,7 +476,7 @@ def parse(data, raw=False, quiet=False):
|
||||
continue
|
||||
|
||||
if not line.startswith(';') and section == 'authority':
|
||||
authority_list.append(_parse_authority(line))
|
||||
authority_list.append(_parse_answer(line))
|
||||
output_entry.update({'authority': authority_list})
|
||||
continue
|
||||
|
||||
@ -469,6 +485,11 @@ def parse(data, raw=False, quiet=False):
|
||||
output_entry.update({'answer': answer_list})
|
||||
continue
|
||||
|
||||
if not line.startswith(';') and section == 'additional':
|
||||
additional_list.append(_parse_answer(line))
|
||||
output_entry.update({'additional': additional_list})
|
||||
continue
|
||||
|
||||
# footer consists of 4 lines
|
||||
# footer line 1
|
||||
if line.startswith(';; Query time:'):
|
||||
|
1
tests/fixtures/generic/dig-additional.json
vendored
Normal file
1
tests/fixtures/generic/dig-additional.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"id":12149,"opcode":"QUERY","status":"NOERROR","flags":["qr","rd"],"query_num":1,"answer_num":0,"authority_num":4,"additional_num":9,"opt_pseudosection":{"edns":{"version":0,"flags":[],"udp":4096}},"question":{"name":"google.com.","class":"IN","type":"NS"},"authority":[{"name":"google.com.","class":"IN","type":"NS","ttl":172800,"data":"ns2.google.com."},{"name":"google.com.","class":"IN","type":"NS","ttl":172800,"data":"ns1.google.com."},{"name":"google.com.","class":"IN","type":"NS","ttl":172800,"data":"ns3.google.com."},{"name":"google.com.","class":"IN","type":"NS","ttl":172800,"data":"ns4.google.com."}],"additional":[{"name":"ns2.google.com.","class":"IN","type":"AAAA","ttl":172800,"data":"2001:4860:4802:34::a"},{"name":"ns2.google.com.","class":"IN","type":"A","ttl":172800,"data":"216.239.34.10"},{"name":"ns1.google.com.","class":"IN","type":"AAAA","ttl":172800,"data":"2001:4860:4802:32::a"},{"name":"ns1.google.com.","class":"IN","type":"A","ttl":172800,"data":"216.239.32.10"},{"name":"ns3.google.com.","class":"IN","type":"AAAA","ttl":172800,"data":"2001:4860:4802:36::a"},{"name":"ns3.google.com.","class":"IN","type":"A","ttl":172800,"data":"216.239.36.10"},{"name":"ns4.google.com.","class":"IN","type":"AAAA","ttl":172800,"data":"2001:4860:4802:38::a"},{"name":"ns4.google.com.","class":"IN","type":"A","ttl":172800,"data":"216.239.38.10"}],"query_time":68,"server":"192.5.6.30#53(192.5.6.30)","when":"Mon Sep 03 19:23:20 EST 2018","rcvd":287,"when_epoch":1536027800,"when_epoch_utc":null}]
|
32
tests/fixtures/generic/dig-additional.out
vendored
Normal file
32
tests/fixtures/generic/dig-additional.out
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
; <<>> DiG 9.11.3-1ubuntu1.1-Ubuntu <<>> google.com NS @a.gtld-servers.net
|
||||
;; global options: +cmd
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12149
|
||||
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 4, ADDITIONAL: 9
|
||||
;; WARNING: recursion requested but not available
|
||||
|
||||
;; OPT PSEUDOSECTION:
|
||||
; EDNS: version: 0, flags:; udp: 4096
|
||||
;; QUESTION SECTION:
|
||||
;google.com. IN NS
|
||||
|
||||
;; AUTHORITY SECTION:
|
||||
google.com. 172800 IN NS ns2.google.com.
|
||||
google.com. 172800 IN NS ns1.google.com.
|
||||
google.com. 172800 IN NS ns3.google.com.
|
||||
google.com. 172800 IN NS ns4.google.com.
|
||||
|
||||
;; ADDITIONAL SECTION:
|
||||
ns2.google.com. 172800 IN AAAA 2001:4860:4802:34::a
|
||||
ns2.google.com. 172800 IN A 216.239.34.10
|
||||
ns1.google.com. 172800 IN AAAA 2001:4860:4802:32::a
|
||||
ns1.google.com. 172800 IN A 216.239.32.10
|
||||
ns3.google.com. 172800 IN AAAA 2001:4860:4802:36::a
|
||||
ns3.google.com. 172800 IN A 216.239.36.10
|
||||
ns4.google.com. 172800 IN AAAA 2001:4860:4802:38::a
|
||||
ns4.google.com. 172800 IN A 216.239.38.10
|
||||
|
||||
;; Query time: 68 msec
|
||||
;; SERVER: 192.5.6.30#53(192.5.6.30)
|
||||
;; WHEN: Mon Sep 03 19:23:20 EST 2018
|
||||
;; MSG SIZE rcvd: 287
|
1
tests/fixtures/generic/dig-additional2.json
vendored
Normal file
1
tests/fixtures/generic/dig-additional2.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"id":54105,"opcode":"QUERY","status":"NOERROR","flags":["qr","rd"],"query_num":1,"answer_num":0,"authority_num":10,"additional_num":5,"opt_pseudosection":{"edns":{"version":0,"flags":[],"udp":4096}},"question":{"name":"ultradns.com.","class":"IN","type":"NS"},"authority":[{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"pdns196.ultradns.com."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"pdns196.ultradns.net."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"pdns196.ultradns.org."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"pdns196.ultradns.info."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"pdns196.ultradns.biz."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"pdns196.ultradns.co.uk."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"ari.alpha.aridns.net.au."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"ari.beta.aridns.net.au."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"ari.gamma.aridns.net.au."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"ari.delta.aridns.net.au."}],"additional":[{"name":"pdns196.ultradns.com.","class":"IN","type":"A","ttl":172800,"data":"156.154.64.196"},{"name":"pdns196.ultradns.com.","class":"IN","type":"AAAA","ttl":172800,"data":"2001:502:f3ff::e8"},{"name":"pdns196.ultradns.net.","class":"IN","type":"A","ttl":172800,"data":"156.154.65.196"},{"name":"pdns196.ultradns.net.","class":"IN","type":"AAAA","ttl":172800,"data":"2610:a1:1014::e8"}],"query_time":72,"server":"192.5.6.30#53(192.5.6.30)","when":"Mon Sep 03 19:25:24 EST 2018","rcvd":432,"when_epoch":1536027924,"when_epoch_utc":null}]
|
34
tests/fixtures/generic/dig-additional2.out
vendored
Normal file
34
tests/fixtures/generic/dig-additional2.out
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
; <<>> DiG 9.11.3-1ubuntu1.1-Ubuntu <<>> ultradns.com NS @a.gtld-servers.net
|
||||
;; global options: +cmd
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54105
|
||||
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 10, ADDITIONAL: 5
|
||||
;; WARNING: recursion requested but not available
|
||||
|
||||
;; OPT PSEUDOSECTION:
|
||||
; EDNS: version: 0, flags:; udp: 4096
|
||||
;; QUESTION SECTION:
|
||||
;ultradns.com. IN NS
|
||||
|
||||
;; AUTHORITY SECTION:
|
||||
ultradns.com. 172800 IN NS pdns196.ultradns.com.
|
||||
ultradns.com. 172800 IN NS pdns196.ultradns.net.
|
||||
ultradns.com. 172800 IN NS pdns196.ultradns.org.
|
||||
ultradns.com. 172800 IN NS pdns196.ultradns.info.
|
||||
ultradns.com. 172800 IN NS pdns196.ultradns.biz.
|
||||
ultradns.com. 172800 IN NS pdns196.ultradns.co.uk.
|
||||
ultradns.com. 172800 IN NS ari.alpha.aridns.net.au.
|
||||
ultradns.com. 172800 IN NS ari.beta.aridns.net.au.
|
||||
ultradns.com. 172800 IN NS ari.gamma.aridns.net.au.
|
||||
ultradns.com. 172800 IN NS ari.delta.aridns.net.au.
|
||||
|
||||
;; ADDITIONAL SECTION:
|
||||
pdns196.ultradns.com. 172800 IN A 156.154.64.196
|
||||
pdns196.ultradns.com. 172800 IN AAAA 2001:502:f3ff::e8
|
||||
pdns196.ultradns.net. 172800 IN A 156.154.65.196
|
||||
pdns196.ultradns.net. 172800 IN AAAA 2610:a1:1014::e8
|
||||
|
||||
;; Query time: 72 msec
|
||||
;; SERVER: 192.5.6.30#53(192.5.6.30)
|
||||
;; WHEN: Mon Sep 03 19:25:24 EST 2018
|
||||
;; MSG SIZE rcvd: 432
|
1
tests/fixtures/generic/dig-additional3.json
vendored
Normal file
1
tests/fixtures/generic/dig-additional3.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"id":54105,"opcode":"QUERY","status":"NOERROR","flags":["qr","rd"],"query_num":1,"answer_num":0,"authority_num":10,"additional_num":5,"opt_pseudosection":{"edns":{"version":0,"flags":[],"udp":4096}},"question":{"name":"ultradns.com.","class":"IN","type":"NS"},"authority":[{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"pdns196.ultradns.com."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"pdns196.ultradns.net."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"pdns196.ultradns.org."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"pdns196.ultradns.info."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"pdns196.ultradns.biz."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"pdns196.ultradns.co.uk."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"ari.alpha.aridns.net.au."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"ari.beta.aridns.net.au."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"ari.gamma.aridns.net.au."},{"name":"ultradns.com.","class":"IN","type":"NS","ttl":172800,"data":"ari.delta.aridns.net.au."}],"answer":[{"name":"www.cnn.com.","class":"IN","type":"CNAME","ttl":93,"data":"turner-tls.map.fastly.net."},{"name":"turner-tls.map.fastly.net.","class":"IN","type":"A","ttl":8,"data":"151.101.193.67"},{"name":"turner-tls.map.fastly.net.","class":"IN","type":"A","ttl":8,"data":"151.101.65.67"},{"name":"turner-tls.map.fastly.net.","class":"IN","type":"A","ttl":8,"data":"151.101.1.67"},{"name":"turner-tls.map.fastly.net.","class":"IN","type":"A","ttl":8,"data":"151.101.129.67"}],"additional":[{"name":"pdns196.ultradns.com.","class":"IN","type":"A","ttl":172800,"data":"156.154.64.196"},{"name":"pdns196.ultradns.com.","class":"IN","type":"AAAA","ttl":172800,"data":"2001:502:f3ff::e8"},{"name":"pdns196.ultradns.net.","class":"IN","type":"A","ttl":172800,"data":"156.154.65.196"},{"name":"pdns196.ultradns.net.","class":"IN","type":"AAAA","ttl":172800,"data":"2610:a1:1014::e8"}],"query_time":72,"server":"192.5.6.30#53(192.5.6.30)","when":"Mon Sep 03 19:25:24 EST 2018","rcvd":432,"when_epoch":1536027924,"when_epoch_utc":null}]
|
41
tests/fixtures/generic/dig-additional3.out
vendored
Normal file
41
tests/fixtures/generic/dig-additional3.out
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
; <<>> DiG 9.11.3-1ubuntu1.1-Ubuntu <<>> ultradns.com NS @a.gtld-servers.net
|
||||
;; global options: +cmd
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54105
|
||||
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 10, ADDITIONAL: 5
|
||||
;; WARNING: recursion requested but not available
|
||||
|
||||
;; OPT PSEUDOSECTION:
|
||||
; EDNS: version: 0, flags:; udp: 4096
|
||||
;; QUESTION SECTION:
|
||||
;ultradns.com. IN NS
|
||||
|
||||
;; AUTHORITY SECTION:
|
||||
ultradns.com. 172800 IN NS pdns196.ultradns.com.
|
||||
ultradns.com. 172800 IN NS pdns196.ultradns.net.
|
||||
ultradns.com. 172800 IN NS pdns196.ultradns.org.
|
||||
ultradns.com. 172800 IN NS pdns196.ultradns.info.
|
||||
ultradns.com. 172800 IN NS pdns196.ultradns.biz.
|
||||
ultradns.com. 172800 IN NS pdns196.ultradns.co.uk.
|
||||
ultradns.com. 172800 IN NS ari.alpha.aridns.net.au.
|
||||
ultradns.com. 172800 IN NS ari.beta.aridns.net.au.
|
||||
ultradns.com. 172800 IN NS ari.gamma.aridns.net.au.
|
||||
ultradns.com. 172800 IN NS ari.delta.aridns.net.au.
|
||||
|
||||
;; ANSWER SECTION:
|
||||
www.cnn.com. 93 IN CNAME turner-tls.map.fastly.net.
|
||||
turner-tls.map.fastly.net. 8 IN A 151.101.193.67
|
||||
turner-tls.map.fastly.net. 8 IN A 151.101.65.67
|
||||
turner-tls.map.fastly.net. 8 IN A 151.101.1.67
|
||||
turner-tls.map.fastly.net. 8 IN A 151.101.129.67
|
||||
|
||||
;; ADDITIONAL SECTION:
|
||||
pdns196.ultradns.com. 172800 IN A 156.154.64.196
|
||||
pdns196.ultradns.com. 172800 IN AAAA 2001:502:f3ff::e8
|
||||
pdns196.ultradns.net. 172800 IN A 156.154.65.196
|
||||
pdns196.ultradns.net. 172800 IN AAAA 2610:a1:1014::e8
|
||||
|
||||
;; Query time: 72 msec
|
||||
;; SERVER: 192.5.6.30#53(192.5.6.30)
|
||||
;; WHEN: Mon Sep 03 19:25:24 EST 2018
|
||||
;; MSG SIZE rcvd: 432
|
@ -1 +1 @@
|
||||
[{"id":26965,"opcode":"QUERY","status":"NXDOMAIN","flags":["qr","rd","ra"],"query_num":1,"answer_num":0,"authority_num":1,"additional_num":1,"opt_pseudosection":{"edns":{"version":0,"flags":[],"udp":4096}},"question":{"name":"x.y.z.w.bl.spamcop.net.","class":"IN","type":"TXT"},"authority":[{"name":"bl.spamcop.net.","class":"IN","type":"SOA","ttl":0,"data":"bl.spamcop.net."}],"answer":[{"name":"x.y.z.w.bl.spamcop.net.","class":"IN","type":"TXT","ttl":2100,"data":"Blocked - see https://www.spamcop.net/bl.shtml?w.z.y.x"}],"query_time":297,"server":"192.168.1.254#53(192.168.1.254)","when":"Fri Feb 05 06:28:58 PST 2021","rcvd":104,"when_epoch":1612535338,"when_epoch_utc":null}]
|
||||
[{"id":26965,"opcode":"QUERY","status":"NXDOMAIN","flags":["qr","rd","ra"],"query_num":1,"answer_num":0,"authority_num":1,"additional_num":1,"opt_pseudosection":{"edns":{"version":0,"flags":[],"udp":4096}},"question":{"name":"x.y.z.w.bl.spamcop.net.","class":"IN","type":"TXT"},"authority":[{"name":"bl.spamcop.net.","class":"IN","type":"SOA","ttl":0,"data":"bl.spamcop.net. hostmaster.admin.spamcop.net. 1612535191 3600 1800 3600 0"}],"answer":[{"name":"x.y.z.w.bl.spamcop.net.","class":"IN","type":"TXT","ttl":2100,"data":"Blocked - see https://www.spamcop.net/bl.shtml?w.z.y.x"}],"query_time":297,"server":"192.168.1.254#53(192.168.1.254)","when":"Fri Feb 05 06:28:58 PST 2021","rcvd":104,"when_epoch":1612535338,"when_epoch_utc":null}]
|
||||
|
1
tests/fixtures/generic/dig-edns.json
vendored
Normal file
1
tests/fixtures/generic/dig-edns.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"id":24245,"opcode":"QUERY","status":"NOERROR","flags":["qr","rd","ra"],"query_num":1,"answer_num":1,"authority_num":0,"additional_num":1,"opt_pseudosection":{"edns":{"version":0,"flags":["do"],"udp":4096},"cookie":"b5dafd2648fa583b"},"question":{"name":"www.google.com.","class":"IN","type":"A"},"answer":[{"name":"www.google.com.","class":"IN","type":"A","ttl":177,"data":"216.58.195.132"}],"query_time":53,"server":"2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)","when":"Thu Apr 15 10:19:50 PDT 2021","rcvd":59,"when_epoch":1618507190,"when_epoch_utc":null}]
|
20
tests/fixtures/generic/dig-edns.out
vendored
Normal file
20
tests/fixtures/generic/dig-edns.out
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
; <<>> DiG 9.10.6 <<>> www.google.com
|
||||
;; global options: +cmd
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24245
|
||||
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
|
||||
|
||||
;; OPT PSEUDOSECTION:
|
||||
; EDNS: version: 0, flags: do; udp: 4096
|
||||
; COOKIE: b5dafd2648fa583b
|
||||
;; QUESTION SECTION:
|
||||
;www.google.com. IN A
|
||||
|
||||
;; ANSWER SECTION:
|
||||
www.google.com. 177 IN A 216.58.195.132
|
||||
|
||||
;; Query time: 53 msec
|
||||
;; SERVER: 2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)
|
||||
;; WHEN: Thu Apr 15 10:19:50 PDT 2021
|
||||
;; MSG SIZE rcvd: 59
|
||||
|
1
tests/fixtures/generic/dig-edns2.json
vendored
Normal file
1
tests/fixtures/generic/dig-edns2.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"id":8794,"opcode":"QUERY","status":"NOERROR","flags":["qr","rd","ra","ad"],"query_num":1,"answer_num":1,"authority_num":0,"additional_num":1,"opt_pseudosection":{"edns":{"version":0,"flags":[],"udp":512}},"question":{"name":"metebalci.com.","class":"IN","type":"A"},"answer":[{"name":"metebalci.com.","class":"IN","type":"A","ttl":59,"data":"104.198.14.52"}],"query_time":53,"server":"8.8.8.8#53(8.8.8.8)","when":"Fri Apr 16 14:19:58 PDT 2021","rcvd":58,"when_epoch":1618607998,"when_epoch_utc":null},{"id":39319,"opcode":"QUERY","status":"NOERROR","flags":["qr","rd","ra"],"query_num":1,"answer_num":1,"authority_num":0,"additional_num":1,"opt_pseudosection":{"edns":{"version":0,"flags":["do"],"udp":512}},"question":{"name":"google.com.","class":"IN","type":"A"},"answer":[{"name":"google.com.","class":"IN","type":"A","ttl":82,"data":"216.58.194.206"}],"query_time":32,"server":"8.8.8.8#53(8.8.8.8)","when":"Fri Apr 16 14:19:58 PDT 2021","rcvd":55,"when_epoch":1618607998,"when_epoch_utc":null}]
|
38
tests/fixtures/generic/dig-edns2.out
vendored
Normal file
38
tests/fixtures/generic/dig-edns2.out
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
; <<>> DiG 9.10.6 <<>> @8.8.8.8 metebalci.com google.com +dnssec
|
||||
; (1 server found)
|
||||
;; global options: +cmd
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8794
|
||||
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
|
||||
|
||||
;; OPT PSEUDOSECTION:
|
||||
; EDNS: version: 0, flags:; udp: 512
|
||||
;; QUESTION SECTION:
|
||||
;metebalci.com. IN A
|
||||
|
||||
;; ANSWER SECTION:
|
||||
metebalci.com. 59 IN A 104.198.14.52
|
||||
|
||||
;; Query time: 53 msec
|
||||
;; SERVER: 8.8.8.8#53(8.8.8.8)
|
||||
;; WHEN: Fri Apr 16 14:19:58 PDT 2021
|
||||
;; MSG SIZE rcvd: 58
|
||||
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39319
|
||||
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
|
||||
|
||||
;; OPT PSEUDOSECTION:
|
||||
; EDNS: version: 0, flags: do; udp: 512
|
||||
;; QUESTION SECTION:
|
||||
;google.com. IN A
|
||||
|
||||
;; ANSWER SECTION:
|
||||
google.com. 82 IN A 216.58.194.206
|
||||
|
||||
;; Query time: 32 msec
|
||||
;; SERVER: 8.8.8.8#53(8.8.8.8)
|
||||
;; WHEN: Fri Apr 16 14:19:58 PDT 2021
|
||||
;; MSG SIZE rcvd: 55
|
||||
|
1
tests/fixtures/generic/dig-edns3.json
vendored
Normal file
1
tests/fixtures/generic/dig-edns3.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"id":37727,"opcode":"QUERY","status":"NOERROR","flags":["qr","rd","ra","ad"],"query_num":1,"answer_num":3,"authority_num":0,"additional_num":1,"opt_pseudosection":{"edns":{"version":0,"flags":["do"],"udp":512}},"question":{"name":"metebalci.com.","class":"IN","type":"A"},"answer":[{"name":"metebalci.com.","class":"IN","type":"A","ttl":299,"data":"151.101.1.195"},{"name":"metebalci.com.","class":"IN","type":"A","ttl":299,"data":"151.101.65.195"},{"name":"metebalci.com.","class":"IN","type":"RRSIG","ttl":299,"data":"A 8 2 300 20181227144044 20181205144044 59764 metebalci.com. z6FupNLEU/8OcB3rNMkVqVaan05Xu89T8hV6+IC7LGjWPtrD+TlNJd8D cGeq8xJLR8b1Q+gBK0QSxpGvk89GaCTjNtMGHLBBdgpyV4syFv2BNzK7 iAJhA8QJ6i5xVFJdzMSsn3WvQvN1W71sirt8+56r1nQ47aVkBSLJoZKP lgw="}],"query_time":41,"server":"8.8.8.8#53(8.8.8.8)","when":"Fri Dec 07 14:09:43 CET 2018","rcvd":247,"when_epoch":1544220583,"when_epoch_utc":null}]
|
34
tests/fixtures/generic/dig-edns3.out
vendored
Normal file
34
tests/fixtures/generic/dig-edns3.out
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
; <<>> DiG 9.11.3-1ubuntu1.3-Ubuntu <<>> @8.8.8.8 metebalci.com +qr +dnssec
|
||||
; (1 server found)
|
||||
;; global options: +cmd
|
||||
;; Sending:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37727
|
||||
;; flags: rd ad; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
|
||||
|
||||
;; OPT PSEUDOSECTION:
|
||||
; EDNS: version: 0, flags: do; udp: 4096
|
||||
; COOKIE: a263795b817be1b1
|
||||
;; QUESTION SECTION:
|
||||
;metebalci.com. IN A
|
||||
|
||||
;; QUERY SIZE: 54
|
||||
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37727
|
||||
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
|
||||
|
||||
;; OPT PSEUDOSECTION:
|
||||
; EDNS: version: 0, flags: do; udp: 512
|
||||
;; QUESTION SECTION:
|
||||
;metebalci.com. IN A
|
||||
|
||||
;; ANSWER SECTION:
|
||||
metebalci.com. 299 IN A 151.101.1.195
|
||||
metebalci.com. 299 IN A 151.101.65.195
|
||||
metebalci.com. 299 IN RRSIG A 8 2 300 20181227144044 20181205144044 59764 metebalci.com. z6FupNLEU/8OcB3rNMkVqVaan05Xu89T8hV6+IC7LGjWPtrD+TlNJd8D cGeq8xJLR8b1Q+gBK0QSxpGvk89GaCTjNtMGHLBBdgpyV4syFv2BNzK7 iAJhA8QJ6i5xVFJdzMSsn3WvQvN1W71sirt8+56r1nQ47aVkBSLJoZKP lgw=
|
||||
|
||||
;; Query time: 41 msec
|
||||
;; SERVER: 8.8.8.8#53(8.8.8.8)
|
||||
;; WHEN: Fri Dec 07 14:09:43 CET 2018
|
||||
;; MSG SIZE rcvd: 247
|
||||
|
@ -58,6 +58,25 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/dig-answer-spaces.out'), 'r', encoding='utf-8') as f:
|
||||
self.generic_dig_answer_spaces = f.read()
|
||||
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/dig-additional.out'), 'r', encoding='utf-8') as f:
|
||||
self.generic_dig_additional = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/dig-additional2.out'), 'r', encoding='utf-8') as f:
|
||||
self.generic_dig_additional2 = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/dig-additional3.out'), 'r', encoding='utf-8') as f:
|
||||
self.generic_dig_additional3 = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/dig-edns.out'), 'r', encoding='utf-8') as f:
|
||||
self.generic_dig_edns = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/dig-edns2.out'), 'r', encoding='utf-8') as f:
|
||||
self.generic_dig_edns2 = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/dig-edns3.out'), 'r', encoding='utf-8') as f:
|
||||
self.generic_dig_edns3 = f.read()
|
||||
|
||||
# output
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/dig.json'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_dig_json = json.loads(f.read())
|
||||
@ -107,6 +126,25 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/dig-answer-spaces.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_dig_answer_spaces_json = json.loads(f.read())
|
||||
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/dig-additional.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_dig_additional_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/dig-additional2.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_dig_additional2_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/dig-additional3.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_dig_additional3_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/dig-edns.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_dig_edns_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/dig-edns2.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_dig_edns2_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/dig-edns3.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_dig_edns3_json = json.loads(f.read())
|
||||
|
||||
def test_dig_nodata(self):
|
||||
"""
|
||||
Test 'dig' with no data
|
||||
@ -209,6 +247,42 @@ class MyTests(unittest.TestCase):
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dig.parse(self.generic_dig_answer_spaces, quiet=True), self.generic_dig_answer_spaces_json)
|
||||
|
||||
def test_dig_additional(self):
|
||||
"""
|
||||
Test 'dig' with additional section
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dig.parse(self.generic_dig_additional, quiet=True), self.generic_dig_additional_json)
|
||||
|
||||
def test_dig_additional2(self):
|
||||
"""
|
||||
Test 'dig' with additional section
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dig.parse(self.generic_dig_additional2, quiet=True), self.generic_dig_additional2_json)
|
||||
|
||||
def test_dig_additional3(self):
|
||||
"""
|
||||
Test 'dig' with additional section
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dig.parse(self.generic_dig_additional3, quiet=True), self.generic_dig_additional3_json)
|
||||
|
||||
def test_dig_edns(self):
|
||||
"""
|
||||
Test 'dig' with edns info
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dig.parse(self.generic_dig_edns, quiet=True), self.generic_dig_edns_json)
|
||||
|
||||
def test_dig_edns2(self):
|
||||
"""
|
||||
Test 'dig' with edns info
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dig.parse(self.generic_dig_edns2, quiet=True), self.generic_dig_edns2_json)
|
||||
|
||||
def test_dig_edns3(self):
|
||||
"""
|
||||
Test 'dig' with edns info
|
||||
"""
|
||||
self.assertEqual(jc.parsers.dig.parse(self.generic_dig_edns3, quiet=True), self.generic_dig_edns3_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user