Newer
Older
#ifndef _RESOLVER_HPP
#define _RESOLVER_HPP
#include <vector>
#include "ipaddr.hpp"
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**
* @brief Provide multiple ways to resolve hostnames to Ipv4 and/or Ipv6
* addresses.
*/
class Resolver
{
private:
/**
* @brief Resolve a given hostname to first ip address that is found. The
* address family can be specified to narrow the resolve to specifically
* only Ipv4, Ipv6 or both.
*
* If the hostname could not be resolved, an exception is thrown.
*
* @param hostname The string representing the hostname that should be
* resolved.
* @param address_family The address family to be used as filter. Should be
* AF_INET for Ipv4 only, AF_INET6 for Ipv6 only or AF_UNSPEC for both.
*
* @return The first IpAddress that was resolved for the given hostname.
*/
static IpAddr resolveHostnameAF(const std::string &hostname, int address_family);
/**
* @brief Resolve a given hostname and get all associated ip addresses. The
* address family can be specified to narrow the resolve to specifically
* only Ipv4, Ipv6 or both.
*
* If the hostname could not be resolved at all, an exception is thrown.
*
* @param hostname The string representing the hostname that should be
* resolved.
* @param address_family The address family to be used as filter. Should be
* AF_INET for Ipv4 only, AF_INET6 for Ipv6 only or AF_UNSPEC for both.
*
* @return A list of all ip addresses resolved by the hostname. If
* address_family filters only certain types, this only contains those.
*/
static std::vector<IpAddr> resolveHostnameAllAF(const std::string &hostname, int address_family);
public:
/**
* @brief Resolve a given hostname to first Ipv4 ip address that is found.
*
* If the hostname could not be resolved, an exception is thrown.
*
* @param hostname The string representing the hostname that should be
* resolved.
*
* @return The first IpAddress that was resolved for the given hostname.
*/
static IpAddr resolveHostnameIpv4(const std::string &hostname);
/**
* @brief Resolve a given hostname to first Ipv6 ip address that is found.
*
* If the hostname could not be resolved, an exception is thrown.
*
* @param hostname The string representing the hostname that should be
* resolved.
*
* @return The first IpAddress that was resolved for the given hostname.
*/
static IpAddr resolveHostnameIpv6(const std::string &hostname);
/**
* @brief Resolve a given hostname and get all associated Ipv4 ip addresses.
*
* If the hostname could not be resolved at all, an exception is thrown.
*
* @param hostname The string representing the hostname that should be
* resolved.
*
* @return A list of all Ipv4 ip addresses resolved by the hostname.
*/
static std::vector<IpAddr> resolveHostnameAllIpv4(const std::string &hostname);
/**
* @brief Resolve a given hostname and get all associated Ipv6 ip addresses.
*
* If the hostname could not be resolved at all, an exception is thrown.
*
* @param hostname The string representing the hostname that should be
* resolved.
*
* @return A list of all Ipv6 ip addresses resolved by the hostname.
*/
static std::vector<IpAddr> resolveHostnameAllIpv6(const std::string &hostname);
/**
* @brief Resolve a given hostname and get all associated ip addresses.
* This contains both Ipv4 and Ipv6 ip addresses.
*
* If the hostname could not be resolved at all, an exception is thrown.
*
* @param hostname The string representing the hostname that should be
* resolved.
*
* @return A list of all Ipv4 and Ipv6 ip addresses resolved by the hostname.
*/
static std::vector<IpAddr> resolveHostnameAll(const std::string &hostname);
};