- Drop support for Python 3.7. - Use offline geolocation database instead of ip-api.com. - Add support for proxy authentication. - Add pre-compiled binaries. - Refactor the code by a lot. - Simplify config. - Add automatic text encoding detection. - Use TOML instead of INI for configuration. - Add support for using httpbin-compatible services and services which return plain IP address for getting proxy's exit node. - Add support for reading proxy lists from local files. - Add support for saving to json. - Remove support for saving geolocation to txt, use json instead. - Improve parser. - Improve config validation. - Use poetry instead of requirements.txt. - Use venv in start scripts.
22 lines
543 B
Python
22 lines
543 B
Python
from __future__ import annotations
|
|
|
|
from typing import Tuple
|
|
|
|
from aiohttp_socks import ProxyType
|
|
|
|
from .proxy import Proxy
|
|
|
|
PROTOCOL_ORDER = (ProxyType.HTTP, ProxyType.SOCKS4, ProxyType.SOCKS5)
|
|
|
|
|
|
def protocol_sort_key(proxy: Proxy, /) -> Tuple[int, ProxyType]:
|
|
return (PROTOCOL_ORDER.index(proxy.protocol), proxy.protocol)
|
|
|
|
|
|
def natural_sort_key(proxy: Proxy, /) -> Tuple[int, ...]:
|
|
return (proxy.protocol.value, *map(int, proxy.host.split(".")), proxy.port)
|
|
|
|
|
|
def timeout_sort_key(proxy: Proxy, /) -> float:
|
|
return proxy.timeout
|