mirror of
https://github.com/bol-van/zapret.git
synced 2025-08-10 01:02:03 +03:00
nfqws: ip->hostname cache
This commit is contained in:
11
nfq/pools.c
11
nfq/pools.c
@@ -589,8 +589,13 @@ static void ipcache_item_touch(ip_cache_item *item)
|
||||
static void ipcache_item_init(ip_cache_item *item)
|
||||
{
|
||||
ipcache_item_touch(item);
|
||||
item->hostname = NULL;
|
||||
item->hops = 0;
|
||||
}
|
||||
static void ipcache_item_destroy(ip_cache_item *item)
|
||||
{
|
||||
free(item->hostname);
|
||||
}
|
||||
|
||||
static void ipcache4Destroy(ip_cache4 **ipcache)
|
||||
{
|
||||
@@ -598,6 +603,7 @@ static void ipcache4Destroy(ip_cache4 **ipcache)
|
||||
HASH_ITER(hh, *ipcache, elem, tmp)
|
||||
{
|
||||
HASH_DEL(*ipcache, elem);
|
||||
ipcache_item_destroy(&elem->data);
|
||||
free(elem);
|
||||
}
|
||||
}
|
||||
@@ -645,7 +651,7 @@ static void ipcache4Print(ip_cache4 *ipcache)
|
||||
{
|
||||
*s_ip=0;
|
||||
inet_ntop(AF_INET, &ipc->key.addr, s_ip, sizeof(s_ip));
|
||||
printf("%s iface=%s : hops %u now=last+%llu\n", s_ip, ipc->key.iface, ipc->data.hops, (unsigned long long)(now-ipc->data.last));
|
||||
printf("%s iface=%s : hops %u hostname=%s now=last+%llu\n", s_ip, ipc->key.iface, ipc->data.hops, ipc->data.hostname ? ipc->data.hostname : "", (unsigned long long)(now-ipc->data.last));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -655,6 +661,7 @@ static void ipcache6Destroy(ip_cache6 **ipcache)
|
||||
HASH_ITER(hh, *ipcache, elem, tmp)
|
||||
{
|
||||
HASH_DEL(*ipcache, elem);
|
||||
ipcache_item_destroy(&elem->data);
|
||||
free(elem);
|
||||
}
|
||||
}
|
||||
@@ -702,7 +709,7 @@ static void ipcache6Print(ip_cache6 *ipcache)
|
||||
{
|
||||
*s_ip=0;
|
||||
inet_ntop(AF_INET6, &ipc->key.addr, s_ip, sizeof(s_ip));
|
||||
printf("%s iface=%s : hops %u now=last+%llu\n", s_ip, ipc->key.iface, ipc->data.hops, (unsigned long long)(now-ipc->data.last));
|
||||
printf("%s iface=%s : hops %u hostname=%s now=last+%llu\n", s_ip, ipc->key.iface, ipc->data.hops, ipc->data.hostname ? ipc->data.hostname : "", (unsigned long long)(now-ipc->data.last));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user