From: Valerie Pond Date: Wed, 5 Apr 2023 04:22:31 +0000 (+0100) Subject: Add the start of "Network Health" tool X-Git-Tag: 0.9~248 X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/commitdiff_plain/e6274ac9bcb1feb95cb8ddab30143e63512321d0 Add the start of "Network Health" tool This tab will let you see if there are any mode mismatches or module version mismatches, and any other stuff we can think might be useful to add in. Since we already have a hardcoded End Of Life, it sounds reasonable to add UnrealIRCd5 being EOL as a "problem" listed on this page after July, for example. --- diff --git a/Classes/class-checkup.php b/Classes/class-checkup.php new file mode 100644 index 0000000..37905ae --- /dev/null +++ b/Classes/class-checkup.php @@ -0,0 +1,132 @@ + 0, + "usermodes" => 0, + "modules" => 0, + "other" => 0, + ]; + public $problems = [ + "chanmodes" => [], + "usermodes" => [], + "modules" => [], + "other" => [], + ]; + + public $serverlist = []; + + /** + * Construct0r + */ + function __construct() + { + global $rpc; + + $this->serverlist = $rpc->server()->getAll(); + $this->chanmode_check(); + $this->usermode_check(); + //$this->module_check(); + + } + + /** + * Checks channel modes of servers against other servers + * @return void + */ + function chanmode_check() : void + { + foreach($this->serverlist as $s) // cycle through each server + { + /* make a single string from the array of groups */ + $ourchmodes = ""; + foreach ($s->server->features->chanmodes as $set) + for ($i=0; isset($set[$i]); $i++) + strcat($ourchmodes,$set[$i]); + + /* take a look at every other server... yep, we do this for every server */ + foreach ($this->serverlist as $serv) + { + /* except for ourselves lol */ + if ($serv->id == $s->id) + continue; + + /* hmm if it's not unreal, skip it too */ + if (!strstr($serv->server->features->software,"UnrealIRCd")) + continue; + + /* make a single string from the array of groups but for them this time */ + $theirchmodes = ""; + foreach ($serv->server->features->chanmodes as $set) + for ($i=0; isset($set[$i]); $i++) + strcat($theirchmodes,$set[$i]); + + /* check ours against theirs */ + for ($i=0; isset($ourchmodes[$i]) && $m = $ourchmodes[$i]; $i++) + { + /* if we have a mode that they don't have */ + if (!strstr($theirchmodes, $m)) + { + ++$this->num_of_problems['chanmodes']; + $this->problems['chanmodes'][] = "Channel mode $m is present on $s->name but missing on $serv->name"; + } + } + } + } + } + + /** + * Checks user modes of servers against other servers + * @return void + */ + function usermode_check() : void + { + /* make a single string from the array of groups */ + $ourumodes = $s->server->features->usermodes; + + /* take a look at every other server... yep, we do this for every server */ + foreach ($this->serverlist as $serv) + { + /* except for ourselves lol */ + if ($serv->id == $s->id) + continue; + + /* hmm if it's not unreal, skip it too */ + if (!strstr($serv->server->features->software,"UnrealIRCd")) + continue; + + $theirumodes = $serv->server->features->usermodes; + + /* check ours against theirs */ + for ($i=0; isset($ourumodes[$i]) && $m = $ourumodes[$i]; $i++) + { + /* if we have a mode that they don't have */ + if (!strstr($theirumodes, $m)) + { + ++$this->num_of_problems['usermodes']; + $this->problems['usermodes'][] = "User mode $m is present on $s->name but missing on $serv->name"; + } + } + } + } + + /** + * Checks modules of servers against other servers + * @return void + */ + function module_check() : void + { + global $rpc; + $modlist = []; + $modarray = []; + foreach ($this->serverlist as $serv) + $modlist[$serv->name] = json_decode(json_encode($rpc->server()->module_list($serv->id)->list), true); + + echo highlight_string(var_export($modlist,true)); + } +} \ No newline at end of file diff --git a/tools/checkup.php b/tools/checkup.php new file mode 100644 index 0000000..d841daa --- /dev/null +++ b/tools/checkup.php @@ -0,0 +1,108 @@ + +

Network Health Checkup

+ +
+ +
+
+
+
text-white"> +
+
+ +
+
+

num_of_problems['chanmodes']; ?>

problems
+
+
+
+
+
+
+
Channel Modes
+
+ +
+
+
+ + +
+
+
+
text-white"> +
+
+ +
+
+

num_of_problems['usermodes']; ?>

problems
+
+
+
+
+
+
+
User Modes
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+

+
+
+
+
+
+
+
Modules
+
+ +
+
+
+
+ +
+
+
+
+
+ +
+
+

+
+
+
+
+
+
+
Servers
+
+ +
+
+
+
+
\ No newline at end of file