2 * @brief IPHelper class header. This class represents a Helper to get the actual IP.
6 * @copyright Intra2net AG
10 #ifndef IPADDRHELPER_H
11 #define IPADDRHELPER_H
15 #include <boost/shared_ptr.hpp>
16 #include <curl/curl.h>
18 #include <boost/archive/text_oarchive.hpp>
19 #include <boost/archive/text_iarchive.hpp>
27 friend class boost::serialization::access;
28 template<class Archive>
29 void serialize(Archive & ar, const unsigned int version)
35 std::string WebcheckIpUrl;
36 std::string WebcheckIpUrlAlt;
44 bool is_local_ipv4(const std::string ip) const;
45 bool is_local_ipv6(const std::string ip) const;
46 std::string webcheck_ip();
47 CURL * init_curl(std::string& curl_writedata_buff, char* curl_err_buff) const;
48 int perform_curl_operation(CURL * curl_easy_handle, const char* curl_err_buff, const std::string& actual_url) const;
49 std::string parse_ipv4(const std::string& data) const;
50 CURLcode set_curl_url(CURL * curl_easy_handle, const std::string& url) const;
54 typedef boost::shared_ptr<IPAddrHelper> Ptr;
58 IPAddrHelper(const Logger::Ptr _log, const std::string& _webcheck_url, const std::string& _webcheck_url_alt, const int _webcheck_interval, const time_t _last_webcheck, const bool _use_ipv6, const std::string& _proxy, const int _proxy_port);
62 std::string dns_query(const std::string& _hostname) const;
64 std::string get_actual_ip( bool use_webcheck );
66 std::string get_local_wan_nic_ip() const;
68 // libcurl is a C library, so we have to make the callback member function static :-(
69 static size_t http_receive(const char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer);
71 time_t get_last_webcheck() const;