]> git.phdru.name Git - bookmarks_db.git/commitdiff
Fix(Robots): Do not route ftp requests via http(s) proxy
authorOleg Broytman <phd@phdru.name>
Tue, 6 Aug 2024 10:07:50 +0000 (13:07 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 6 Aug 2024 10:07:50 +0000 (13:07 +0300)
socks5 proxies are ok.

Robots/bkmk_robot_base.py
doc/ANNOUNCE
doc/ChangeLog

index dffffdb09645361c80ff5a0adc666b3dd8b3fdeb..b2e444220a4bf00e701f3bc5b933eaba20c91813 100644 (file)
@@ -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,
index 3fb4356e567c76840212d8405dc23c981a499f5a..ec435e1f4795e83254135f2e4523175cc4ebda6f 100644 (file)
@@ -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.
index cb8415da7c1a6bae5c869b5a86b5e7871d7b0fc6..4057f50e3193e0787b980c69ce1ddc9d7a9b735b 100644 (file)
@@ -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.