You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2021/06/18 05:18:45 UTC

[couchdb] branch fix-socks5-proxy-support created (now 365c245)

This is an automated email from the ASF dual-hosted git repository.

jaydoane pushed a change to branch fix-socks5-proxy-support
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 365c245  Use correct socks5 proxy ibrowse options

This branch includes the following new commits:

     new 365c245  Use correct socks5 proxy ibrowse options

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[couchdb] 01/01: Use correct socks5 proxy ibrowse options

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jaydoane pushed a commit to branch fix-socks5-proxy-support
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 365c2455357ace90aa78651b439e1e9eaaa1ca08
Author: Jay Doane <ja...@apache.org>
AuthorDate: Thu Jun 17 22:18:27 2021 -0700

    Use correct socks5 proxy ibrowse options
    
    With the move from using a forked ibrowse to upstream [1], the
    ibrowse options for socks5 proxy settings all changed to a `socks5_`
    prefix.
    
    [1] https://github.com/apache/couchdb/pull/3551
---
 src/couch_replicator/src/couch_replicator_docs.erl | 37 ++++++++++++++++++++--
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/src/couch_replicator/src/couch_replicator_docs.erl b/src/couch_replicator/src/couch_replicator_docs.erl
index 3087195..a8efa63 100644
--- a/src/couch_replicator/src/couch_replicator_docs.erl
+++ b/src/couch_replicator/src/couch_replicator_docs.erl
@@ -571,8 +571,7 @@ parse_proxy_params(ProxyUrl) ->
         password = Passwd,
         protocol = Protocol
     } = ibrowse_lib:parse_url(ProxyUrl),
-    [
-        {proxy_protocol, Protocol},
+    Params = [
         {proxy_host, Host},
         {proxy_port, Port}
     ] ++ case is_list(User) andalso is_list(Passwd) of
@@ -580,7 +579,24 @@ parse_proxy_params(ProxyUrl) ->
             [];
         true ->
             [{proxy_user, User}, {proxy_password, Passwd}]
-        end.
+    end,
+    case Protocol of
+        socks5 ->
+            [proxy_to_socks5(Param) || Param <- Params];
+        _ ->
+            Params
+    end.
+
+
+-spec proxy_to_socks5({atom(), string()}) -> {atom(), string()}.
+proxy_to_socks5({proxy_host, Val}) ->
+    {socks5_host, Val};
+proxy_to_socks5({proxy_port, Val}) ->
+    {socks5_port, Val};
+proxy_to_socks5({proxy_user, Val}) ->
+    {socks5_user, Val};
+proxy_to_socks5({proxy_password, Val}) ->
+    {socks5_password, Val}.
 
 
 -spec ssl_params([_]) -> [_].
@@ -790,6 +806,21 @@ check_strip_credentials_test() ->
     ]].
 
 
+parse_proxy_params_test() ->
+    ?assertEqual([
+        {proxy_host, "foo.com"},
+        {proxy_port, 443},
+        {proxy_user, "u"},
+        {proxy_password, "p"}
+    ], parse_proxy_params("https://u:p@foo.com")),
+    ?assertEqual([
+        {socks5_host, "foo.com"},
+        {socks5_port, 1080},
+        {socks5_user, "u"},
+        {socks5_password, "p"}
+    ], parse_proxy_params("socks5://u:p@foo.com")).
+
+
 setup() ->
     DbName = ?tempdb(),
     {ok, Db} = couch_db:create(DbName, [?ADMIN_CTX]),