config/option/pingreplytimeoutoption.cpp
config/option/maxaddressresolutionattemptsoption.cpp
config/option/resolvedipttlthresholdoption.cpp
+ config/option/dnscachefileoption.cpp
dns_neww/dnscache.cpp
dns_neww/resolverbase.cpp
dns_neww/dnsresolver.cpp
PingReplyTimeout( 30 ),
MaxAddressResolutionAttempts( 10 ),
ResolvedIpTtlThreshold( 10 ),
+ DnsCacheFile(""),
Hosts(),
RatioRandomHosts( 1.0f ),
PrintVersion( false ),
ResolvedIpTtlThreshold = resolved_ip_ttl_threshold;
}
+void Configuration::set_dns_cache_file( const std::string &dns_cache_file)
+{
+ BOOST_ASSERT( !dns_cache_file.empty() );
+ DnsCacheFile = dns_cache_file;
+}
+
+std::string Configuration::get_dns_cache_file() const
+{
+ return DnsCacheFile;
+}
+
float Configuration::get_ratio_random_hosts() const
{
return RatioRandomHosts;
void set_print_version( const bool do_print );
bool get_print_version();
+ std::string get_dns_cache_file() const;
+ void set_dns_cache_file(const std::string &dns_cache_file);
+
bool randomize_hosts();
private:
HostList Hosts;
float RatioRandomHosts;
bool PrintVersion;
+ std::string DnsCacheFile;
rand_gen_type RandomNumberGenerator;
};
#include "config/option/pingreplytimeoutoption.h"
#include "config/option/maxaddressresolutionattemptsoption.h"
#include "config/option/resolvedipttlthresholdoption.h"
+#include "config/option/dnscachefileoption.h"
using namespace std;
using boost::program_options::option_description;
ConfigurationOptionItem ratio_random_hosts( new RatioRandomHostsOption );
ConfigOptions.push_back( ratio_random_hosts );
+ ConfigurationOptionItem dns_cache_file( new DnsCacheFileOption );
+ ConfigOptions.push_back( dns_cache_file );
+
HostConfigurationOptionItem host_name( new HostNameOption );
HostOptions.push_back( host_name );
--- /dev/null
+/*
+ The software in this package is distributed under the GNU General
+ Public License version 2 (with a special exception described below).
+
+ A copy of GNU General Public License (GPL) is included in this distribution,
+ in the file COPYING.GPL.
+
+ As a special exception, if other files instantiate templates or use macros
+ or inline functions from this file, or you compile this file and link it
+ with other works to produce a work based on this file, this file
+ does not by itself cause the resulting work to be covered
+ by the GNU General Public License.
+
+ However the source code for this file must still be made available
+ in accordance with section (3) of the GNU General Public License.
+
+ This exception does not invalidate any other reasons why a work based
+ on this file might be covered by the GNU General Public License.
+ */
+
+#include "config/option/dnscachefileoption.h"
+
+#include <iostream>
+
+#include <logfunc.hpp>
+
+using namespace std;
+using boost::program_options::value;
+using boost::program_options::variables_map;
+using I2n::Logger::GlobalLogger;
+
+//-----------------------------------------------------------------------------
+// DnsCacheFileOption
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief Default constructor.
+ */
+DnsCacheFileOption::DnsCacheFileOption() :
+ ConfigurationOption(
+ "dns-cache-file",
+ value<string>()->default_value( "/etc/pingcheck_dns_cache.xml" ),
+ "Name of the DNS cache file."
+ )
+{
+}
+
+/**
+ * @brief Destructor.
+ */
+DnsCacheFileOption::~DnsCacheFileOption()
+{
+}
+
+bool DnsCacheFileOption::parse(
+ const variables_map& vm,
+ Configuration *configuration
+)
+{
+ // dns-cache-file
+ if ( 1 <= vm.count( get_command_string() ) )
+ {
+ string dns_cache_file = vm[ get_command_string() ].as<string> ();
+ configuration->set_dns_cache_file( dns_cache_file );
+
+ GlobalLogger.info() << get_command_string() << "=" << dns_cache_file
+ << endl;
+ return true;
+ }
+
+ return false;
+}
--- /dev/null
+/*
+ The software in this package is distributed under the GNU General
+ Public License version 2 (with a special exception described below).
+
+ A copy of GNU General Public License (GPL) is included in this distribution,
+ in the file COPYING.GPL.
+
+ As a special exception, if other files instantiate templates or use macros
+ or inline functions from this file, or you compile this file and link it
+ with other works to produce a work based on this file, this file
+ does not by itself cause the resulting work to be covered
+ by the GNU General Public License.
+
+ However the source code for this file must still be made available
+ in accordance with section (3) of the GNU General Public License.
+
+ This exception does not invalidate any other reasons why a work based
+ on this file might be covered by the GNU General Public License.
+ */
+
+#ifndef DNS_CACHE_FILE_OPTION_H
+#define DNS_CACHE_FILE_OPTION_H
+
+#include <boost/program_options.hpp>
+
+#include "config/option/configurationoption.h"
+
+//-----------------------------------------------------------------------------
+// DnsCacheFileOption
+//-----------------------------------------------------------------------------
+
+/**
+ * @brief DNS Cache file name option.
+ */
+class DnsCacheFileOption : public ConfigurationOption
+{
+public:
+ DnsCacheFileOption();
+ virtual ~DnsCacheFileOption();
+
+ virtual bool parse(
+ const boost::program_options::variables_map &vm,
+ Configuration *configuration
+ );
+
+};
+
+#endif // DNS_CACHE_FILE_OPTION_H