diff --git a/include/aman/types/Communication.h b/include/aman/types/Communication.h index 0577ace..fe14cd4 100644 --- a/include/aman/types/Communication.h +++ b/include/aman/types/Communication.h @@ -17,9 +17,10 @@ namespace aman { */ struct Communication { bool valid; /**< Marks if the configuration is valid */ + bool httpsProtocol; /**< Marks if the server uses HTTPS */ std::string address; /**< The address of the backend */ - std::uint16_t portReporter; /**< The reported port of the backend */ - std::uint16_t portNotification; /**< The notification port of the backend */ + std::uint16_t portBackend; /**< The reported port of the backend */ + std::uint16_t portRestAPI; /**< The notification port of the backend */ std::string serverPublicIdentifier; /**< The server's public identifier */ std::string clientPublicIdentifier; /**< The client's public identifier */ std::string clientPrivateIdentifier; /**< The client's private identifier */ @@ -29,9 +30,10 @@ namespace aman { */ Communication() : valid(false), + httpsProtocol(false), address(), - portReporter(0), - portNotification(0), + portBackend(0), + portRestAPI(0), serverPublicIdentifier(), clientPublicIdentifier(), clientPrivateIdentifier() { } diff --git a/src/PlugIn.cpp b/src/PlugIn.cpp index e66055e..9a3df65 100644 --- a/src/PlugIn.cpp +++ b/src/PlugIn.cpp @@ -95,7 +95,19 @@ PlugIn::~PlugIn() noexcept { } void PlugIn::validateBackendData() { - std::string url = "http://" + this->m_configuration.address + ":5000/aman/airports"; + if (false == this->m_configuration.valid) { + this->m_compatible = false; + return; + } + + /* set up the URL */ + std::string url; + if (true == this->m_configuration.httpsProtocol) + url += "https://"; + else + url += "http://"; + url += this->m_configuration.address + ":" + std::to_string(this->m_configuration.portRestAPI) + "/aman/airports"; + CURL* curl = curl_easy_init(); CURLcode result; diff --git a/src/com/Backend.cpp b/src/com/Backend.cpp index 6f9d74e..0ec52fa 100644 --- a/src/com/Backend.cpp +++ b/src/com/Backend.cpp @@ -37,7 +37,7 @@ bool Backend::initialize(const Communication& configuration) { /* connect to the server */ try { - this->m_socket->connect("tcp://" + configuration.address + ":" + std::to_string(configuration.portReporter)); + this->m_socket->connect("tcp://" + configuration.address + ":" + std::to_string(configuration.portBackend)); } catch (zmq::error_t&) { this->m_socket = std::unique_ptr(); diff --git a/src/config/CommunicationFileFormat.cpp b/src/config/CommunicationFileFormat.cpp index 6c7a60c..edc524e 100644 --- a/src/config/CommunicationFileFormat.cpp +++ b/src/config/CommunicationFileFormat.cpp @@ -75,11 +75,14 @@ bool CommunicationFileFormat::parse(const std::string& filename, Communication& if ("Address" == gsl::at(entry, 0)) { config.address = gsl::at(entry, 1); } - else if ("PortReporter" == gsl::at(entry, 0)) { - config.portReporter = static_cast(std::atoi(gsl::at(entry, 1).c_str())); + else if ("HttpsProtocol" == gsl::at(entry, 0)) { + config.httpsProtocol = "0" != gsl::at(entry, 1); } - else if ("PortNotification" == gsl::at(entry, 0)) { - config.portNotification = static_cast(std::atoi(gsl::at(entry, 1).c_str())); + else if ("PortBackend" == gsl::at(entry, 0)) { + config.portBackend = static_cast(std::atoi(gsl::at(entry, 1).c_str())); + } + else if ("PortRestAPI" == gsl::at(entry, 0)) { + config.portRestAPI = static_cast(std::atoi(gsl::at(entry, 1).c_str())); } else { this->m_errorLine = lineOffset;