Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def lookup(address):
host, port = parse_address(address)
if port is None:
port = 25565
try:
answers = dns.resolver.query("_minecraft._tcp." + host, "SRV")
if len(answers):
answer = answers[0]
host = str(answer.target).rstrip(".")
port = int(answer.port)
except Exception:
pass
return MinecraftServer(host, port)