feat: add timeouts to all requests requests
This commit is contained in:
parent
2498f408c8
commit
fff38fa994
7 changed files with 10 additions and 7 deletions
|
@ -66,4 +66,4 @@ class Webhook(AbstractConfiguration):
|
|||
else:
|
||||
# Matrix as default
|
||||
data = {"body": text}
|
||||
requests.post(self.url, json=data)
|
||||
requests.post(self.url, json=data, timeout=30)
|
||||
|
|
|
@ -14,7 +14,8 @@ class BlockBridgeScriptzteamAutomation(BlockBridgelinesAutomation):
|
|||
|
||||
def fetch(self) -> None:
|
||||
r = requests.get(
|
||||
"https://raw.githubusercontent.com/scriptzteam/Tor-Bridges-Collector/main/bridges-obfs4")
|
||||
"https://raw.githubusercontent.com/scriptzteam/Tor-Bridges-Collector/main/bridges-obfs4",
|
||||
timeout=60)
|
||||
r.encoding = "utf-8"
|
||||
contents = r.text
|
||||
self._lines = contents.splitlines()
|
||||
|
|
|
@ -20,7 +20,8 @@ class BlockBridgeDnscAutomation(BlockBridgeAutomation):
|
|||
def fetch(self) -> None:
|
||||
response = requests.get(DOWNLOAD_URL,
|
||||
headers={"User-Agent": "Mozilla/5.0 (Windows NT x.y; Win64; x64; rv:10.0) "
|
||||
"Gecko/20100101 Firefox/10.0"})
|
||||
"Gecko/20100101 Firefox/10.0"},
|
||||
timeout=60)
|
||||
self._content = BytesIO(response.content)
|
||||
|
||||
def parse(self) -> None:
|
||||
|
|
|
@ -13,7 +13,7 @@ class BlockBridgeRoskomsvobodaAutomation(BlockBridgeAutomation):
|
|||
_data: Any
|
||||
|
||||
def fetch(self) -> None:
|
||||
self._data = requests.get("https://reestr.rublacklist.net/api/v3/ips/").json()
|
||||
self._data = requests.get("https://reestr.rublacklist.net/api/v3/ips/", timeout=180).json()
|
||||
|
||||
def parse(self) -> None:
|
||||
self.ips.extend(self._data)
|
||||
|
|
|
@ -16,7 +16,7 @@ class BlockExternalAutomation(BlockMirrorAutomation):
|
|||
|
||||
def fetch(self) -> None:
|
||||
user_agent = {'User-agent': 'BypassCensorship/1.0'}
|
||||
page = requests.get(app.config['EXTERNAL_CHECK_URL'], headers=user_agent)
|
||||
page = requests.get(app.config['EXTERNAL_CHECK_URL'], headers=user_agent, timeout=30)
|
||||
self._content = page.content
|
||||
|
||||
def parse(self) -> None:
|
||||
|
|
|
@ -22,7 +22,7 @@ def check_origin(domain_name: str) -> Dict[str, Any]:
|
|||
|
||||
def _check_origin(api_url: str, result: Dict[str, Any]) -> Dict[str, Any]:
|
||||
print(f"Processing {api_url}")
|
||||
req = requests.get(api_url).json()
|
||||
req = requests.get(api_url, timeout=30).json()
|
||||
if 'results' not in req or not req['results']:
|
||||
return result
|
||||
for r in req['results']:
|
||||
|
|
|
@ -23,7 +23,8 @@ class BlockRoskomsvobodaAutomation(BlockMirrorAutomation):
|
|||
_data: Any
|
||||
|
||||
def fetch(self) -> None:
|
||||
self._data = requests.get("https://reestr.rublacklist.net/api/v3/domains/").json()
|
||||
self._data = requests.get("https://reestr.rublacklist.net/api/v3/domains/",
|
||||
timeout=180).json()
|
||||
|
||||
def parse(self) -> None:
|
||||
self.patterns.extend(["https://" + pattern for pattern in self._data])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue