From 53c634c44a9612f367bd13ba86bbd7117bf4427c Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Testillano Date: Sat, 12 Jul 2014 18:41:32 +0200 Subject: [PATCH] Make http interface optional in diameter launcher --- example/diameter/launcher/main.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/example/diameter/launcher/main.cpp b/example/diameter/launcher/main.cpp index dce3235..89858b2 100644 --- a/example/diameter/launcher/main.cpp +++ b/example/diameter/launcher/main.cpp @@ -811,7 +811,7 @@ int main(int argc, const char** argv) { commandLine.add("logStatisticSamples", anna::CommandLine::Argument::Optional, "Log statistics samples for the provided concept id list, over './sample..csv' files. For example: \"1,2\" will log concepts 1 and 2. Reserved word \"all\" activates all registered statistics concept identifiers. That ids are shown at context dump (see help to get it)."); commandLine.add("burstLog", anna::CommandLine::Argument::Optional, "Burst operations log file. By default 'launcher.burst'. Empty string or \"null\" name, to disable. Warning: there is no rotation for log files (use logrotate or whatever). Output: dot (.) for each burst message sent/pushed, cross (x) for popped ones, and order number when multiple of 1% of burst list size, plus OTA requests when changed."); // Communications - commandLine.add("httpServer", anna::CommandLine::Argument::Mandatory, "HTTP Management interface address (using i.e. curl tool) in '
:' format. For example: 10.20.30.40:8080"); + commandLine.add("httpServer", anna::CommandLine::Argument::Optional, "HTTP Management interface address (using i.e. curl tool) in '
:' format. For example: 10.20.30.40:8080"); commandLine.add("httpServerShared", anna::CommandLine::Argument::Optional, "Enables shared bind for HTTP Management interface address. It would be useful i.e. to allow a great amount of curl operations per second", false); commandLine.add("diameterServer", anna::CommandLine::Argument::Optional, "Diameter own server address in '
:' format. For example: 10.20.30.40:3868"); commandLine.add("diameterServerSessions", anna::CommandLine::Argument::Optional, "Diameter own server available connections (0: diameter server disabled). Default value of 1"); @@ -1271,13 +1271,16 @@ throw(anna::RuntimeException) { anna::Logger::information(msg, ANNA_FILE_LOCATION); ); // HTTP Server: - anna::comm::Network& network = anna::comm::Network::instantiate(); - std::string address; - int port; - anna::functions::getAddressAndPortFromSocketLiteral(cl.getValue("httpServer"), address, port); -// const anna::comm::Device* device = network.find(Device::asAddress(address)); // aqui hay que proporcionar una IP ! - const anna::comm::Device* device = *((network.resolve(address)->device_begin())); // ArtimaƱa para resolver (IP o hostname) - a_httpServerSocket = new anna::comm::ServerSocket(anna::comm::INetAddress(device, port), cl.exists("httpServerShared") /* shared bind */, &anna::http::Transport::getFactory()); + if (cl.exists("httpServer")) { + anna::comm::Network& network = anna::comm::Network::instantiate(); + std::string address; + int port; + anna::functions::getAddressAndPortFromSocketLiteral(cl.getValue("httpServer"), address, port); + //const anna::comm::Device* device = network.find(Device::asAddress(address)); // aqui hay que proporcionar una IP ! + const anna::comm::Device* device = *((network.resolve(address)->device_begin())); // ArtimaƱa para resolver (IP o hostname) + a_httpServerSocket = new anna::comm::ServerSocket(anna::comm::INetAddress(device, port), cl.exists("httpServerShared") /* shared bind */, &anna::http::Transport::getFactory()); + } + // Stack: anna::diameter::codec::Engine *codecEngine = new anna::diameter::codec::Engine(); anna::diameter::stack::Engine &stackEngine = anna::diameter::stack::Engine::instantiate(); @@ -1414,7 +1417,7 @@ throw(anna::RuntimeException) { } a_communicator->setRecoveryTime((const anna::Millisecond)reconnectionPeriod); - a_communicator->attach(a_httpServerSocket); // HTTP + if (cl.exists("httpServer")) a_communicator->attach(a_httpServerSocket); // HTTP a_communicator->accept(); } -- 2.20.1