1
0
mirror of https://github.com/yarrick/iodine.git synced 2024-11-25 22:46:05 +03:00

#45: Use IpHelper to get DNS server on win32

This commit is contained in:
Erik Ekman 2009-02-22 14:27:10 +00:00
parent 844342e1c1
commit a3cea72400
5 changed files with 24 additions and 3 deletions

View File

@ -12,6 +12,7 @@ CHANGES:
- Added syslog logging for iodined on version and login packets
- Fixed segfault when encoding just one block, fixes #51.
The normal code was never affected by this.
- Added win32 code to read DNS server from system, fixes #45.
2009-01-23: 0.5.0 "iPassed"
- Fixed segfault in server when sending version reject.

View File

@ -49,7 +49,6 @@ cross-compile.
== Results of crappy Win32 API:
The following fixable limitations apply:
- The password is shown when entered
- DNS server IP can not be fetched automatically
- Exactly one TAP32 interface must be installed
- The TAP32 interface must be named "dns" and be version 0801
- Server cannot read packet destination address

View File

@ -890,8 +890,9 @@ static char *
get_resolvconf_addr()
{
static char addr[16];
char buf[80];
char *rv;
#ifndef WINDOWS32
char buf[80];
FILE *fp;
rv = NULL;
@ -909,7 +910,26 @@ get_resolvconf_addr()
}
fclose(fp);
#else /* !WINDOWS32 */
FIXED_INFO *fixed_info;
ULONG buflen;
DWORD ret;
rv = NULL;
fixed_info = malloc(sizeof(FIXED_INFO));
buflen = sizeof(FIXED_INFO);
if (GetNetworkParams(fixed_info, &buflen) == ERROR_BUFFER_OVERFLOW) {
/* official ugly api workaround */
free(fixed_info);
fixed_info = malloc(buflen);
}
ret = GetNetworkParams(fixed_info, &buflen);
if (ret == NO_ERROR) {
rv = fixed_info->DnsServerList.IpAddress.String;
}
#endif
return rv;
}

View File

@ -14,7 +14,7 @@ link)
echo '-lnetwork';
;;
windows32)
echo '-lws2_32';
echo '-lws2_32 -liphlpapi';
;;
esac
;;

View File

@ -22,6 +22,7 @@ typedef unsigned int in_addr_t;
#include <windows.h>
#include <windns.h>
#include <winsock2.h>
#include <iphlpapi.h>
#define T_A DNS_TYPE_A
#define T_NS DNS_TYPE_NS