list/gen: generate lists based on pools
This commit is contained in:
parent
de0f472fdc
commit
076de1bc44
7 changed files with 30 additions and 22 deletions
|
@ -3,8 +3,9 @@ from typing import Dict, Callable, Any
|
|||
from app.lists.bc2 import mirror_sites
|
||||
from app.lists.bridgelines import bridgelines
|
||||
from app.lists.mirror_mapping import mirror_mapping
|
||||
from app.models.base import Pool
|
||||
|
||||
lists: Dict[str, Callable[[], Any]] = {
|
||||
lists: Dict[str, Callable[[Pool], Any]] = {
|
||||
"bca": mirror_mapping,
|
||||
"bc2": mirror_sites,
|
||||
"bridgelines": bridgelines,
|
||||
|
|
|
@ -6,6 +6,7 @@ from typing import List, Dict, Union, Any, Optional
|
|||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.models.base import Pool
|
||||
from app.models.mirrors import Origin, Proxy
|
||||
|
||||
|
||||
|
@ -69,12 +70,12 @@ def active_proxies(origin: Origin, provider: str) -> List[Proxy]:
|
|||
return list(filter(_filter_fn, origin.proxies))
|
||||
|
||||
|
||||
def mirror_sites(provider: str = "cloudfront") -> Dict[
|
||||
def mirror_sites(pool: Pool) -> Dict[
|
||||
str, Union[str, List[Dict[str, Union[str, List[Dict[str, str]]]]]]]:
|
||||
return {"version": "2.0", "sites": [{"main_domain": main_domain(origin),
|
||||
"available_alternatives": onion_alternative(origin) + [
|
||||
proxy_alternative(proxy) for proxy in
|
||||
active_proxies(origin, provider)]} for origin in
|
||||
active_proxies(origin, pool)]} for origin in
|
||||
Origin.query.order_by(Origin.domain_name).all() if
|
||||
origin.destroyed is None]}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ from typing import List, Iterable, Dict, Any, Optional
|
|||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.models.base import Pool
|
||||
from app.models.bridges import Bridge
|
||||
|
||||
|
||||
|
@ -31,7 +32,7 @@ class Bridgelines(BaseModel):
|
|||
title = "Bridgelines Version 1"
|
||||
|
||||
|
||||
def bridgelines(*, distribution_method: Optional[str] = None) -> Dict[str, Any]:
|
||||
def bridgelines(pool: Pool, *, distribution_method: Optional[str] = None) -> Dict[str, Any]:
|
||||
bridges: Iterable[Bridge] = Bridge.query.filter(
|
||||
Bridge.destroyed.is_(None),
|
||||
Bridge.deprecated.is_(None),
|
||||
|
|
|
@ -7,7 +7,7 @@ from flask import current_app
|
|||
from pydantic import BaseModel, Field
|
||||
from tldextract import extract
|
||||
|
||||
from app.models.base import Group
|
||||
from app.models.base import Group, Pool
|
||||
from app.models.mirrors import Proxy
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@ class MirrorMapping(BaseModel):
|
|||
title = "Mirror Mapping Version 1.1"
|
||||
|
||||
|
||||
def mirror_mapping() -> Dict[str, Union[str, Dict[str, str]]]:
|
||||
def mirror_mapping(pool: Pool) -> Dict[str, Union[str, Dict[str, str]]]:
|
||||
return MirrorMapping(
|
||||
version="1.1",
|
||||
mappings={
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue