mirror of
https://github.com/matrix-construct/construct
synced 2024-06-25 21:38:18 +02:00
modules/console: Add net service console cmd.
This commit is contained in:
parent
ffcbc87fdd
commit
cf37e364ce
|
@ -5419,6 +5419,45 @@ console_cmd__net__addrs(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__net__service(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"service", "proto"
|
||||
}};
|
||||
|
||||
const string_view &service
|
||||
{
|
||||
param.at("service")
|
||||
};
|
||||
|
||||
const string_view &proto
|
||||
{
|
||||
param.at("proto", "tcp"_sv)
|
||||
};
|
||||
|
||||
if(lex_castable<uint16_t>(service))
|
||||
{
|
||||
char buf[64];
|
||||
const auto name
|
||||
{
|
||||
net::dns::service_name(buf, lex_cast<uint16_t>(service), proto)
|
||||
};
|
||||
|
||||
out << name << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto port
|
||||
{
|
||||
net::dns::service_port(service, proto)
|
||||
};
|
||||
|
||||
out << port << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__net__host(opt &out, const string_view &line)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue