From 02b84fb519c853cee0a7765b475371d9eb59cf60 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Mon, 26 Feb 2024 10:59:18 +0100 Subject: Improve filter_messages in gui Add rdns suport for proxies --- g4f/providers/helper.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'g4f/providers') diff --git a/g4f/providers/helper.py b/g4f/providers/helper.py index 49d033d1..6981f984 100644 --- a/g4f/providers/helper.py +++ b/g4f/providers/helper.py @@ -55,7 +55,11 @@ def get_connector(connector: BaseConnector = None, proxy: str = None) -> Optiona if proxy and not connector: try: from aiohttp_socks import ProxyConnector - connector = ProxyConnector.from_url(proxy) + rdns = False + if proxy.startswith("socks5h://"): + proxy = proxy.replace("socks5h://", "socks5://") + rdns = True + connector = ProxyConnector.from_url(proxy, rdns=rdns) except ImportError: raise MissingRequirementsError('Install "aiohttp_socks" package for proxy support') return connector \ No newline at end of file -- cgit v1.2.3 From 6bbe60572e55d7cdc72a179da3940554128c2c50 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Mon, 26 Feb 2024 11:25:07 +0100 Subject: Add default values for rdns --- g4f/providers/helper.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'g4f/providers') diff --git a/g4f/providers/helper.py b/g4f/providers/helper.py index 6981f984..c027216b 100644 --- a/g4f/providers/helper.py +++ b/g4f/providers/helper.py @@ -51,11 +51,10 @@ def get_random_hex() -> str: """ return secrets.token_hex(16).zfill(32) -def get_connector(connector: BaseConnector = None, proxy: str = None) -> Optional[BaseConnector]: +def get_connector(connector: BaseConnector = None, proxy: str = None, rdns: bool = False) -> Optional[BaseConnector]: if proxy and not connector: try: from aiohttp_socks import ProxyConnector - rdns = False if proxy.startswith("socks5h://"): proxy = proxy.replace("socks5h://", "socks5://") rdns = True -- cgit v1.2.3