Overview
Comment: | OFDNSResolver: Get name servers & domain on Win32 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
42bee3f92055372def2de9bde5c0caa7 |
User & Date: | js on 2018-07-10 22:58:16 |
Other Links: | manifest | tags |
Context
2018-07-28
| ||
14:33 | OFDNSResolver: Add resolv.conf path for MorphOS check-in: d0099ed8c9 user: js tags: trunk | |
2018-07-10
| ||
22:58 | OFDNSResolver: Get name servers & domain on Win32 check-in: 42bee3f920 user: js tags: trunk | |
21:24 | OFDNSResolver: Win32: Get hosts path from registry check-in: 4b20f0e12c user: js tags: trunk | |
Changes
Modified configure.ac from [67c3ea16a5] to [1c10342f65].
︙ | ︙ | |||
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 | AS_IF([test x"$enable_sockets" != x"no"], [ AC_DEFINE(OF_HAVE_SOCKETS, 1, [Whether we have sockets]) AC_SUBST(USE_SRCS_SOCKETS, '${SRCS_SOCKETS}') AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket") AC_CHECK_LIB(network, socket, LIBS="$LIBS -lnetwork") AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32") AC_CHECK_HEADER(sys/socket.h, [ AC_DEFINE(OF_HAVE_SYS_SOCKET_H, 1, [Whether we have sys/socket.h]) ]) AC_CHECK_HEADER(netinet/in.h, [ AC_DEFINE(OF_HAVE_NETINET_IN_H, 1, | > | 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 | AS_IF([test x"$enable_sockets" != x"no"], [ AC_DEFINE(OF_HAVE_SOCKETS, 1, [Whether we have sockets]) AC_SUBST(USE_SRCS_SOCKETS, '${SRCS_SOCKETS}') AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket") AC_CHECK_LIB(network, socket, LIBS="$LIBS -lnetwork") AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32") AC_CHECK_LIB(iphlpapi, main, LIBS="$LIBS -liphlpapi") AC_CHECK_HEADER(sys/socket.h, [ AC_DEFINE(OF_HAVE_SYS_SOCKET_H, 1, [Whether we have sys/socket.h]) ]) AC_CHECK_HEADER(netinet/in.h, [ AC_DEFINE(OF_HAVE_NETINET_IN_H, 1, |
︙ | ︙ |
Modified src/OFDNSResolver.m from [452969d7b3] to [231fa481e0].
︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #import "OFLocalization.h" #import "OFString.h" #ifdef OF_WINDOWS # import "OFWindowsRegistryKey.h" #endif #import "OFOpenItemFailedException.h" @interface OFDNSResolver () #ifdef OF_HAVE_FILES - (void)of_parseHosts: (OFString *)path; - (void)of_parseResolvConf: (OFString *)path; - (void)of_parseResolvConfOption: (OFString *)option; #endif @end static OFString * domainFromHostname(void) { char hostname[256]; | > > > > > > > > > > > | 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 | #import "OFLocalization.h" #import "OFString.h" #ifdef OF_WINDOWS # import "OFWindowsRegistryKey.h" #endif #import "OFOpenItemFailedException.h" #ifdef OF_WINDOWS # define interface struct # include <iphlpapi.h> # undef interface #endif @interface OFDNSResolver () #ifdef OF_HAVE_FILES - (void)of_parseHosts: (OFString *)path; # ifndef OF_WINDOWS - (void)of_parseResolvConf: (OFString *)path; - (void)of_parseResolvConfOption: (OFString *)option; # endif #endif #ifdef OF_WINDOWS - (void)of_parseNetworkParams; #endif @end static OFString * domainFromHostname(void) { char hostname[256]; |
︙ | ︙ | |||
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | # elif defined(OF_AMIGAOS4) [self of_parseHosts: @"DEVS:Internet/hosts"]; # elif defined(OF_AMIGAOS) [self of_parseHosts: @"AmiTCP:db/hosts"]; # else [self of_parseHosts: @"/etc/hosts"]; # endif [self of_parseResolvConf: @"/etc/resolv.conf"]; [self of_parseResolvConf: @"/etc/resolv.conf.tail"]; #endif if (_staticHosts == nil) _staticHosts = [[OFDictionary alloc] init]; if (_nameServers == nil) _nameServers = [[OFArray alloc] initWithObjects: | > > > > > | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | # elif defined(OF_AMIGAOS4) [self of_parseHosts: @"DEVS:Internet/hosts"]; # elif defined(OF_AMIGAOS) [self of_parseHosts: @"AmiTCP:db/hosts"]; # else [self of_parseHosts: @"/etc/hosts"]; # endif # ifndef OF_WINDOWS [self of_parseResolvConf: @"/etc/resolv.conf"]; [self of_parseResolvConf: @"/etc/resolv.conf.tail"]; # endif #endif #ifdef OF_WINDOWS [self of_parseNetworkParams]; #endif if (_staticHosts == nil) _staticHosts = [[OFDictionary alloc] init]; if (_nameServers == nil) _nameServers = [[OFArray alloc] initWithObjects: |
︙ | ︙ | |||
212 213 214 215 216 217 218 219 220 221 222 223 224 225 | [_staticHosts release]; _staticHosts = [staticHosts copy]; objc_autoreleasePoolPop(pool); } - (void)of_parseResolvConf: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFCharacterSet *whitespaceCharacterSet = [OFCharacterSet whitespaceCharacterSet]; OFCharacterSet *commentCharacters = [OFCharacterSet characterSetWithCharactersInString: @"#;"]; | > | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | [_staticHosts release]; _staticHosts = [staticHosts copy]; objc_autoreleasePoolPop(pool); } # ifndef OF_WINDOWS - (void)of_parseResolvConf: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFCharacterSet *whitespaceCharacterSet = [OFCharacterSet whitespaceCharacterSet]; OFCharacterSet *commentCharacters = [OFCharacterSet characterSetWithCharactersInString: @"#;"]; |
︙ | ︙ | |||
305 306 307 308 309 310 311 312 313 | (size_t)[option decimalValue]; } @catch (id e) { return; } } else if ([option isEqual: @"tcp"]) _usesTCP = true; } #endif @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | (size_t)[option decimalValue]; } @catch (id e) { return; } } else if ([option isEqual: @"tcp"]) _usesTCP = true; } # endif #endif #ifdef OF_WINDOWS - (void)of_parseNetworkParams { void *pool = objc_autoreleasePoolPush(); of_string_encoding_t encoding = [OFLocalization encoding]; OFMutableArray *nameServers; OFString *localDomain; /* * We need more space than FIXED_INFO in case we have more than one * name server, but we also want it to be properly aligned, meaning we * can't just get a buffer of bytes. Thus, we just get space for 8. */ FIXED_INFO fixedInfo[8]; ULONG length = sizeof(fixedInfo); PIP_ADDR_STRING iter; if (GetNetworkParams(fixedInfo, &length) != ERROR_SUCCESS) return; nameServers = [OFMutableArray array]; localDomain = [OFString stringWithCString: fixedInfo->DomainName encoding: encoding]; for (iter = &fixedInfo->DnsServerList; iter != NULL; iter = iter->Next) [nameServers addObject: [OFString stringWithCString: iter->IpAddress.String encoding: encoding]]; if ([nameServers count] > 0) { [nameServers makeImmutable]; _nameServers = [nameServers copy]; } if ([localDomain length] > 0) _localDomain = [localDomain copy]; objc_autoreleasePoolPop(pool); } #endif @end |