mirror of
https://github.com/Flowseal/tg-ws-proxy.git
synced 2026-06-12 01:31:42 +03:00
Possibility to pass few cfproxy and worker domains
This commit is contained in:
@@ -58,8 +58,8 @@ class ProxyConfig:
|
||||
buffer_size: int = 256 * 1024
|
||||
pool_size: int = 4
|
||||
fallback_cfproxy: bool = True
|
||||
cfproxy_user_domain: str = ''
|
||||
cfproxy_worker_domain: str = ''
|
||||
cfproxy_user_domains: List[str] = field(default_factory=list)
|
||||
cfproxy_worker_domains: List[str] = field(default_factory=list)
|
||||
fake_tls_domain: str = ''
|
||||
proxy_protocol: bool = False
|
||||
|
||||
@@ -67,6 +67,30 @@ class ProxyConfig:
|
||||
proxy_config = ProxyConfig()
|
||||
|
||||
|
||||
def coerce_domain_list(value) -> List[str]:
|
||||
if isinstance(value, str):
|
||||
items = value.replace(',', ' ').replace(';', ' ').split()
|
||||
elif isinstance(value, (list, tuple)):
|
||||
items: List[str] = []
|
||||
for entry in value:
|
||||
if isinstance(entry, str):
|
||||
items.extend(entry.replace(',', ' ').replace(';', ' ').split())
|
||||
else:
|
||||
return []
|
||||
seen = set()
|
||||
result: List[str] = []
|
||||
for item in items:
|
||||
item = item.strip()
|
||||
if not item:
|
||||
continue
|
||||
key = item.lower()
|
||||
if key in seen:
|
||||
continue
|
||||
seen.add(key)
|
||||
result.append(item)
|
||||
return result
|
||||
|
||||
|
||||
def _fetch_cfproxy_domain_list() -> List[str]:
|
||||
try:
|
||||
req = Request(CFPROXY_DOMAINS_URL + "?" + "".join(random.choices(string.ascii_letters, k=7)),
|
||||
@@ -120,7 +144,7 @@ def _normalize_domain_pool(domains: List[str]) -> List[str]:
|
||||
|
||||
|
||||
def refresh_cfproxy_domains() -> None:
|
||||
if proxy_config.cfproxy_user_domain:
|
||||
if proxy_config.cfproxy_user_domains:
|
||||
return
|
||||
|
||||
fetched = _fetch_cfproxy_domain_list()
|
||||
|
||||
Reference in New Issue
Block a user