2 The software in this package is distributed under the GNU General
3 Public License version 2 (with a special exception described below).
5 A copy of GNU General Public License (GPL) is included in this distribution,
6 in the file COPYING.GPL.
8 As a special exception, if other files instantiate templates or use macros
9 or inline functions from this file, or you compile this file and link it
10 with other works to produce a work based on this file, this file
11 does not by itself cause the resulting work to be covered
12 by the GNU General Public License.
14 However the source code for this file must still be made available
15 in accordance with section (3) of the GNU General Public License.
17 This exception does not invalidate any other reasons why a work based
18 on this file might be covered by the GNU General Public License.
20 Christian Herdtweck, Intra2net AG 2015
23 #ifndef IP_PSEUDO_RESOLVER_H
24 #define IP_PSEUDO_RESOLVER_H
26 #include <boost/asio/ip/address.hpp>
27 #include "dns/hostaddress.h"
28 #include "dns/resolverbase.h"
29 #include "dns/dnsmaster.h"
33 uint32_t DefaultTtl = 60*60*24*356; // 1 year in seconds (approx)
36 /** @brief Degenerate case of a resolver: hostname is already an IP
38 * created by DnsMaster if given an IP address as hostname
40 * Will do nothing, just remember that IP and return it for every call to
43 * Since this is so boring, I did not create an own .cpp for it
45 class IpPseudoResolver : public ResolverBase
47 // constructor accessible from friend DnsMaster
49 friend ResolverItem& DnsMaster::get_resolver_for(
50 const std::string &hostname,
51 const DnsIpProtocol &protocol);
53 IpPseudoResolver(const IoServiceItem io_serv,
54 const std::string &ip_string,
55 const DnsCacheItem &cache )
56 : ResolverBase( io_serv, ip_string, cache )
57 , IpAddress( boost::asio::ip::address::from_string(ip_string),
62 HostAddress IpAddress;
64 // only real public function
66 HostAddress get_next_ip(const bool check_up_to_date=true)
68 bool have_up_to_date_ip() { return true; }
69 int get_resolved_ip_count() { return 1; }
70 bool is_resolving() const { return false; }
71 bool is_waiting_to_resolve() const { return false; }
72 void cancel_resolve() {}
74 // implementation of ResolverBase::async_resolve
77 { ResolverBase::schedule_callbacks(true, 0); }
81 // (created using vim -- the world's best text editor)