mirror of
https://github.com/matrix-construct/construct
synced 2024-11-19 08:21:09 +01:00
ircd::net: Add validations on hostport constructions.
This commit is contained in:
parent
67a759ac21
commit
14a1be0aaf
1 changed files with 12 additions and 4 deletions
|
@ -78,7 +78,9 @@ ircd::net::hostport::hostport(const string_view &host,
|
||||||
:host{host}
|
:host{host}
|
||||||
,service{service}
|
,service{service}
|
||||||
,port{port}
|
,port{port}
|
||||||
{}
|
{
|
||||||
|
rfc3986::valid_host(host);
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates a host:port pair from a hostname and a port number. When
|
/// Creates a host:port pair from a hostname and a port number. When
|
||||||
/// passed to net::dns() no SRV resolution will be done because no
|
/// passed to net::dns() no SRV resolution will be done because no
|
||||||
|
@ -87,9 +89,10 @@ ircd::net::hostport::hostport(const string_view &host,
|
||||||
inline
|
inline
|
||||||
ircd::net::hostport::hostport(const string_view &host,
|
ircd::net::hostport::hostport(const string_view &host,
|
||||||
const uint16_t &port)
|
const uint16_t &port)
|
||||||
:host{host}
|
:hostport
|
||||||
,service{}
|
{
|
||||||
,port{port}
|
host, string_view{}, port
|
||||||
|
}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// Creates a host:service or host:port pair from the single string literally
|
/// Creates a host:service or host:port pair from the single string literally
|
||||||
|
@ -111,14 +114,19 @@ ircd::net::hostport::hostport(const string_view &amalgam)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(amalgam == host || empty(port))
|
if(amalgam == host || empty(port))
|
||||||
|
{
|
||||||
|
rfc3986::valid_host(host);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(try_lex_cast<uint16_t>(port))
|
if(try_lex_cast<uint16_t>(port))
|
||||||
{
|
{
|
||||||
this->service = {};
|
this->service = {};
|
||||||
this->port = lex_cast<uint16_t>(port);
|
this->port = lex_cast<uint16_t>(port);
|
||||||
|
rfc3986::valid_remote(amalgam);
|
||||||
} else {
|
} else {
|
||||||
this->service = port;
|
this->service = port;
|
||||||
|
rfc3986::valid_host(host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue