lists: allow provider selection for bc2

This commit is contained in:
Iain Learmonth 2022-05-01 16:49:05 +01:00
parent 80890c2127
commit 7ef321280e

View file

@ -1,6 +1,6 @@
import builtins import builtins
from datetime import datetime from datetime import datetime
from typing import List from typing import List, Dict, Union
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
@ -33,7 +33,8 @@ class BypassCensorship2(BaseModel):
title = "Bypass Censorship Version 2" title = "Bypass Censorship Version 2"
def mirror_sites(): def mirror_sites(provider: str = "cloudfront") -> Dict[
str, Union[str, List[Dict[Union[str, List[Dict[str, str]]]]]]]:
return { return {
"version": "2.0", "version": "2.0",
"sites": [{ "sites": [{
@ -55,7 +56,10 @@ def mirror_sites():
"updated_at": str(a.updated), "updated_at": str(a.updated),
"url": a.url "url": a.url
} for a in x.proxies if } for a in x.proxies if
a.url is not None and not a.deprecated and not a.destroyed and a.provider == "cloudfront" a.url is not None
and not a.deprecated
and not a.destroyed
and a.provider == provider
]} for x in Origin.query.order_by(Origin.domain_name).all() if x.destroyed is None ]} for x in Origin.query.order_by(Origin.domain_name).all() if x.destroyed is None
] ]
} }