Minor update

This commit is contained in:
Miroslav Stampar
2026-01-05 00:31:50 +01:00
parent 5864dd4949
commit 69eca57915
3 changed files with 10 additions and 5 deletions

View File

@@ -89,17 +89,22 @@ class DNSServer(object):
def _check_localhost(self):
response = b""
s = None
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(1.0)
s.connect(("", 53))
s.send(binascii.unhexlify("6509012000010000000000010377777706676f6f676c6503636f6d00000100010000291000000000000000")) # A www.google.com
response = s.recv(512)
except:
pass
finally:
if response and b"google" in response:
raise socket.error("another DNS service already running on '0.0.0.0:53'")
if s:
s.close()
if response and b"google" in response:
raise socket.error("another DNS service already running on '0.0.0.0:53'")
def pop(self, prefix=None, suffix=None):
"""