Beispiel #1
0
 def do_query(self, q, ip):
     """do_query(self, q, ip)
     Execute a request to the given IP.
     q is a query tuple of (qname, qtype, qclass, recursion)
     This will generate the query ID.
     Returns a dns_reply object.
     """
     if self.outstanding_sem.avail <= 0:
         # we've hit a system resource limit
         LOG ('limit', self.max_outstanding)
     self.outstanding_sem.acquire(1)
     try:
         qid = dns_random (65536)
         reply = self.send_request ((qid, ip, q))
         if reply.tc:
             # truncated, try tcp
             qid = dns_random (65536)
             return self.send_request ((qid, ip, q), use_tcp=1)
         else:
             return reply
     finally:
         self.outstanding_sem.release(1)
Beispiel #2
0
 def do_query(self, q, ip):
     """do_query(self, q, ip)
     Execute a request to the given IP.
     q is a query tuple of (qname, qtype, qclass, recursion)
     This will generate the query ID.
     Returns a dns_reply object.
     """
     if self.outstanding_sem.avail<=0:
         # we've hit a system resource limit
         # we use max_outstanding twice here because the log message wants "current" and "max"
         # but these are always going to be the same in the dns server
         self.log('DNS.LIMIT', self.max_outstanding, self.max_outstanding)
     self.outstanding_sem.acquire(1)
     try:
         qid = dns_random (65536)
         reply = self.send_request ((qid, ip, q))
         if reply.tc:
             # truncated, try tcp
             qid = dns_random (65536)
             return self.send_request ((qid, ip, q), use_tcp=1)
         else:
             return reply
     finally:
         self.outstanding_sem.release(1)
Beispiel #3
0
 def do_query(self, q, ip):
     """do_query(self, q, ip)
     Execute a request to the given IP.
     q is a query tuple of (qname, qtype, qclass, recursion)
     This will generate the query ID.
     Returns a dns_reply object.
     """
     if self.outstanding_sem.avail <= 0:
         # we've hit a system resource limit
         # we use max_outstanding twice here because the log message wants "current" and "max"
         # but these are always going to be the same in the dns server
         self.log('DNS.LIMIT', self.max_outstanding, self.max_outstanding)
     self.outstanding_sem.acquire(1)
     try:
         qid = dns_random(65536)
         reply = self.send_request((qid, ip, q))
         if reply.tc:
             # truncated, try tcp
             qid = dns_random(65536)
             return self.send_request((qid, ip, q), use_tcp=1)
         else:
             return reply
     finally:
         self.outstanding_sem.release(1)