From 6c4af9bfeabda06ab9c70727dec72d147b12723f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Fri, 30 Aug 2019 01:06:50 -0400
Subject: [PATCH] proxy server: fix warnings

---
 include/opendht/http.h   |  2 +-
 src/dht_proxy_server.cpp | 18 +++++++-----------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/include/opendht/http.h b/include/opendht/http.h
index 523b40b3..9888c8cf 100644
--- a/include/opendht/http.h
+++ b/include/opendht/http.h
@@ -44,7 +44,7 @@ namespace dht {
 struct Logger;
 
 namespace crypto {
-class Certificate;
+struct Certificate;
 }
 
 namespace http {
diff --git a/src/dht_proxy_server.cpp b/src/dht_proxy_server.cpp
index a97ca78b..22177e88 100644
--- a/src/dht_proxy_server.cpp
+++ b/src/dht_proxy_server.cpp
@@ -54,15 +54,17 @@ struct custom_http_methods_t
 #endif
 
 namespace dht {
-
-constexpr char RESP_MSG_DESTINATION_NOT_FOUND[] = "{\"err\":\"No destination found\"}";
-constexpr char RESP_MSG_NO_TOKEN[] = "{\"err\":\"No token\"}";
-constexpr char RESP_MSG_JSON_NOT_ENABLED[] = "{\"err\":\"JSON not enabled on this instance\"}";
 constexpr char RESP_MSG_JSON_INCORRECT[] = "{\"err:\":\"Incorrect JSON\"}";
 constexpr char RESP_MSG_SERVICE_UNAVAILABLE[] = "{\"err\":\"Incorrect DhtRunner\"}";
 constexpr char RESP_MSG_INTERNAL_SERVER_ERRROR[] = "{\"err\":\"Internal server error\"}";
 constexpr char RESP_MSG_MISSING_PARAMS[] = "{\"err\":\"Missing parameters\"}";
 constexpr char RESP_MSG_PUT_FAILED[] = "{\"err\":\"Put failed\"}";
+#ifdef OPENDHT_PROXY_SERVER_IDENTITY
+constexpr char RESP_MSG_DESTINATION_NOT_FOUND[] = "{\"err\":\"No destination found\"}";
+#endif
+#ifdef OPENDHT_PUSH_NOTIFICATIONS
+constexpr char RESP_MSG_NO_TOKEN[] = "{\"err\":\"No token\"}";
+#endif
 
 constexpr const std::chrono::minutes PRINT_STATS_PERIOD {2};
 
@@ -298,6 +300,7 @@ DhtProxyServer::io_context() const
         return httpsServer_->io_context();
     else if (httpServer_)
         return httpServer_->io_context();
+    throw std::runtime_error("No available server");
 }
 
 DhtProxyServer::~DhtProxyServer()
@@ -501,17 +504,10 @@ DhtProxyServer::getStats(restinio::request_handle_t request,
     requestNum_++;
     try {
         if (dht_){
-#ifdef OPENDHT_JSONCPP
             auto output = Json::writeString(jsonBuilder_, stats_.toJson()) + "\n";
             auto response = this->initHttpResponse(request->create_response());
             response.append_body(output);
             response.done();
-#else
-            auto response = this->initHttpResponse(
-                request->create_response(restinio::status_not_found()));
-            response.set_body(RESP_MSG_JSON_NOT_ENABLED);
-            return response.done();
-#endif
         } else {
             auto response = this->initHttpResponse(
                 request->create_response(restinio::status_service_unavailable()));
-- 
GitLab