From: Guilherme Maciel Ferreira Date: Wed, 4 May 2011 09:41:06 +0000 (+0200) Subject: Solved the item: X-Git-Tag: v1.0~28 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=766b964880ea8c8047db5a3a809e6362ae3e8ee8;p=pingcheck Solved the item: - Perform a better treatment of missing configuration items, actually the application just crashes. All items that are strictly required have default values, or are checked against valid values. The last item missing was nameserver, which has a default value now. --- diff --git a/TODO b/TODO index 79c0ee8..7a30f9d 100644 --- a/TODO +++ b/TODO @@ -27,9 +27,6 @@ TODO Guilherme: - fix config parser: -- Perform a better treatment of missing configuration items, actually the - application just crashes. - - Documentation of the functions (doxygen) - Make the link down interval also configurable. Today it is possible just to diff --git a/src/config/configurationreader.cpp b/src/config/configurationreader.cpp index d963fa9..0f11c1d 100644 --- a/src/config/configurationreader.cpp +++ b/src/config/configurationreader.cpp @@ -34,6 +34,7 @@ ConfigurationReader::ConfigurationReader() : ConfigFileCmdDesc( "Name of the configuration file." ), SourceNetworkInterfaceCmdStr( "source-network-interface" ), SourceNetworkInterfaceCmdDesc( "The network interface from where the packets will be received and originated" ), + DefaultNameServer( "127.0.0.1" ), NameServerCmdStr( "nameserver" ), NameServerCmdDesc( "The local address from where the DNS query will be made." ), DefaultHostsDownLimit( 0 ), // no host down @@ -169,7 +170,7 @@ options_description ConfigurationReader::get_configuration_options() const options_description options( "Configuration" ); options.add_options() ( SourceNetworkInterfaceCmdStr.c_str(), value(), SourceNetworkInterfaceCmdDesc.c_str() ) - ( NameServerCmdStr.c_str(), value(), NameServerCmdDesc.c_str() ) + ( NameServerCmdStr.c_str(), value()->default_value( DefaultNameServer ), NameServerCmdDesc.c_str() ) ( HostsDownLimitCmdStr.c_str(), value()->default_value( DefaultHostsDownLimit ), HostsDownLimitCmdDesc.c_str() ) ( PingFailLimitCmdStr.c_str(), value()->default_value( DefaultPingFailLimit ), PingFailLimitCmdDesc.c_str() ) ( StatusNotifierCmdCmdStr.c_str(), value(), StatusNotifierCmdCmdDesc.c_str() ) diff --git a/src/config/configurationreader.h b/src/config/configurationreader.h index f7b8e2a..68f7f43 100644 --- a/src/config/configurationreader.h +++ b/src/config/configurationreader.h @@ -64,6 +64,7 @@ private: const std::string ConfigFileCmdDesc; const std::string SourceNetworkInterfaceCmdStr; const std::string SourceNetworkInterfaceCmdDesc; + const std::string DefaultNameServer; const std::string NameServerCmdStr; const std::string NameServerCmdDesc; const int DefaultHostsDownLimit;