Commit 97e6119c authored by Alexandre's avatar Alexandre
Browse files

Refactoring

parent 5e08350e
......@@ -78,18 +78,8 @@ class ConnectionDOT(Connection):
self.sni = sni
self.key = key
self.pipelining = pipelining
if self.pipelining:
self.all_requests = [] # Currently, we load everything in memory
# since we want to keep everything,
# anyway. May be in the future, if we don't
# want to keep individual results, we'll use
# an iterator to fill a smaller table.
# all_requests is indexed by its rank in the input file.
self.pending = {} # pending is indexed by the query ID, and its
# maximum size is max_in_flight.
# establish the connection
self.connect()
self.connect() # establish the connection
def connect(self):
# if connect_to is defined, it means we know the IP address of the
......@@ -323,7 +313,7 @@ class ConnectionDOT(Connection):
# look for a potential response
if self.verbose:
print('Looking for a response...')
id = self.read_result(self.pending)
id = self.pipelining_read_result(self.pending)
if id is None: # nothing to read for now
if self.n_in_flight >= min(max_in_flight, len(requests_list)): # we need to wait a little bit
time.sleep(homer.SLEEP_TIMEOUT)
......@@ -338,12 +328,10 @@ class ConnectionDOT(Connection):
# this method might need to be moved somewhere else in order to avoid
# calling dns.message.from_wire()
def read_result(self, requests, display_results=True):
rcode, data, size = self.receive_data() # TODO can raise
# OpenSSL.SSL.ZeroReturnError
# if the
# connection was
# closed
def pipelining_read_result(self, requests, display_results=True):
rcode, data, size = self.receive_data() # can raise
# OpenSSL.SSL.ZeroReturnError
# if the connection was closed
if not rcode:
if display_results:
print("TIMEOUT")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment