mirror of
https://github.com/matrix-construct/construct
synced 2024-09-28 19:58:53 +02:00
ircd::net: Use specific canon service/port variables.
This commit is contained in:
parent
e395e4d85e
commit
5a058be4ba
2 changed files with 23 additions and 7 deletions
|
@ -15,16 +15,20 @@ namespace ircd::net
|
|||
{
|
||||
struct hostport;
|
||||
|
||||
// abstraction bleed
|
||||
extern const uint16_t canon_port;
|
||||
extern const string_view canon_service;
|
||||
|
||||
const uint16_t &port(const hostport &);
|
||||
const string_view &host(const hostport &);
|
||||
const string_view &service(const hostport &);
|
||||
|
||||
uint16_t &port(hostport &);
|
||||
string_view &host(hostport &);
|
||||
|
||||
string_view string(const mutable_buffer &out, const hostport &);
|
||||
string_view canonize(const mutable_buffer &out, const hostport &, const uint16_t &port = 8448);
|
||||
std::string canonize(const hostport &, const uint16_t &port = 8448);
|
||||
|
||||
string_view canonize(const mutable_buffer &out, const hostport &, const uint16_t &port = canon_port);
|
||||
std::string canonize(const hostport &, const uint16_t &port = canon_port);
|
||||
}
|
||||
|
||||
namespace ircd
|
||||
|
@ -49,12 +53,12 @@ namespace ircd
|
|||
struct ircd::net::hostport
|
||||
{
|
||||
string_view host {"0.0.0.0"};
|
||||
string_view service {"matrix"};
|
||||
uint16_t port {8448};
|
||||
string_view service {canon_service};
|
||||
uint16_t port {canon_port};
|
||||
|
||||
bool operator!() const;
|
||||
|
||||
hostport(const string_view &host, const string_view &service, const uint16_t &port = 8448);
|
||||
hostport(const string_view &host, const string_view &service, const uint16_t &port = canon_port);
|
||||
hostport(const string_view &host, const uint16_t &port);
|
||||
hostport(const string_view &amalgam);
|
||||
hostport() = default;
|
||||
|
|
14
ircd/net.cc
14
ircd/net.cc
|
@ -3644,6 +3644,18 @@ ircd::net::ipport::ipport(const boost::asio::ip::address &address,
|
|||
// net/hostport.h
|
||||
//
|
||||
|
||||
decltype(ircd::net::canon_port)
|
||||
ircd::net::canon_port
|
||||
{
|
||||
8448
|
||||
};
|
||||
|
||||
decltype(ircd::net::canon_service)
|
||||
ircd::net::canon_service
|
||||
{
|
||||
"matrix"
|
||||
};
|
||||
|
||||
std::ostream &
|
||||
ircd::net::operator<<(std::ostream &s, const hostport &t)
|
||||
{
|
||||
|
@ -3659,7 +3671,7 @@ ircd::net::canonize(const hostport &hp,
|
|||
{
|
||||
const size_t len
|
||||
{
|
||||
size(host(hp)) + 6 // optimistic ':' + portnum
|
||||
size(host(hp)) + 1 + 5 + 1 // optimistic ':' + portnum
|
||||
};
|
||||
|
||||
return ircd::string(len, [&hp, &port]
|
||||
|
|
Loading…
Reference in a new issue