mirrors: allow selective auto-rotation
This commit is contained in:
parent
18e046dc42
commit
80890c2127
5 changed files with 25 additions and 34 deletions
|
@ -106,6 +106,7 @@ def new_origin(group_id=None):
|
||||||
origin.group_id = form.group.data
|
origin.group_id = form.group.data
|
||||||
origin.domain_name = form.domain_name.data
|
origin.domain_name = form.domain_name.data
|
||||||
origin.description = form.description.data
|
origin.description = form.description.data
|
||||||
|
origin.auto_rotation = form.auto_rotate.data
|
||||||
origin.created = datetime.utcnow()
|
origin.created = datetime.utcnow()
|
||||||
origin.updated = datetime.utcnow()
|
origin.updated = datetime.utcnow()
|
||||||
try:
|
try:
|
||||||
|
@ -137,6 +138,7 @@ def edit_origin(origin_id):
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
origin.group_id = form.group.data
|
origin.group_id = form.group.data
|
||||||
origin.description = form.description.data
|
origin.description = form.description.data
|
||||||
|
origin.auto_rotation = form.auto_rotate.data
|
||||||
origin.updated = datetime.utcnow()
|
origin.updated = datetime.utcnow()
|
||||||
try:
|
try:
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
@ -306,9 +308,9 @@ def edit_bridgeconf(bridgeconf_id):
|
||||||
bridgeconf = BridgeConf.query.filter(BridgeConf.id == bridgeconf_id).first()
|
bridgeconf = BridgeConf.query.filter(BridgeConf.id == bridgeconf_id).first()
|
||||||
if bridgeconf is None:
|
if bridgeconf is None:
|
||||||
return Response(render_template("error.html.j2",
|
return Response(render_template("error.html.j2",
|
||||||
section="origin",
|
section="bridge",
|
||||||
header="404 Origin Not Found",
|
header="404 Bridge Configuration Not Found",
|
||||||
message="The requested origin could not be found."),
|
message="The requested bridge configuration could not be found."),
|
||||||
status=404)
|
status=404)
|
||||||
form = EditBridgeConfForm(description=bridgeconf.description,
|
form = EditBridgeConfForm(description=bridgeconf.description,
|
||||||
number=bridgeconf.number)
|
number=bridgeconf.number)
|
||||||
|
|
|
@ -20,12 +20,14 @@ class NewOriginForm(FlaskForm):
|
||||||
domain_name = StringField('Domain Name', validators=[DataRequired()])
|
domain_name = StringField('Domain Name', validators=[DataRequired()])
|
||||||
description = StringField('Description', validators=[DataRequired()])
|
description = StringField('Description', validators=[DataRequired()])
|
||||||
group = SelectField('Group', validators=[DataRequired()])
|
group = SelectField('Group', validators=[DataRequired()])
|
||||||
|
auto_rotate = BooleanField("Enable auto-rotation?", default=True)
|
||||||
submit = SubmitField('Save Changes')
|
submit = SubmitField('Save Changes')
|
||||||
|
|
||||||
|
|
||||||
class EditOriginForm(FlaskForm):
|
class EditOriginForm(FlaskForm):
|
||||||
description = StringField('Description', validators=[DataRequired()])
|
description = StringField('Description', validators=[DataRequired()])
|
||||||
group = SelectField('Group', validators=[DataRequired()])
|
group = SelectField('Group', validators=[DataRequired()])
|
||||||
|
auto_rotate = BooleanField("Enable auto-rotation?")
|
||||||
submit = SubmitField('Save Changes')
|
submit = SubmitField('Save Changes')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ group.group_name }}</td>
|
<td>{{ group.group_name }}</td>
|
||||||
<td>{{ group.description }}</td>
|
<td>{{ group.description }}</td>
|
||||||
<td>{% if group.eotk %}√{% else %}x{% endif %}</td>
|
<td>{% if group.eotk %}✅{% else %}❌{% endif %}</td>
|
||||||
<td>{{ group.origins | length }}</td>
|
<td>{{ group.origins | length }}</td>
|
||||||
<td><a href="{{ url_for("portal.edit_group", group_id=group.id) }}" class="btn btn-primary btn-sm">View/Edit</a></td>
|
<td><a href="{{ url_for("portal.edit_group", group_id=group.id) }}" class="btn btn-primary btn-sm">View/Edit</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -21,8 +21,7 @@
|
||||||
{{ origin.domain_name }}
|
{{ origin.domain_name }}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ origin.description }}</td>
|
<td>{{ origin.description }}</td>
|
||||||
<td>{{ origin.mirrors | length }}</td>
|
<td>{% if origin.auto_rotation %}✅{% else %}❌{% endif %}</td>
|
||||||
<td>{{ origin.proxies | length }}</td>
|
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ url_for("portal.edit_group", group_id=origin.group.id) }}">{{ origin.group.group_name }}</a>
|
<a href="{{ url_for("portal.edit_group", group_id=origin.group.id) }}">{{ origin.group.group_name }}</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -7,7 +7,7 @@ from app.models.mirrors import Proxy
|
||||||
|
|
||||||
|
|
||||||
def check_blocks():
|
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)
|
page = requests.get(app.config['EXTERNAL_CHECK_URL'], headers=user_agent)
|
||||||
soup = BeautifulSoup(page.content, 'html.parser')
|
soup = BeautifulSoup(page.content, 'html.parser')
|
||||||
h2 = soup.find_all('h2')
|
h2 = soup.find_all('h2')
|
||||||
|
@ -33,7 +33,6 @@ def check_blocks():
|
||||||
if vp not in app.config['EXTERNAL_VANTAGE_POINTS']:
|
if vp not in app.config['EXTERNAL_VANTAGE_POINTS']:
|
||||||
continue
|
continue
|
||||||
for url in results[vp]:
|
for url in results[vp]:
|
||||||
if "cloudfront.net" in url:
|
|
||||||
print(f"Found {url} blocked")
|
print(f"Found {url} blocked")
|
||||||
proxy = Proxy.query.filter(
|
proxy = Proxy.query.filter(
|
||||||
Proxy.provider == "cloudfront",
|
Proxy.provider == "cloudfront",
|
||||||
|
@ -42,24 +41,13 @@ def check_blocks():
|
||||||
if not proxy:
|
if not proxy:
|
||||||
print("Proxy not found")
|
print("Proxy not found")
|
||||||
continue
|
continue
|
||||||
|
if not proxy.origin.auto_rotation:
|
||||||
|
print("Proxy auto-rotation forbidden for origin")
|
||||||
if proxy.deprecated:
|
if proxy.deprecated:
|
||||||
print("Proxy already marked blocked")
|
print("Proxy already marked blocked")
|
||||||
continue
|
continue
|
||||||
proxy.deprecate(reason="external")
|
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")
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue