From b56df6677e8589ac94f69d697de8d828ac5b841c Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 15 Apr 2019 13:16:00 -0700 Subject: [PATCH] ircd::server: Set SNI explicitly here rather than through fallback. ircd::server: Detect IP literal to set the peer::remote/open_opts directly. --- ircd/server.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ircd/server.cc b/ircd/server.cc index ff556ade3..56e0cb46d 100644 --- a/ircd/server.cc +++ b/ircd/server.cc @@ -567,10 +567,21 @@ ircd::server::peer::peer(const net::hostport &hostport, std::move(open_opts) } { - const net::hostport canon{this->hostcanon}; - this->open_opts.hostport.host = net::host(canon); - this->open_opts.hostport.port = net::port(canon); - this->open_opts.hostport.service = this->service; + const net::hostport &canon{this->hostcanon}; + + this->open_opts.hostport.host = this->hostcanon; // Resolve SRV on this name. + this->open_opts.hostport.port = net::port(hostport); + this->open_opts.hostport.service = this->service; // Resolve SRV on this protocol. + + this->open_opts.server_name = this->hostcanon; // Send SNI for this name. + this->open_opts.common_name = this->hostcanon; // Cert verify this name. + + if(rfc3986::valid(std::nothrow, rfc3986::parser::ip_address, host(this->open_opts.hostport))) + this->remote = + { + host(this->open_opts.hostport), port(this->open_opts.hostport) + }; + this->open_opts.ipport = this->remote; }