]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
Set "issuer" already in connection call. This to speed up connection
authorBram Matthys <redacted>
Thu, 27 Apr 2023 14:37:17 +0000 (16:37 +0200)
committerBram Matthys <redacted>
Thu, 27 Apr 2023 14:37:35 +0000 (16:37 +0200)
a bit as this causes unrealircd-rpc-php to skip a ping-pong and also
makes it not wait for the rpc.set_issuer call reply (since we don't
care that much).

inc/connection.php

index 0a06ab2a6d64225aecf699e9f6035db8c2197806..0272138d9801d88213c6b67b094a2629acfbe5c2 100644 (file)
@@ -10,6 +10,8 @@ function connect_to_ircd()
 
        $is_api_page = str_contains($_SERVER['SCRIPT_FILENAME'], "/api/") ? true : false;
 
+       $options = []; /* options that we pass to new UnrealIRCd\Connection */
+
        $rpc = null; /* Initialize, mostly for API page failures */
 
        $server = get_active_rpc_server();
@@ -26,7 +28,8 @@ function connect_to_ircd()
        $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 (isset($config["unrealircd"][$server]["tls_verify_cert"]))
+               $options["tls_verify"] = $config["unrealircd"][$server]["tls_verify_cert"];
 
        if (!$host || !$port || !$rpc_user)
        {
@@ -44,13 +47,20 @@ function connect_to_ircd()
                die;
        }
 
+       $user = unreal_get_current_user();
+       if ($user)
+       {
+               /* Set issuer for all the RPC commands */
+               $options['issuer'] = $user->username;
+       }
+
        /* Connect now */
        try {
                        $rpc = new UnrealIRCd\Connection
                        (
                                "wss://$host:$port",
                                "$rpc_user:$rpc_password",
-                               ["tls_verify" => $tls_verify]
+                               $options
                        );
        }
        catch (Exception $e)
@@ -62,13 +72,6 @@ function connect_to_ircd()
                              "and that UnrealIRCd is up and running");
                throw $e;
        }
-
-       $user = unreal_get_current_user();
-       if ($user)
-       {
-               /* Set issuer for all the RPC commands */
-               $rpc->rpc()->set_issuer($user->username);
-       }
 }
 
 connect_to_ircd();