Browse Source

Flush DNS cache if --dns-addr is used

pull/48/head
ValdikSS 7 years ago
parent
commit
363b2dca37
  1. 16
      dnsredir.c
  2. 2
      dnsredir.h
  3. 1
      goodbyedpi.c

16
dnsredir.c

@ -50,6 +50,22 @@ typedef struct udp_connrecord {
static time_t last_cleanup = 0;
static udp_connrecord_t *conntrack = NULL;
void flush_dns_cache() {
BOOL WINAPI (*DnsFlushResolverCache)();
HMODULE dnsapi = LoadLibrary("dnsapi.dll");
if (dnsapi == NULL)
{
printf("Can't load dnsapi.dll to flush DNS cache!\n");
exit(EXIT_FAILURE);
}
DnsFlushResolverCache = GetProcAddress(dnsapi, "DnsFlushResolverCache");
if (DnsFlushResolverCache == NULL || !DnsFlushResolverCache())
printf("Can't flush DNS cache!");
FreeLibrary(dnsapi);
}
inline static void construct_key(const uint32_t srcip, const uint16_t srcport, char *key) {
debug("Construct key enter\n");
if (key) {

2
dnsredir.h

@ -15,3 +15,5 @@ int dns_handle_incoming(const uint32_t srcip, const uint16_t srcport,
int dns_handle_outgoing(const uint32_t srcip, const uint16_t srcport,
const uint32_t dstip, const uint16_t dstport,
const char *packet_data, const UINT packet_dataLen);
void flush_dns_cache();

1
goodbyedpi.c

@ -337,6 +337,7 @@ int main(int argc, char *argv[]) {
exit(EXIT_FAILURE);
}
add_filter_str(IPPROTO_UDP, 53);
flush_dns_cache();
}
break;
case 'g':

Loading…
Cancel
Save