mirror of
https://github.com/ValdikSS/GoodbyeDPI.git
synced 2024-12-22 06:15:27 +00:00
Flush DNS cache if --dns-addr is used
This commit is contained in:
parent
1e8835cfe5
commit
363b2dca37
16
dnsredir.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) {
|
||||
|
@ -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();
|
||||
|
@ -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…
Reference in New Issue
Block a user