diff options
author | Nick Vatamaniuc <vatamane@apache.org> | 2019-10-30 15:45:44 -0400 |
---|---|---|
committer | Nick Vatamaniuc <nickva@users.noreply.github.com> | 2019-10-30 17:55:45 -0400 |
commit | 18db801b751d9aeb22cb99783eee252bc3cf82d1 (patch) | |
tree | 6aee500e2a849fd185cf3ea3d03be39a210e3e54 | |
parent | 5e3e50f2424d09dc2086941dba7f0e13af6e4281 (diff) | |
download | couchdb-18db801b751d9aeb22cb99783eee252bc3cf82d1.tar.gz |
Show source and target proxies in _scheduler/docs output
Since we have separate proxies for source and target
(https://github.com/apache/couchdb/commit/053d494e698181ae3b0b0698055f5a24e7995172),
show them in _scheduler/docs endpoint as separate as well. Previously we just
read the proxy value from the source.
When formatting the proxy url for output, make sure `socks5` schema is handled
by the url credentials stripping code to avoid exposing user credentials.
-rw-r--r-- | src/couch/src/couch_util.erl | 4 | ||||
-rw-r--r-- | src/couch_replicator/src/couch_replicator_scheduler.erl | 31 |
2 files changed, 31 insertions, 4 deletions
diff --git a/src/couch/src/couch_util.erl b/src/couch/src/couch_util.erl index 62e17ce36..e2885a15e 100644 --- a/src/couch/src/couch_util.erl +++ b/src/couch/src/couch_util.erl @@ -529,8 +529,8 @@ reorder_results(Keys, SortedResults) -> url_strip_password(Url) -> re:replace(Url, - "http(s)?://([^:]+):[^@]+@(.*)$", - "http\\1://\\2:*****@\\3", + "(http|https|socks5)://([^:]+):[^@]+@(.*)$", + "\\1://\\2:*****@\\3", [{return, list}]). encode_doc_id(#doc{id = Id}) -> diff --git a/src/couch_replicator/src/couch_replicator_scheduler.erl b/src/couch_replicator/src/couch_replicator_scheduler.erl index 52d362b99..c9da377c6 100644 --- a/src/couch_replicator/src/couch_replicator_scheduler.erl +++ b/src/couch_replicator/src/couch_replicator_scheduler.erl @@ -165,7 +165,8 @@ job_summary(JobId, HealthThreshold) -> {last_updated, last_updated(History)}, {start_time, couch_replicator_utils:iso8601(Rep#rep.start_time)}, - {proxy, job_proxy_url(Rep#rep.source)} + {source_proxy, job_proxy_url(Rep#rep.source)}, + {target_proxy, job_proxy_url(Rep#rep.target)} ]; {error, not_found} -> nil % Job might have just completed @@ -1068,7 +1069,8 @@ scheduler_test_() -> t_job_summary_running(), t_job_summary_pending(), t_job_summary_crashing_once(), - t_job_summary_crashing_many_times() + t_job_summary_crashing_many_times(), + t_job_summary_proxy_fields() ] }. @@ -1479,6 +1481,31 @@ t_job_summary_crashing_many_times() -> end). +t_job_summary_proxy_fields() -> + ?_test(begin + Job = #job{ + id = job1, + history = [started(10), added()], + rep = #rep{ + source = #httpdb{ + url = "https://s", + proxy_url = "http://u:p@sproxy:12" + }, + target = #httpdb{ + url = "http://t", + proxy_url = "socks5://u:p@tproxy:34" + } + } + }, + setup_jobs([Job]), + Summary = job_summary(job1, ?DEFAULT_HEALTH_THRESHOLD_SEC), + ?assertEqual(<<"http://u:*****@sproxy:12">>, + proplists:get_value(source_proxy, Summary)), + ?assertEqual(<<"socks5://u:*****@tproxy:34">>, + proplists:get_value(target_proxy, Summary)) + end). + + % Test helper functions setup() -> |