You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2019/10/30 20:04:08 UTC

[couchdb] branch fix-proxy-fields-in-scheduler-endpoints updated (23bafcd -> 67069c3)

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

vatamane pushed a change to branch fix-proxy-fields-in-scheduler-endpoints
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


 discard 23bafcd  Show source and target proxies in _scheduler/docs output
     new 67069c3  Show source and target proxies in _scheduler/docs output

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (23bafcd)
            \
             N -- N -- N   refs/heads/fix-proxy-fields-in-scheduler-endpoints (67069c3)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

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.


Summary of changes:


[couchdb] 01/01: Show source and target proxies in _scheduler/docs output

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

vatamane pushed a commit to branch fix-proxy-fields-in-scheduler-endpoints
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 67069c3004273446f4f6dd20d669e170e225b384
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Wed Oct 30 15:45:44 2019 -0400

    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.
---
 src/couch/src/couch_util.erl                       |  4 +--
 .../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 62e17ce..e2885a1 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 52d362b..c9da377 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() ->