Skip to content

Commit

Permalink
Ignore garbage queries
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkst-marco committed Oct 19, 2021
1 parent 0b388dc commit ea1ea01
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion channel_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import math
import base64
import re
from exceptions import UnicodeDecodeError

class DNSServerFactory(server.DNSServerFactory, object):
def handleQuery(self, message, protocol, address):
Expand All @@ -30,7 +31,12 @@ def handleQuery(self, message, protocol, address):
else:
src_ip = protocol.transport.socket.getpeername()[0]

log.info('Query: {} sent {}'.format(src_ip, query))
try:
log.info('Query: {} sent {}'.format(src_ip, query))
except UnicodeDecodeError:
# Invalid query
return None

return self.resolver.query(query, src_ip).addCallback(
self.gotResolverResponse, protocol, message, address
).addErrback(
Expand Down

0 comments on commit ea1ea01

Please sign in to comment.