mirror of
https://github.com/matrix-construct/construct
synced 2024-06-09 05:29:00 +02:00
ircd:Ⓜ️🆔 Add test for whether hostname is an IP literal.
This commit is contained in:
parent
85cbaffca4
commit
3e1157f043
|
@ -72,6 +72,7 @@ struct ircd::m::id
|
|||
string_view localname() const; // The localpart not including sigil
|
||||
string_view hostname() const; // The server part not including port
|
||||
uint16_t port() const; // Just the port number or 0 if none
|
||||
bool literal() const; // Whether the hostname() is IP literal
|
||||
|
||||
IRCD_USING_OVERLOAD(generate, m::generate);
|
||||
|
||||
|
|
19
ircd/m_id.cc
19
ircd/m_id.cc
|
@ -456,6 +456,25 @@ ircd::m::id::id(const enum sigil &sigil,
|
|||
{
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::id::literal()
|
||||
const
|
||||
{
|
||||
static const parser::rule<string_view> rule
|
||||
{
|
||||
rfc3986::parser::ip4_literal |
|
||||
rfc3986::parser::ip6_literal
|
||||
};
|
||||
|
||||
const auto &hostname
|
||||
{
|
||||
this->hostname()
|
||||
};
|
||||
|
||||
const char *start(hostname.begin()), *const stop(hostname.end());
|
||||
return qi::parse(start, stop, rule);
|
||||
}
|
||||
|
||||
uint16_t
|
||||
ircd::m::id::port()
|
||||
const
|
||||
|
|
Loading…
Reference in a new issue