mirrors: record deprecation reason
This commit is contained in:
parent
cacb35a671
commit
18e046dc42
9 changed files with 96 additions and 26 deletions
|
@ -4,6 +4,7 @@ from dateutil.parser import isoparse
|
|||
from github import Github
|
||||
|
||||
from app import app
|
||||
from app.extensions import db
|
||||
from app.models.bridges import Bridge
|
||||
|
||||
|
||||
|
@ -17,11 +18,12 @@ def check_blocks():
|
|||
if isoparse(parts[2]) < (datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=3)):
|
||||
continue
|
||||
if int(parts[1]) < 40:
|
||||
bridge = Bridge.query.filter(
|
||||
bridge: Bridge = Bridge.query.filter(
|
||||
Bridge.hashed_fingerprint == parts[0]
|
||||
).first()
|
||||
if bridge is not None:
|
||||
bridge.deprecate()
|
||||
bridge.deprecate(reason="github")
|
||||
db.session.commit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -2,6 +2,7 @@ from bs4 import BeautifulSoup
|
|||
import requests
|
||||
|
||||
from app import app
|
||||
from app.extensions import db
|
||||
from app.models.mirrors import Proxy
|
||||
|
||||
|
||||
|
@ -44,7 +45,7 @@ def check_blocks():
|
|||
if proxy.deprecated:
|
||||
print("Proxy already marked blocked")
|
||||
continue
|
||||
proxy.deprecate()
|
||||
proxy.deprecate(reason="external")
|
||||
if "azureedge.net" in url:
|
||||
slug = url[len('https://'):][:-len('.azureedge.net')]
|
||||
print(f"Found {slug} blocked")
|
||||
|
@ -58,7 +59,8 @@ def check_blocks():
|
|||
if proxy.deprecated:
|
||||
print("Proxy already marked blocked")
|
||||
continue
|
||||
proxy.deprecate()
|
||||
proxy.deprecate(reason="external")
|
||||
db.session.commit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
from typing import Iterable
|
||||
|
||||
from app import app
|
||||
from app.extensions import db
|
||||
|
@ -9,8 +10,9 @@ from app.terraform import BaseAutomation
|
|||
|
||||
class BridgeAutomation(BaseAutomation):
|
||||
def create_missing(self):
|
||||
bridgeconfs = BridgeConf.query.filter(
|
||||
BridgeConf.provider == self.provider
|
||||
bridgeconfs: Iterable[BridgeConf] = BridgeConf.query.filter(
|
||||
BridgeConf.provider == self.provider,
|
||||
BridgeConf.destroyed == None
|
||||
).all()
|
||||
for bridgeconf in bridgeconfs:
|
||||
active_bridges = Bridge.query.filter(
|
||||
|
@ -27,10 +29,11 @@ class BridgeAutomation(BaseAutomation):
|
|||
elif len(active_bridges) > bridgeconf.number:
|
||||
active_bridge_count = len(active_bridges)
|
||||
for bridge in active_bridges:
|
||||
bridge.deprecate()
|
||||
bridge.deprecate("redundant")
|
||||
active_bridge_count -= 1
|
||||
if active_bridge_count == bridgeconf.number:
|
||||
break
|
||||
db.session.commit()
|
||||
|
||||
def destroy_expired(self):
|
||||
cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=0)
|
||||
|
@ -40,6 +43,7 @@ class BridgeAutomation(BaseAutomation):
|
|||
).all() if b.conf.provider == self.provider]
|
||||
for bridge in bridges:
|
||||
bridge.destroy()
|
||||
db.session.commit()
|
||||
|
||||
def generate_terraform(self):
|
||||
self.write_terraform_config(
|
||||
|
|
|
@ -61,7 +61,7 @@ class ProxyAutomation(BaseAutomation):
|
|||
Proxy.provider == self.provider,
|
||||
Proxy.destroyed == None
|
||||
).all(),
|
||||
subgroups = self.get_subgroups(),
|
||||
subgroups=self.get_subgroups(),
|
||||
global_namespace=app.config['GLOBAL_NAMESPACE'],
|
||||
bypass_token=app.config['BYPASS_TOKEN'],
|
||||
**{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue