From 038938fc9b00365ec865421949e5938f7625a94f Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Tue, 6 Aug 2024 13:07:50 +0300 Subject: [PATCH] Fix(Robots): Do not route ftp requests via http(s) proxy socks5 proxies are ok. --- Robots/bkmk_robot_base.py | 17 +++++++++++++---- doc/ANNOUNCE | 4 ++++ doc/ChangeLog | 4 ++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Robots/bkmk_robot_base.py b/Robots/bkmk_robot_base.py index dffffdb..b2e4442 100644 --- a/Robots/bkmk_robot_base.py +++ b/Robots/bkmk_robot_base.py @@ -341,14 +341,24 @@ class robot_base(Robot): def smart_get(self, bookmark, url, accept_charset=False): split_results = urlsplit(url) + url_proto = split_results.scheme url_host = split_results.hostname if url_host in self.proxy_error: return 'see prev. error', None, None, None, None use_proxy = False - if url_host in self.proxy_ok: - use_proxy = True + if self.proxy: + split_proxy = urlsplit(self.proxy) + proxy_proto = split_proxy.scheme + # Do not route ftp requests via http(s) proxy; + # socks5 proxies are ok. + if (url_proto == 'ftp'): + use_proxy = proxy_proto.startswith('socks5') + else: # http(s) + use_proxy = True + + if use_proxy and url_host in self.proxy_ok: self.log(' Immediately trying with the proxy') error, http_status_code, redirect_to, headers, content = \ self.get(bookmark, url, @@ -363,8 +373,7 @@ class robot_base(Robot): not url_host.startswith('127.') ): self.log(' Error : %s' % error) - if self.proxy and http_status_code != 404: - use_proxy = True + if use_proxy and http_status_code != 404: self.log(' Retrying with the proxy...') error, http_status_code, redirect_to, headers, content = \ self.get(bookmark, url, diff --git a/doc/ANNOUNCE b/doc/ANNOUNCE index 3fb4356..ec435e1 100644 --- a/doc/ANNOUNCE +++ b/doc/ANNOUNCE @@ -7,6 +7,10 @@ bookmarks.html. WHAT'S NEW +Version 5.5.1 (2024-08-??) + + Do not route ftp requests via http(s) proxy; socks5 proxies are ok. + Version 5.5.0 (2024-08-06) Robot based on aiohttp. diff --git a/doc/ChangeLog b/doc/ChangeLog index cb8415d..4057f50 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +Version 5.5.1 (2024-08-??) + + Do not route ftp requests via http(s) proxy; socks5 proxies are ok. + Version 5.5.0 (2024-08-06) Robot based on aiohttp. -- 2.39.5