X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/c06c1713af2db485d55a91073bbc5b63b6aa8c0b..41aad10cbe0755aee50f597cb2cadd3029de7e1d:/inc/connection.php
diff --git a/inc/connection.php b/inc/connection.php
index 44ec034..fd264b7 100644
--- a/inc/connection.php
+++ b/inc/connection.php
@@ -3,24 +3,42 @@
if (!defined('UPATH'))
die("Access denied");
+function get_active_rpc_server()
+{
+ // TODO: make user able to override this - either in user or in session
+
+ foreach (get_config("unrealircd") as $displayname=>$e)
+ {
+ if (isset($e["default"]) && $e["default"])
+ return $displayname;
+ }
+ return null;
+}
+
function connect_to_ircd()
{
GLOBAL $rpc;
+ GLOBAL $config;
- $host = get_config("unrealircd::host");
- $port = get_config("unrealircd::port");
- $rpc_user = get_config("unrealircd::rpc_user");
- $rpc_password = get_config("unrealircd::rpc_password");
+ $server = get_active_rpc_server();
+ if (!$server)
+ die("No RPC server configured as primary");
+ $host = $config["unrealircd"][$server]["host"];
+ $port = $config["unrealircd"][$server]["port"];
+ $rpc_user = $config["unrealircd"][$server]["rpc_user"];
+ $rpc_password = $config["unrealircd"][$server]["rpc_password"];
if (str_starts_with($rpc_password, "secret:"))
$rpc_password = secret_decrypt($rpc_password);
+ $tls_verify = $config["unrealircd"][$server]["tls_verify_cert"];
if (!$host || !$port || !$rpc_user)
- die("Unable to find RPC credentials in your config.php");
+ die("RPC Server is missing credentials");
+
if ($rpc_password === null)
+ {
die("Your RPC password in the DB was encrypted with a different key than config/config.php contains.
\n".
"Either restore your previous config/config.php or start with a fresh database.
\n");
-
- $tls_verify = get_config("unrealircd::tls_verify_cert");
+ }
/* Connect now */
try {