summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/database/database.hpp3
-rw-r--r--src/irc/irc_client.cpp16
-rw-r--r--src/xmpp/biboumi_adhoc_commands.cpp18
3 files changed, 29 insertions, 8 deletions
diff --git a/src/database/database.hpp b/src/database/database.hpp
index ce7595b..79b16d6 100644
--- a/src/database/database.hpp
+++ b/src/database/database.hpp
@@ -84,6 +84,7 @@ class Database
struct RemoteJid: Column<std::string> { static constexpr auto name = "remote"; };
+ struct Address: Column<std::string> { static constexpr auto name = "hostname_"; };
using MucLogLineTable = Table<Id, Uuid, Owner, IrcChanName, IrcServerName, Date, Body, Nick>;
using MucLogLine = MucLogLineTable::RowType;
@@ -91,7 +92,7 @@ class Database
using GlobalOptionsTable = Table<Id, Owner, MaxHistoryLength, RecordHistory, GlobalPersistent>;
using GlobalOptions = GlobalOptionsTable::RowType;
- using IrcServerOptionsTable = Table<Id, Owner, Server, Pass, AfterConnectionCommand, TlsPorts, Ports, Username, Realname, VerifyCert, TrustedFingerprint, EncodingOut, EncodingIn, MaxHistoryLength>;
+ using IrcServerOptionsTable = Table<Id, Owner, Server, Pass, AfterConnectionCommand, TlsPorts, Ports, Username, Realname, VerifyCert, TrustedFingerprint, EncodingOut, EncodingIn, MaxHistoryLength, Address>;
using IrcServerOptions = IrcServerOptionsTable::RowType;
using IrcChannelOptionsTable = Table<Id, Owner, Server, Channel, EncodingOut, EncodingIn, MaxHistoryLength, Persistent, RecordHistoryOptional>;
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index c5ef36c..764f37b 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -186,20 +186,22 @@ void IrcClient::start()
bool tls;
std::tie(port, tls) = this->ports_to_try.top();
this->ports_to_try.pop();
- this->bridge.send_xmpp_message(this->hostname, "", "Connecting to " +
- this->hostname + ":" + port + " (" +
- (tls ? "encrypted" : "not encrypted") + ")");
-
this->bind_addr = Config::get("outgoing_bind", "");
+ std::string address = this->hostname;
-#ifdef BOTAN_FOUND
-# ifdef USE_DATABASE
+#ifdef USE_DATABASE
auto options = Database::get_irc_server_options(this->bridge.get_bare_jid(),
this->get_hostname());
+# ifdef BOTAN_FOUND
this->credential_manager.set_trusted_fingerprint(options.col<Database::TrustedFingerprint>());
# endif
+ if (!options.col<Database::Address>().empty())
+ address = options.col<Database::Address>();
#endif
- this->connect(this->hostname, port, tls);
+ this->bridge.send_xmpp_message(this->hostname, "", "Connecting to " +
+ address + ":" + port + " (" +
+ (tls ? "encrypted" : "not encrypted") + ")");
+ this->connect(address, port, tls);
}
void IrcClient::on_connection_failed(const std::string& reason)
diff --git a/src/xmpp/biboumi_adhoc_commands.cpp b/src/xmpp/biboumi_adhoc_commands.cpp
index bcdac39..0a25bd4 100644
--- a/src/xmpp/biboumi_adhoc_commands.cpp
+++ b/src/xmpp/biboumi_adhoc_commands.cpp
@@ -228,6 +228,19 @@ void ConfigureIrcServerStep1(XmppComponent&, AdhocSession& session, XmlNode& com
instructions.set_inner("Edit the form, to configure the settings of the IRC server " + server_domain);
{
+ XmlSubNode hostname(x, "field");
+ hostname["var"] = "hostname";
+ hostname["type"] = "text-single";
+ hostname["label"] = "Address";
+ hostname["desc"] = "The hostname (or IP) to connect to.";
+ XmlSubNode value(hostname, "value");
+ if (options.col<Database::Address>().empty())
+ value.set_inner(server_domain);
+ else
+ value.set_inner(options.col<Database::Address>());
+ }
+
+ {
XmlSubNode ports(x, "field");
ports["var"] = "ports";
ports["type"] = "text-multi";
@@ -375,6 +388,11 @@ void ConfigureIrcServerStep2(XmppComponent&, AdhocSession& session, XmlNode& com
{
const XmlNode* value = field->get_child("value", "jabber:x:data");
const std::vector<const XmlNode*> values = field->get_children("value", "jabber:x:data");
+
+ if (field->get_tag("var") == "hostname")
+ {
+ options.col<Database::Address>() = value->get_inner();
+ }
if (field->get_tag("var") == "ports")
{
std::string ports;