Skip to content

Commit

Permalink
Use newer version of dnspython
Browse files Browse the repository at this point in the history
Fixes #132
  • Loading branch information
kevinkjt2000 committed Jun 1, 2021
1 parent a552293 commit 68882a9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![travis build status]( https://img.shields.io/travis/Dinnerbone/mcstatus/master.svg)
![travis build status](https://img.shields.io/travis/Dinnerbone/mcstatus/master.svg)
![current version](https://img.shields.io/pypi/v/mcstatus.svg)
![supported python versions](https://img.shields.io/pypi/pyversions/mcstatus.svg)

Expand Down
4 changes: 2 additions & 2 deletions mcstatus/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def lookup(address: str):
if port is None:
port = 25565
try:
answers = dns.resolver.query("_minecraft._tcp." + host, "SRV")
answers = dns.resolver.resolve("_minecraft._tcp." + host, "SRV")
if len(answers):
answer = answers[0]
host = str(answer.target).rstrip(".")
Expand Down Expand Up @@ -148,7 +148,7 @@ def query(self, tries: int = 3):
exception = None
host = self.host
try:
answers = dns.resolver.query(host, "A")
answers = dns.resolver.resolve(host, "A")
if len(answers):
answer = answers[0]
host = str(answer).rstrip(".")
Expand Down
18 changes: 9 additions & 9 deletions mcstatus/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,29 +161,29 @@ def test_query_retry(self):
assert querier.call_count == 3

def test_by_address_no_srv(self):
with patch("dns.resolver.query") as query:
query.return_value = []
with patch("dns.resolver.resolve") as resolve:
resolve.return_value = []
self.server = MinecraftServer.lookup("example.org")
query.assert_called_once_with("_minecraft._tcp.example.org", "SRV")
resolve.assert_called_once_with("_minecraft._tcp.example.org", "SRV")
assert self.server.host == "example.org"
assert self.server.port == 25565

def test_by_address_invalid_srv(self):
with patch("dns.resolver.query") as query:
query.side_effect = [Exception]
with patch("dns.resolver.resolve") as resolve:
resolve.side_effect = [Exception]
self.server = MinecraftServer.lookup("example.org")
query.assert_called_once_with("_minecraft._tcp.example.org", "SRV")
resolve.assert_called_once_with("_minecraft._tcp.example.org", "SRV")
assert self.server.host == "example.org"
assert self.server.port == 25565

def test_by_address_with_srv(self):
with patch("dns.resolver.query") as query:
with patch("dns.resolver.resolve") as resolve:
answer = Mock()
answer.target = "different.example.org."
answer.port = 12345
query.return_value = [answer]
resolve.return_value = [answer]
self.server = MinecraftServer.lookup("example.org")
query.assert_called_once_with("_minecraft._tcp.example.org", "SRV")
resolve.assert_called_once_with("_minecraft._tcp.example.org", "SRV")
assert self.server.host == "different.example.org"
assert self.server.port == 12345

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
asyncio-dgram>=1.2.0
click>=7.1.1
dnspython3>=1.15.0
dnspython>=2.1.0
six>=1.14.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name="mcstatus",
version="5.2.0",
version="6.0.0",
author="Nathan Adams",
author_email="[email protected]",
url="https://pypi.python.org/pypi/mcstatus",
Expand Down

0 comments on commit 68882a9

Please sign in to comment.