1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

simplify answer data logic

This commit is contained in:
Kelly Brazil
2021-02-10 10:55:53 -08:00
parent f450f9eb8b
commit 283b89e37c
2 changed files with 5 additions and 4 deletions

View File

@ -1,7 +1,8 @@
jc changelog jc changelog
20210209 v1.14.3 202102010 v1.14.3
- Add hciconfig parser tested on linux - Add hciconfig parser tested on linux
- Update dig parser to simplify answer data logic
20210205 v1.14.2 20210205 v1.14.2
- Update dig parser to fix cases where there are spaces in the answer data (e.g. TXT records) - Update dig parser to fix cases where there are spaces in the answer data (e.g. TXT records)

View File

@ -333,7 +333,7 @@ import jc.utils
class info(): class info():
version = '1.4' version = '1.5'
description = 'dig command parser' description = 'dig command parser'
author = 'Kelly Brazil' author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com' author_email = 'kellyjonbrazil@gmail.com'
@ -521,12 +521,12 @@ def parse_authority(authority):
def parse_answer(answer): def parse_answer(answer):
# www.cnn.com. 5 IN CNAME turner-tls.map.fastly.net. # www.cnn.com. 5 IN CNAME turner-tls.map.fastly.net.
answer = answer.split() answer = answer.split(maxsplit=4)
answer_name = answer[0] answer_name = answer[0]
answer_class = answer[2] answer_class = answer[2]
answer_type = answer[3] answer_type = answer[3]
answer_ttl = answer[1] answer_ttl = answer[1]
answer_data = ' '.join(answer[4:]) answer_data = answer[4]
# remove surrounding quotation marks from answer_data if they exist # remove surrounding quotation marks from answer_data if they exist
if answer_data.startswith('"') and answer_data.endswith('"'): if answer_data.startswith('"') and answer_data.endswith('"'):