Commit ed01daa4 authored by Alexandre's avatar Alexandre
Browse files

[DoT] Create methods to send and receive data

parent c375f586
......@@ -373,14 +373,20 @@ class ConnectionDoT(Connection):
self.session.shutdown()
self.session.close()
def do_test(self, qname, qtype=rtype):
self.request = RequestDoT(qname, qtype)
length = len(self.request.data)
self.session.send(length.to_bytes(2, byteorder='big') + self.request.data)
def send_data(self, data):
length = len(data)
self.session.send(length.to_bytes(2, byteorder='big') + data)
def receive_data(self):
buf = self.session.recv(2)
self.request.received = int.from_bytes(buf, byteorder='big')
buf = self.session.recv(self.request.received)
self.request.response = dns.message.from_wire(buf)
def do_test(self, qname, qtype=rtype):
self.request = RequestDoT(qname, qtype)
self.send_data(self.request.data)
self.receive_data()
self.request.check_response()
return (True, self.request.response, self.request.received)
......
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