unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
json-log-tag.c (2602B)
1 /* 2 * IRC - Internet Relay Chat, src/modules/monitor.c 3 * (C) 2021 Bram Matthys and The UnrealIRCd Team 4 * 5 * See file AUTHORS in IRC package for additional names of 6 * the programmers. 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 1, or (at your option) 11 * any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 */ 22 23 #include "unrealircd.h" 24 25 ModuleHeader MOD_HEADER 26 = { 27 "json-log-tag", 28 "5.0", 29 "unrealircd.org/json-log tag for S2S and ircops", 30 "UnrealIRCd Team", 31 "unrealircd-6", 32 }; 33 34 /* Variables */ 35 long CAP_JSON_LOG = 0L; 36 37 /* Forward declarations */ 38 int json_log_mtag_is_ok(Client *client, const char *name, const char *value); 39 int json_log_mtag_should_send_to_client(Client *target); 40 41 MOD_TEST() 42 { 43 ModuleSetOptions(modinfo->handle, MOD_OPT_PRIORITY, -1000000001); /* load very early */ 44 return MOD_SUCCESS; 45 } 46 47 MOD_INIT() 48 { 49 ClientCapabilityInfo cap; 50 ClientCapability *c; 51 MessageTagHandlerInfo mtag; 52 53 MARK_AS_OFFICIAL_MODULE(modinfo); 54 55 memset(&cap, 0, sizeof(cap)); 56 cap.name = "unrealircd.org/json-log"; 57 c = ClientCapabilityAdd(modinfo->handle, &cap, &CAP_JSON_LOG); 58 59 memset(&mtag, 0, sizeof(mtag)); 60 mtag.name = "unrealircd.org/json-log"; 61 mtag.is_ok = json_log_mtag_is_ok; 62 mtag.should_send_to_client = json_log_mtag_should_send_to_client; 63 mtag.clicap_handler = c; 64 MessageTagHandlerAdd(modinfo->handle, &mtag); 65 66 ModuleSetOptions(modinfo->handle, MOD_OPT_PRIORITY, 1000000001); /* unload very late */ 67 return MOD_SUCCESS; 68 } 69 70 MOD_LOAD() 71 { 72 return MOD_SUCCESS; 73 } 74 75 MOD_UNLOAD() 76 { 77 return MOD_SUCCESS; 78 } 79 80 /** This function verifies if the client sending 81 * We simply allow from servers without any syntax checking. 82 */ 83 int json_log_mtag_is_ok(Client *client, const char *name, const char *value) 84 { 85 if (IsServer(client) || IsMe(client)) 86 return 1; 87 88 return 0; 89 } 90 91 /** Outgoing filter for this message tag */ 92 int json_log_mtag_should_send_to_client(Client *target) 93 { 94 if (IsServer(target) || (target->local && IsOper(target) && HasCapabilityFast(target, CAP_JSON_LOG))) 95 return 1; 96 return 0; 97 }