unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
account-tag.c (2515B)
1 /* 2 * IRC - Internet Relay Chat, src/modules/account-tag.c 3 * (C) 2019 Syzop & 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 "account-tag", 28 "5.0", 29 "account-tag CAP", 30 "UnrealIRCd Team", 31 "unrealircd-6", 32 }; 33 34 /* Variables */ 35 long CAP_ACCOUNT_TAG = 0L; 36 37 int account_tag_mtag_is_ok(Client *client, const char *name, const char *value); 38 void mtag_add_account(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature); 39 40 MOD_INIT() 41 { 42 ClientCapabilityInfo cap; 43 ClientCapability *c; 44 MessageTagHandlerInfo mtag; 45 46 MARK_AS_OFFICIAL_MODULE(modinfo); 47 48 memset(&cap, 0, sizeof(cap)); 49 cap.name = "account-tag"; 50 c = ClientCapabilityAdd(modinfo->handle, &cap, &CAP_ACCOUNT_TAG); 51 52 memset(&mtag, 0, sizeof(mtag)); 53 mtag.name = "account"; 54 mtag.is_ok = account_tag_mtag_is_ok; 55 mtag.clicap_handler = c; 56 MessageTagHandlerAdd(modinfo->handle, &mtag); 57 58 HookAddVoid(modinfo->handle, HOOKTYPE_NEW_MESSAGE, 0, mtag_add_account); 59 60 return MOD_SUCCESS; 61 } 62 63 MOD_LOAD() 64 { 65 return MOD_SUCCESS; 66 } 67 68 MOD_UNLOAD() 69 { 70 return MOD_SUCCESS; 71 } 72 73 /** This function verifies if the client sending 74 * 'account-tag' is permitted to do so and uses a permitted 75 * syntax. 76 * We simply allow account-tag ONLY from servers and with any syntax. 77 */ 78 int account_tag_mtag_is_ok(Client *client, const char *name, const char *value) 79 { 80 if (IsServer(client)) 81 return 1; 82 83 return 0; 84 } 85 86 void mtag_add_account(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature) 87 { 88 MessageTag *m; 89 90 if (IsLoggedIn(client)) 91 { 92 m = safe_alloc(sizeof(MessageTag)); 93 safe_strdup(m->name, "account"); 94 safe_strdup(m->value, client->user->account); 95 96 AddListItem(m, *mtag_list); 97 } 98 }