From 890cfe90996ac4c3916c84d178049d9b3b23465b Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Mon, 21 Sep 2015 04:27:23 +0200 Subject: Provide Ports and TLS Ports IRC-server ad-hoc options This let any user choose which ports to use when connecting to the IRC server. This also lets the user choose whether or not to force TLS usage (by setting no non-TLS port). fix #2731 --- src/irc/irc_client.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/irc') diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index bac3e34..c6174bf 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -16,11 +16,13 @@ #include #include +#include "biboumi.h" #include "louloulibs.h" using namespace std::string_literals; using namespace std::chrono_literals; + IrcClient::IrcClient(std::shared_ptr poller, const std::string& hostname, const std::string& username, Bridge* bridge): TCPSocketHandler(poller), hostname(hostname), @@ -39,13 +41,25 @@ IrcClient::IrcClient(std::shared_ptr poller, const std::string& hostname "alive without having to join a real channel of that server. " "To disconnect from the IRC server, leave this room and all " "other IRC channels of that server."; - // TODO: get the values from the preferences of the user, and only use the - // list of default ports if the user didn't specify anything +#ifdef USE_DATABASE + auto options = Database::get_irc_server_options(this->bridge->get_bare_jid(), + this->get_hostname()); + std::vector ports = utils::split(options.ports, ';', false); + for (auto it = ports.rbegin(); it != ports.rend(); ++it) + this->ports_to_try.emplace(*it, false); +# ifdef BOTAN_FOUND + ports = utils::split(options.tlsPorts, ';', false); + for (auto it = ports.rbegin(); it != ports.rend(); ++it) + this->ports_to_try.emplace(*it, true); +# endif // BOTAN_FOUND + +#else // not USE_DATABASE this->ports_to_try.emplace("6667", false); // standard non-encrypted port -#ifdef BOTAN_FOUND +# ifdef BOTAN_FOUND this->ports_to_try.emplace("6670", true); // non-standard but I want it for some servers this->ports_to_try.emplace("6697", true); // standard encrypted port -#endif // BOTAN_FOUND +# endif // BOTAN_FOUND +#endif // USE_DATABASE } IrcClient::~IrcClient() -- cgit v1.2.3