# HG changeset patch # User Sebastien Jodogne # Date 1549345476 -3600 # Node ID 595bfee4391a0673289885fe0b1cc89138f9c27c # Parent 20826867141f50fc164dde462324c0de5e3d7453 URI "/peers?expand" provides more information diff -r 20826867141f -r 595bfee4391a Core/WebServiceParameters.cpp --- a/Core/WebServiceParameters.cpp Mon Feb 04 21:09:44 2019 +0100 +++ b/Core/WebServiceParameters.cpp Tue Feb 05 06:44:36 2019 +0100 @@ -502,4 +502,47 @@ } } #endif + + + void WebServiceParameters::FormatPublic(Json::Value& target) const + { + target = Json::objectValue; + + // Only return the public information identifying the destination. + // "Security"-related information such as passwords and HTTP + // headers are shown as "null" values. + target[KEY_URL] = url_; + + if (!username_.empty()) + { + target[KEY_USERNAME] = username_; + target[KEY_PASSWORD] = Json::nullValue; + } + + if (!certificateFile_.empty()) + { + target[KEY_CERTIFICATE_FILE] = certificateFile_; + target[KEY_CERTIFICATE_KEY_FILE] = Json::nullValue; + target[KEY_CERTIFICATE_KEY_PASSWORD] = Json::nullValue; + } + + target[KEY_PKCS11] = pkcs11Enabled_; + + Json::Value headers = Json::arrayValue; + + for (Dictionary::const_iterator it = headers_.begin(); + it != headers_.end(); ++it) + { + // Only list the HTTP headers, not their value + headers.append(it->first); + } + + target[KEY_HTTP_HEADERS] = headers; + + for (Dictionary::const_iterator it = userProperties_.begin(); + it != userProperties_.end(); ++it) + { + target[it->first] = it->second; + } + } } diff -r 20826867141f -r 595bfee4391a Core/WebServiceParameters.h --- a/Core/WebServiceParameters.h Mon Feb 04 21:09:44 2019 +0100 +++ b/Core/WebServiceParameters.h Tue Feb 05 06:44:36 2019 +0100 @@ -175,5 +175,7 @@ #if ORTHANC_SANDBOXED == 0 void CheckClientCertificate() const; #endif + + void FormatPublic(Json::Value& target) const; }; } diff -r 20826867141f -r 595bfee4391a NEWS --- a/NEWS Mon Feb 04 21:09:44 2019 +0100 +++ b/NEWS Tue Feb 05 06:44:36 2019 +0100 @@ -15,6 +15,7 @@ * API version has been upgraded to 1.4 * New URI "/tools/metrics" to dynamically enable/disable the collection of metrics * New URI "/tools/metrics-prometheus" to retrieve metrics using Prometheus text format +* URI "/peers?expand" provides more information about the peers Plugins ------- diff -r 20826867141f -r 595bfee4391a OrthancServer/OrthancRestApi/OrthancRestModalities.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Mon Feb 04 21:09:44 2019 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Tue Feb 05 06:44:36 2019 +0100 @@ -1015,16 +1015,9 @@ if (lock.GetConfiguration().LookupOrthancPeer(peer, *it)) { - Json::Value jsonPeer = Json::objectValue; - // only return the minimum information to identify the - // destination, do not include "security" information like - // passwords - jsonPeer["Url"] = peer.GetUrl(); - if (!peer.GetUsername().empty()) - { - jsonPeer["Username"] = peer.GetUsername(); - } - result[*it] = jsonPeer; + Json::Value info; + peer.FormatPublic(info); + result[*it] = info; } } call.GetOutput().AnswerJson(result);