mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-01-04 07:03:14 +08:00
cloudflare 525 error fix crashing qbit_manage
This commit is contained in:
parent
4cebab7b4a
commit
1decfdcd7f
3 changed files with 17 additions and 2 deletions
|
@ -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")
|
||||
|
||||
|
|
|
@ -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}")
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue