Exemplo n.º 1
0
def on_result_response(*args):
    #Store probe statistics in Redis
    #print (args[0]['prb_id'])
    if 'result' in args[0]:
        result = args[0]['result']
        if 'answers' in result:
            #process_answers(data=result['answers'])
            logging.disable(logging.WARNING)
            res = DnsResult.get(args[0], parse_buf=True)
            logging.basicConfig(level=defaultloglevel)
            if res.is_error:
                return True
            if (res.responses[0].abuf.answers):
                for answer in res.responses[0].abuf.answers:
                    process_answers(data=answer['raw_data'], sagan=True)

        # print (result['answers'])
        else:
            # Some of the records are not automatically decoded and need to pass
            # into ripe.atlas.sagan firat
            logging.disable(logging.WARNING)
            res = DnsResult.get(args[0], parse_buf=True)
            logging.basicConfig(level=defaultloglevel)
            if res.is_error:
                return True
            if (res.responses[0].abuf.answers):
                for answer in res.responses[0].abuf.answers:
                    process_answers(data=answer['raw_data'], sagan=True)
Exemplo n.º 2
0
 def print_nicely(self, limit):
     with open(self.filename) as results:
         i = 0
         for result in results.readlines():
             if limit is not None:
                 if i >= limit:
                     return
             parsed_result = DnsResult.get(result)
             print("PROBE ID:        "+str(parsed_result.probe_id))
             print("firmware:        "+str(parsed_result.firmware))
             print("origin:            "+parsed_result.origin)
             print("measurement type:    "+self.measurement_type)
             self._print_dns_nicely(parsed_result)
             print("\n")
             i +=1
Exemplo n.º 3
0
 def print_nicely(self, limit):
     with open(self.filename) as results:
         i = 0
         for result in results.readlines():
             if limit is not None:
                 if i >= limit:
                     return
             parsed_result = DnsResult.get(result)
             print("PROBE ID:        "+str(parsed_result.probe_id))
             print("firmware:        "+str(parsed_result.firmware))
             print("origin:            "+parsed_result.origin)
             print("measurement type:    "+self.measurement_type)
             self._print_dns_nicely(parsed_result)
             print("\n")
             i +=1
Exemplo n.º 4
0
    def _get_list_of_qtypes(self):
        list_of_qtypes = []

        with open(self.filename) as results:
            for this_result in results:
                parsed_result = DnsResult.get(this_result)
                response_list = parsed_result.responses

                for this_response in response_list:
                    this_abuf = this_response.abuf
                    list_of_questions = this_abuf.questions
                    for this_question in list_of_questions:
                        this_qtype = this_question.type
                        list_of_qtypes.append(this_qtype)

        return list_of_qtypes
Exemplo n.º 5
0
    def _get_list_of_qtypes(self):
        list_of_qtypes = []

        with open(self.filename) as results:
            for this_result in results:
                parsed_result = DnsResult.get(this_result)
                response_list = parsed_result.responses

                for this_response in response_list:
                    this_abuf = this_response.abuf
                    list_of_questions = this_abuf.questions
                    for this_question in list_of_questions:
                        this_qtype = this_question.type
                        list_of_qtypes.append(this_qtype)

        return list_of_qtypes