Skip to content

Commit

Permalink
Fix Bug in Recursive Resolve (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
anchal00 committed Aug 5, 2024
1 parent ba343b1 commit 1eab080
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
4 changes: 2 additions & 2 deletions optimus/bin_data_reader/bin_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ def get_cur_ptr_pos(self) -> int:

def read_bytes_and_move(self, bytes_to_read) -> bytearray:
cur_ptr_pos = self.get_cur_ptr_pos()
return self.__bin_data_block[cur_ptr_pos: cur_ptr_pos + bytes_to_read]
return self.__bin_data_block[cur_ptr_pos : cur_ptr_pos + bytes_to_read]

def parse_bytes_to_int(self, bytes_to_parse: int) -> int:
cur_ptr_pos = self.get_cur_ptr_pos()
to_be_read_data_block = self.__bin_data_block[
cur_ptr_pos: cur_ptr_pos + bytes_to_parse
cur_ptr_pos : cur_ptr_pos + bytes_to_parse
]
data = 0
for x in to_be_read_data_block:
Expand Down
14 changes: 2 additions & 12 deletions optimus/dns/dns_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,8 @@

from optimus.bin_data_reader.bin_reader import BinReader
from optimus.dns.dns_packet import DNSHeader, DNSPacket, Question, ResponseCode
from optimus.dns.dns_records import (
AAAA,
CNAME,
MX,
NS,
SOA,
A,
OptPseudoRR,
Record,
RecordClass,
RecordType,
)
from optimus.dns.dns_records import (AAAA, CNAME, MX, NS, SOA, A, OptPseudoRR,
Record, RecordClass, RecordType)


class DNSParser:
Expand Down
1 change: 1 addition & 0 deletions optimus/dns/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def __perform_recursive_lookup(qpacket: DNSPacket) -> DNSPacket:
id=random.randint(0, int(math.pow(2, 16)) - 1),
is_query=True,
question_count=1,
is_recursion_desired=True,
),
questions=[
Question(ns_record.nsdname, RecordType.A, RecordClass.IN)
Expand Down
1 change: 0 additions & 1 deletion optimus/optimus_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ def run_server(port: int, worker_threads: int):
while True:
received_bytes, address = master_socket.recvfrom(600)
pool.submit(handle_request, master_socket, received_bytes, address)
handle_request(master_socket, received_bytes, address)

0 comments on commit 1eab080

Please sign in to comment.