1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-15 01:24:29 +02:00

add authority parsing

This commit is contained in:
Kelly Brazil
2019-10-30 17:18:14 -07:00
parent d3e1aa20a8
commit d1f64214de

View File

@ -82,7 +82,19 @@ def parse_question(question):
def parse_authority(authority): def parse_authority(authority):
return {} # 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): def parse_answer(answer):
@ -135,16 +147,20 @@ def parse(data):
if question: if question:
output_entry['question'] = parse_question(line) output_entry['question'] = parse_question(line)
question = False question = False
authority = False
answer = False
continue continue
if line.find(';; AUTHORITY SECTION:') == 0: if line.find(';; AUTHORITY SECTION:') == 0:
question = False question = False
authority = True authority = True
answer = False answer = False
authority_list = []
continue continue
if authority: if line.find(';') == -1 and authority:
output_entry['authority'] = parse_authority(line) authority_list.append(parse_authority(line))
output_entry.update({'authority': authority_list})
continue continue
if line.find(';; ANSWER SECTION:') == 0: if line.find(';; ANSWER SECTION:') == 0: