0
0
Fork 0
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:
Jason Volk 2020-03-12 09:35:49 -07:00
parent ffcbc87fdd
commit cf37e364ce

View file

@ -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)
{