Skip to content

Commit

Permalink
Fixed potential issue with auth.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dries007 committed Aug 23, 2021
1 parent ff74401 commit 95fff30
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
31 changes: 18 additions & 13 deletions quarry/net/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
from quarry.net import http
from quarry.types.uuid import UUID

if sys.version_info[0] == 2:
from urllib import urlencode
else:
from urllib.parse import urlencode

SESSION_SERVER = b"https://sessionserver.mojang.com/session/minecraft/"


class ProfileException(http.HTTPException):
pass
Expand Down Expand Up @@ -38,13 +45,12 @@ def __init__(self, client_token, access_token, display_name, uuid):

def join(self, digest, refresh=True):
d1 = http.request(
url=b"https://sessionserver.mojang.com/session/minecraft/join",
url=SESSION_SERVER + b"join",
timeout=self.timeout,
err_type=AuthException,
data={
"accessToken": self.access_token,
"selectedProfile": self.uuid.to_hex(with_dashes=False),
"serverId": digest})
data={"accessToken": self.access_token,
"selectedProfile": self.uuid.to_hex(with_dashes=False),
"serverId": digest})

if not refresh:
return d1
Expand Down Expand Up @@ -163,7 +169,7 @@ def _from_response(cls, response):
@classmethod
def _request(cls, endpoint, **data):
return http.request(
url=b"https://authserver.mojang.com/"+endpoint,
url=b"https://authserver.mojang.com/" + endpoint,
timeout=cls.timeout,
err_type=ProfileException,
data=data)
Expand All @@ -173,7 +179,7 @@ def _get_profiles_path(cls):
dot_minecraft = ".minecraft"
if sys.platform == 'win32':
app_data = os.environ['APPDATA']
if sys.platform == 'darwin':
elif sys.platform == 'darwin':
app_data = os.path.expanduser("~/Library/Application Support")
dot_minecraft = "minecraft"
else:
Expand Down Expand Up @@ -220,13 +226,12 @@ def make_profile(cls, args):


def has_joined(timeout, digest, display_name, remote_host=None):
url = b"https://sessionserver.mojang.com/session/minecraft/hasJoined" + \
b"?username=" + display_name.encode('ascii') + \
b"&serverId=" + digest.encode('ascii')
if remote_host is not None:
url += b"&ip=" + remote_host.encode('ascii')
data = {"username": display_name, "serverId": digest}
if remote_host:
data["ip"] = remote_host

return http.request(
url=url,
url=SESSION_SERVER + b"hasJoined?" + urlencode(data).encode('ascii'),
timeout=timeout,
err_type=AuthException,
expect_content=True)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='quarry',
version='1.6.4',
version='1.7.0',
author='Barney Gale',
author_email='barney@barneygale.co.uk',
url='https://github.com/barneygale/quarry',
Expand Down

0 comments on commit 95fff30

Please sign in to comment.