diff options
author | Florent Le Coz <louiz@louiz.org> | 2015-09-21 04:27:23 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2015-09-21 04:27:23 +0200 |
commit | 890cfe90996ac4c3916c84d178049d9b3b23465b (patch) | |
tree | 2a5a4576f5c6f2ecf98e58875736c6d9be861861 /src/irc | |
parent | 532228a3cefd92fe43ad0f52149b7f0f5ab5cb79 (diff) | |
download | biboumi-890cfe90996ac4c3916c84d178049d9b3b23465b.tar.gz biboumi-890cfe90996ac4c3916c84d178049d9b3b23465b.tar.bz2 biboumi-890cfe90996ac4c3916c84d178049d9b3b23465b.tar.xz biboumi-890cfe90996ac4c3916c84d178049d9b3b23465b.zip |
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
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/irc_client.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
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 <chrono> #include <string> +#include "biboumi.h" #include "louloulibs.h" using namespace std::string_literals; using namespace std::chrono_literals; + IrcClient::IrcClient(std::shared_ptr<Poller> 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> 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<std::string> 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() |