mirrors: allow selective auto-rotation
This commit is contained in:
parent
18e046dc42
commit
80890c2127
5 changed files with 25 additions and 34 deletions
|
@ -7,7 +7,7 @@ from app.models.mirrors import Proxy
|
|||
|
||||
|
||||
def check_blocks():
|
||||
user_agent = {'User-agent': 'BypassCensorship/1.0 (contact@sr2.uk for info)'}
|
||||
user_agent = {'User-agent': 'BypassCensorship/1.0'}
|
||||
page = requests.get(app.config['EXTERNAL_CHECK_URL'], headers=user_agent)
|
||||
soup = BeautifulSoup(page.content, 'html.parser')
|
||||
h2 = soup.find_all('h2')
|
||||
|
@ -33,33 +33,21 @@ def check_blocks():
|
|||
if vp not in app.config['EXTERNAL_VANTAGE_POINTS']:
|
||||
continue
|
||||
for url in results[vp]:
|
||||
if "cloudfront.net" in url:
|
||||
print(f"Found {url} blocked")
|
||||
proxy = Proxy.query.filter(
|
||||
Proxy.provider == "cloudfront",
|
||||
Proxy.url == f"https://{url}"
|
||||
).first()
|
||||
if not proxy:
|
||||
print("Proxy not found")
|
||||
continue
|
||||
if proxy.deprecated:
|
||||
print("Proxy already marked blocked")
|
||||
continue
|
||||
proxy.deprecate(reason="external")
|
||||
if "azureedge.net" in url:
|
||||
slug = url[len('https://'):][:-len('.azureedge.net')]
|
||||
print(f"Found {slug} blocked")
|
||||
proxy = Proxy.query.filter(
|
||||
Proxy.provider == "azure_cdn",
|
||||
Proxy.slug == slug
|
||||
).first()
|
||||
if not proxy:
|
||||
print("Proxy not found")
|
||||
continue
|
||||
if proxy.deprecated:
|
||||
print("Proxy already marked blocked")
|
||||
continue
|
||||
proxy.deprecate(reason="external")
|
||||
print(f"Found {url} blocked")
|
||||
proxy = Proxy.query.filter(
|
||||
Proxy.provider == "cloudfront",
|
||||
Proxy.url == f"https://{url}"
|
||||
).first()
|
||||
if not proxy:
|
||||
print("Proxy not found")
|
||||
continue
|
||||
if not proxy.origin.auto_rotation:
|
||||
print("Proxy auto-rotation forbidden for origin")
|
||||
if proxy.deprecated:
|
||||
print("Proxy already marked blocked")
|
||||
continue
|
||||
proxy.deprecate(reason="external")
|
||||
|
||||
db.session.commit()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue