@@ -79,8 +79,8 @@ std::string kiwix::download(const std::string& url) {
79
79
80
80
#ifdef _WIN32
81
81
82
- std::map<std::string,ip_addr> kiwix::getNetworkInterfacesWin () {
83
- std::map<std::string,ip_addr > interfaces;
82
+ std::map<std::string,kiwix::IpAddress> getNetworkInterfacesWin () {
83
+ std::map<std::string,kiwix::IpAddress > interfaces;
84
84
85
85
const int working_buffer_size = 15000 ;
86
86
const int max_tries = 3 ;
@@ -98,15 +98,13 @@ std::map<std::string,ip_addr> kiwix::getNetworkInterfacesWin() {
98
98
// Successively allocate the required memory until GetAdaptersAddresses does not
99
99
// results in ERROR_BUFFER_OVERFLOW for a maximum of max_tries
100
100
do {
101
-
102
101
interfacesHead = (IP_ADAPTER_ADDRESSES *) malloc (outBufLen);
103
102
if (interfacesHead == NULL ) {
104
103
std::cerr << " Memory allocation failed for IP_ADAPTER_ADDRESSES struct" << std::endl;
105
104
return interfaces;
106
105
}
107
106
108
107
dwRetVal = GetAdaptersAddresses (family, flags, NULL , interfacesHead, &outBufLen);
109
-
110
108
} while ((dwRetVal == ERROR_BUFFER_OVERFLOW) && (Iterations < max_tries));
111
109
112
110
if (dwRetVal == NO_ERROR) {
@@ -147,8 +145,8 @@ std::map<std::string,ip_addr> kiwix::getNetworkInterfacesWin() {
147
145
148
146
#else
149
147
150
- std::map<std::string,ip_addr> kiwix::getNetworkInterfacesPosix () {
151
- std::map<std::string,ip_addr > interfaces;
148
+ std::map<std::string,kiwix::IpAddress> getNetworkInterfacesPosix () {
149
+ std::map<std::string,kiwix::IpAddress > interfaces;
152
150
153
151
struct ifaddrs *interfacesHead;
154
152
if (getifaddrs (&interfacesHead) == -1 ) {
@@ -179,20 +177,17 @@ std::map<std::string,ip_addr> kiwix::getNetworkInterfacesPosix() {
179
177
180
178
#endif
181
179
182
- std::map<std::string,ip_addr> kiwix::getNetworkInterfaces () {
183
- std::map<std::string,ip_addr> interfaces;
184
-
180
+ std::map<std::string,kiwix::IpAddress> kiwix::getNetworkInterfaces () {
185
181
#ifdef _WIN32
186
182
return getNetworkInterfacesWin ();
187
183
#else
188
184
return getNetworkInterfacesPosix ();
189
185
#endif
190
-
191
186
}
192
187
193
188
std::string kiwix::getBestPublicIp (bool ipv6) {
194
- ip_addr bestPublicIp = ip_addr {" 127.0.0.1" ," ::1" };
195
- std::map<std::string,ip_addr > interfaces = getNetworkInterfaces ();
189
+ kiwix::IpAddress bestPublicIp = kiwix::IpAddress {" 127.0.0.1" ," ::1" };
190
+ std::map<std::string,kiwix::IpAddress > interfaces = getNetworkInterfaces ();
196
191
197
192
#ifndef _WIN32
198
193
const char * const prioritizedNames[] =
0 commit comments