Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Implemented temporary patch to bypass verifying SSL certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
ricky-davis committed Sep 30, 2021
1 parent 384e366 commit 03a2d5d
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 73 deletions.
13 changes: 10 additions & 3 deletions AstroLauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,11 @@ def update_server(self, latest_version):

def check_for_server_update(self, serverStart=False, check_only=False):
try:

# print('here1')
if not self.launcherConfig.UpdateOnServerRestart and serverStart:
return
else:
# print('here2')
needs_update = False
update_status = None
if os.path.exists("update.p"):
Expand All @@ -519,18 +520,22 @@ def check_for_server_update(self, serverStart=False, check_only=False):
if update_status != "completed":
needs_update = True

# print('here3')
cur_version = "0.0"
try:
with open(os.path.join(self.astroPath, "build.version"), "r") as f:
cur_version = (f.readline())[:-10]
except:
pass
# print(cur_version)
# print('here4')
if cur_version == "0.0":
needs_update = True
url = "https://servercheck.spycibot.com/stats"
data = json.load((AstroRequests.get(url)))
data = json.load(AstroRequests.get(url))
print(data)

# print('here6')
latest_version = data['LatestVersion']
if version.parse(latest_version) > version.parse(cur_version):
needs_update = True
Expand All @@ -540,15 +545,17 @@ def check_for_server_update(self, serverStart=False, check_only=False):
AstroLogging.logPrint(
f"SERVER UPDATE AVAILABLE: {cur_version} -> {latest_version}", "warning")

# print('here7')
if self.launcherConfig.AutoUpdateServerSoftware and not check_only:
self.update_server(latest_version)
# print('here8')
return True, latest_version

cur_version = "0.0"
with open(os.path.join(self.astroPath, "build.version"), "r") as f:
cur_version = (f.readline())[:-10]
self.cur_server_version = cur_version

# print('here9')
except Exception as e:
print(e)
AstroLogging.logPrint(
Expand Down
126 changes: 68 additions & 58 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions cogs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import urllib
import urllib.error
from urllib import request
import ssl

# pylint: disable=no-member

Expand All @@ -15,9 +16,11 @@ def get(cls, url, timeout=5):
proxies = request.getproxies()
proxy_handler = request.ProxyHandler(proxies)
opener = request.build_opener(proxy_handler)
gcontext = ssl.SSLContext()
request.install_opener(opener)
# print(f"get: {proxies}")
resp = request.urlopen(url, timeout=timeout)
#print(f"get: {proxies}")
resp = request.urlopen(url, timeout=timeout, context=gcontext)
# print(resp)
return resp # cls.session.get(url, verify=False, timeout=timeout)

@classmethod
Expand All @@ -30,6 +33,7 @@ def post(cls, url, headers=None, jsonD=None, timeout=5):
if jsonD != {}:
jsonD = json.dumps(jsonD).encode('utf-8')
req.add_header('Content-Type', 'application/json; charset=utf-8')
gcontext = ssl.SSLContext()

# print(f"data: {jsonD}")
# print(f"headers:{headers}")
Expand All @@ -43,7 +47,8 @@ def post(cls, url, headers=None, jsonD=None, timeout=5):
# print(f"post: {proxies}")
# print(f"url: {url}")
try:
resp = request.urlopen(req, data=jsonD, timeout=timeout)
resp = request.urlopen(
req, data=jsonD, timeout=timeout, context=gcontext)
except urllib.error.HTTPError as e:
resp = e
return resp
18 changes: 9 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
#

-i https://pypi.org/simple
altgraph==0.17
altgraph==0.17.2
asyncio==3.4.3
colorlog==5.0.1
importlib-metadata==4.6.4; python_version < '3.8'
colorlog==6.4.1
importlib-metadata==4.8.1; python_version < '3.8'
ipy==1.1
packaging==21.0
pathvalidate==2.4.1
pathvalidate==2.5.0
psutil==5.8.0
pyinstaller-hooks-contrib==2021.2
pyinstaller-hooks-contrib==2021.3
pyinstaller==4.5.1
pypakparser==1.2.0
pyparsing==2.4.7; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
pyparsing==2.4.7; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'
tornado==6.1
typing-extensions==3.10.0.0; python_version < '3.8'
watchdog==2.1.3
zipp==3.5.0; python_version >= '3.6'
typing-extensions==3.10.0.2; python_version < '3.8'
watchdog==2.1.5
zipp==3.6.0; python_version >= '3.6'

0 comments on commit 03a2d5d

Please sign in to comment.