cloudflare 525 error fix crashing qbit_manage

This commit is contained in:
bobokun 2021-12-20 10:11:52 -05:00
parent 4cebab7b4a
commit 1decfdcd7f
No known key found for this signature in database
GPG key ID: 9665BA6CF5DC2671
3 changed files with 17 additions and 2 deletions

View file

@ -110,7 +110,10 @@ class Config:
})
except Failed as e:
logger.error(e)
logger.info(f"Notifiarr Connection {'Failed' if self.NotifiarrFactory is None else 'Successful'}")
notifiarr_error = str(e)
if '525' in notifiarr_error:
self.NotifiarrFactory = notifiarr_error
logger.info(f"Notifiarr Connection {'Failed' if self.NotifiarrFactory is (None or notifiarr_error) else 'Successful'}")
else:
logger.warning("Config Warning: notifiarr attribute not found")

View file

@ -1,6 +1,7 @@
import logging
from modules.util import Failed
from json import JSONDecodeError
logger = logging.getLogger("qBit Manage")
@ -17,7 +18,14 @@ class Notifiarr:
self.instance = params["instance"]
url, _ = self.get_url("user/validate/")
response = self.config.get(url)
response_json = response.json()
try:
response_json = response.json()
except JSONDecodeError:
if response.status_code >= 400:
if response.status_code == 525:
raise Failed(f"Notifiarr Error (Response: 525): SSL handshake between Cloudflare and the origin web server failed.")
else:
raise Failed(f"({response.status_code} [{response.reason}])")
if response.status_code >= 400 or ("result" in response_json and response_json["result"] == "error"):
logger.debug(f"Response: {response_json}")
raise Failed(f"({response.status_code} [{response.reason}]) {response_json}")

View file

@ -29,6 +29,10 @@ class Webhooks:
if self.config.trace_mode:
logger.debug(f"Webhook: {webhook}")
if webhook == "notifiarr":
if self.notifiarr is None:
raise Failed(f"Webhook attribute set to notifiarr but notifiarr attribute is not configured.")
elif '525' in self.notifiarr:
raise Failed(self.notifiarr)
url, params = self.notifiarr.get_url("notification/qbitManage/")
for x in range(6):
response = self.config.get(url, json=json, params=params)