From 213c46d9f82eb90761b2b008f9f93ff0e8ecf3d7 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 13 Mar 2019 17:32:39 -0700 Subject: [PATCH] ircd::net: Add interface to get cipher list from acceptor w/ console cmd. --- include/ircd/net/listener.h | 2 ++ ircd/net.cc | 7 +++++++ modules/console.cc | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/include/ircd/net/listener.h b/include/ircd/net/listener.h index bcc472764..181e7096a 100644 --- a/include/ircd/net/listener.h +++ b/include/ircd/net/listener.h @@ -20,6 +20,8 @@ namespace ircd::net std::ostream &operator<<(std::ostream &s, const acceptor &); extern conf::item listen; + + std::string cipher_list(const acceptor &); } struct ircd::net::listener diff --git a/ircd/net.cc b/ircd/net.cc index c21ea8476..4b7353fde 100644 --- a/ircd/net.cc +++ b/ircd/net.cc @@ -945,6 +945,13 @@ ircd::net::listen // listener // +std::string +ircd::net::cipher_list(const acceptor &a) +{ + auto &ssl(const_cast(a).ssl); + return openssl::cipher_list(*ssl.native_handle()); +} + std::ostream & ircd::net::operator<<(std::ostream &s, const listener &a) { diff --git a/modules/console.cc b/modules/console.cc index bb231ac5c..272c5f8ae 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -4430,6 +4430,41 @@ console_cmd__net__listen__list(opt &out, const string_view &line) return true; } +bool +console_cmd__net__listen__ciphers(opt &out, const string_view &line) +{ + const params param{line, " ", + { + "name", + }}; + + const auto &name + { + param["name"] + }; + + using list = std::list; + + static mods::import listeners + { + "s_listen", "listeners" + }; + + const list &l(listeners); + for(const auto &listener : l) + { + if(name && listener.name() != name) + continue; + + out << listener.name() << ": " << std::endl + << cipher_list(listener) + << std::endl + << std::endl; + } + + return true; +} + bool console_cmd__net__listen(opt &out, const string_view &line) {