chore(webrequest): test if endpoints are available at init
This commit is contained in:
@@ -26,7 +26,9 @@ SIGNATURE = "RDS_SIGNATURE"
|
||||
EDITION = "RDS_EDITION"
|
||||
ISBN = "RDS_ISBN"
|
||||
AUTHOR = "RDS_PERSON"
|
||||
|
||||
ALLOWED_IPS = [
|
||||
"193.197.140.245", # PHFR Internal
|
||||
]
|
||||
HEADERS = {
|
||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 \
|
||||
(HTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36",
|
||||
@@ -56,10 +58,11 @@ class WebRequest:
|
||||
self.data = None
|
||||
self.timeout = 5
|
||||
self.public_ip = None
|
||||
self._can_run()
|
||||
if self.public_ip not in ALLOWED_IPS:
|
||||
raise PermissionError("IP not allowed to access the requested data.")
|
||||
|
||||
self.canrun()
|
||||
|
||||
def canrun(self) -> None:
|
||||
def _can_run(self) -> None:
|
||||
"""Check if requests can be made."""
|
||||
try:
|
||||
# check public IP to see if the requested data can be accessed
|
||||
|
||||
Reference in New Issue
Block a user