unrealircd

- supernets unrealircd source & configuration
git clone git://git.acid.vegas/unrealircd.git
Log | Files | Refs | Archive | README | LICENSE

real-quit-reason.c (2055B)

      1 /*
      2  * unrealircd.org/real-quit-reason message tag (server only)
      3  * This is really server-only, it does not traverse to any clients.
      4  * (C) Copyright 2023-.. Syzop and The UnrealIRCd Team
      5  * License: GPLv2 or later
      6  */
      7 
      8 #include "unrealircd.h"
      9 
     10 ModuleHeader MOD_HEADER
     11   = {
     12 	"real-quit-reason",
     13 	"6.0",
     14 	"unrealircd.org/real-quit-reason message tag",
     15 	"UnrealIRCd Team",
     16 	"unrealircd-6",
     17 	};
     18 
     19 /* Forward declarations */
     20 int real_quit_reason_mtag_is_ok(Client *client, const char *name, const char *value);
     21 int real_quit_reason_mtag_should_send_to_client(Client *target);
     22 void mtag_inherit_real_quit_reason(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature);
     23 
     24 MOD_INIT()
     25 {
     26 	MessageTagHandlerInfo mtag;
     27 
     28 	MARK_AS_OFFICIAL_MODULE(modinfo);
     29 
     30 	memset(&mtag, 0, sizeof(mtag));
     31 	mtag.name = "unrealircd.org/real-quit-reason";
     32 	mtag.is_ok = real_quit_reason_mtag_is_ok;
     33 	mtag.should_send_to_client = real_quit_reason_mtag_should_send_to_client;
     34 	mtag.flags = MTAG_HANDLER_FLAGS_NO_CAP_NEEDED;
     35 	MessageTagHandlerAdd(modinfo->handle, &mtag);
     36 
     37 	HookAddVoid(modinfo->handle, HOOKTYPE_NEW_MESSAGE, 0, mtag_inherit_real_quit_reason);
     38 
     39 	return MOD_SUCCESS;
     40 }
     41 
     42 MOD_LOAD()
     43 {
     44 	return MOD_SUCCESS;
     45 }
     46 
     47 MOD_UNLOAD()
     48 {
     49 	return MOD_SUCCESS;
     50 }
     51 
     52 /** This function verifies if the client sending 'unrealircd.org/real-quit-reason'
     53  * is permitted to do so and uses a permitted syntax.
     54  * We simply allow unrealircd.org/real-quit-reason ONLY from servers and with any syntax.
     55  */
     56 int real_quit_reason_mtag_is_ok(Client *client, const char *name, const char *value)
     57 {
     58 	if (IsServer(client))
     59 		return 1;
     60 
     61 	return 0;
     62 }
     63 
     64 void mtag_inherit_real_quit_reason(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature)
     65 {
     66 	MessageTag *m = find_mtag(recv_mtags, "unrealircd.org/real-quit-reason");
     67 	if (m)
     68 	{
     69 		m = duplicate_mtag(m);
     70 		AddListItem(m, *mtag_list);
     71 	}
     72 }
     73 
     74 /** Outgoing filter for this message tag */
     75 int real_quit_reason_mtag_should_send_to_client(Client *target)
     76 {
     77 	if (IsServer(target))
     78 		return 1;
     79 
     80 	return 0;
     81 }