fix(block): handle blocked url with no corresponding proxy
This commit is contained in:
parent
f4662fae27
commit
226c67eb65
1 changed files with 4 additions and 3 deletions
|
@ -2,7 +2,7 @@ from datetime import datetime, timedelta
|
|||
import logging
|
||||
from abc import abstractmethod
|
||||
import fnmatch
|
||||
from typing import Tuple, List, Any
|
||||
from typing import Tuple, List, Any, Optional
|
||||
|
||||
from app.extensions import db
|
||||
from app.models.activity import Activity
|
||||
|
@ -30,7 +30,8 @@ class BlockMirrorAutomation(BaseAutomation):
|
|||
for pattern in self.patterns:
|
||||
blocked_urls = fnmatch.filter(proxy_urls, pattern)
|
||||
for blocked_url in blocked_urls:
|
||||
proxy = proxy_by_url(blocked_url)
|
||||
if not (proxy := proxy_by_url(blocked_url)):
|
||||
continue
|
||||
logging.debug("Found %s blocked", proxy.url)
|
||||
if not proxy.origin.auto_rotation:
|
||||
logging.debug("Proxy auto-rotation forbidden for origin")
|
||||
|
@ -79,7 +80,7 @@ def active_proxy_urls() -> List[str]:
|
|||
).all()]
|
||||
|
||||
|
||||
def proxy_by_url(url: str) -> Proxy:
|
||||
def proxy_by_url(url: str) -> Optional[Proxy]:
|
||||
return Proxy.query.filter( # type: ignore[no-any-return]
|
||||
Proxy.deprecated.is_(None),
|
||||
Proxy.destroyed.is_(None),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue