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/25 06:19:05 UTC
[couchdb] branch 3.x updated: Use correct socks5 proxy ibrowse
options
This is an automated email from the ASF dual-hosted git repository.
jaydoane pushed a commit to branch 3.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/3.x by this push:
new 3675e5e Use correct socks5 proxy ibrowse options
3675e5e is described below
commit 3675e5ecf71e2f749404c82012a4804d02894701
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 cc2d33a..7c60e8a 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]),