mirror of
https://github.com/matrix-construct/construct
synced 2024-10-04 14:48:56 +02:00
modules/console: Add console command suite to view DNS caches.
This commit is contained in:
parent
d54d6b687c
commit
15ec746fc6
1 changed files with 54 additions and 0 deletions
|
@ -358,6 +358,7 @@ console_cmd__net(const string_view &line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool console_cmd__net_host_cache(const string_view &line);
|
||||||
static bool console_cmd__net_host__default(const string_view &line);
|
static bool console_cmd__net_host__default(const string_view &line);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -370,6 +371,9 @@ console_cmd__net_host(const string_view &line)
|
||||||
|
|
||||||
switch(hash(token(line, " ", 0)))
|
switch(hash(token(line, " ", 0)))
|
||||||
{
|
{
|
||||||
|
case hash("cache"):
|
||||||
|
return console_cmd__net_host_cache(args);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return console_cmd__net_host__default(line);
|
return console_cmd__net_host__default(line);
|
||||||
}
|
}
|
||||||
|
@ -377,6 +381,56 @@ console_cmd__net_host(const string_view &line)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
console_cmd__net_host_cache(const string_view &line)
|
||||||
|
{
|
||||||
|
switch(hash(token(line, " ", 0)))
|
||||||
|
{
|
||||||
|
case hash("A"):
|
||||||
|
{
|
||||||
|
for(const auto &pair : net::dns::cache.A)
|
||||||
|
{
|
||||||
|
const auto &host{pair.first};
|
||||||
|
const auto &record{pair.second};
|
||||||
|
const net::ipport ipp{record.ip4, 0};
|
||||||
|
out << std::setw(32) << host
|
||||||
|
<< " => " << ipp
|
||||||
|
<< " expires " << timestr(record.ttl, ircd::localtime)
|
||||||
|
<< " (" << record.ttl << ")"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case hash("SRV"):
|
||||||
|
{
|
||||||
|
for(const auto &pair : net::dns::cache.SRV)
|
||||||
|
{
|
||||||
|
const auto &key{pair.first};
|
||||||
|
const auto &record{pair.second};
|
||||||
|
const net::hostport hostport
|
||||||
|
{
|
||||||
|
record.tgt, record.port
|
||||||
|
};
|
||||||
|
|
||||||
|
out << std::setw(32) << key
|
||||||
|
<< " => " << hostport
|
||||||
|
<< " expires " << timestr(record.ttl, ircd::localtime)
|
||||||
|
<< " (" << record.ttl << ")"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: throw bad_command
|
||||||
|
{
|
||||||
|
"Which cache?"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
console_cmd__net_host__default(const string_view &line)
|
console_cmd__net_host__default(const string_view &line)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue