1 /* 2 * ircd-ratbox: A slightly useful ircd. 3 * struct.h: Contains various structures used throughout ircd 4 * 5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center 6 * Copyright (C) 1996-2002 Hybrid Development Team 7 * Copyright (C) 2002-2012 ircd-ratbox development team 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 22 * USA 23 * 24 * $Id: struct.h 28697 2015-10-02 20:57:42Z androsyn $ 25 */ 26 #ifndef INCLUDED_struct_h 27 #define INCLUDED_struct_h 28 29 #include "ratbox_lib.h" 30 31 /*** client.h ***/ 32 33 struct User 34 { 35 rb_dlink_list channel; /* chain of channel pointer blocks */ 36 char *away; /* pointer to away message */ 37 char name[NICKLEN]; 38 #ifdef ENABLE_SERVICES 39 char suser[NICKLEN + 1]; 40 #endif 41 42 }; 43 44 struct Server 45 { 46 const char *name; 47 char by[NICKLEN]; 48 rb_dlink_list servers; 49 rb_dlink_list users; 50 int caps; /* capabilities bit-field */ 51 char *fullcaps; 52 }; 53 54 struct ZipStats 55 { 56 unsigned long long in; 57 unsigned long long in_wire; 58 unsigned long long out; 59 unsigned long long out_wire; 60 double in_ratio; 61 double out_ratio; 62 }; 63 64 struct Client 65 { 66 rb_dlink_node node; 67 rb_dlink_node lnode; 68 struct User *user; /* ...defined, if this is a User */ 69 struct Server *serv; /* ...defined, if this is a server */ 70 struct Client *servptr; /* Points to server this Client is on */ 71 struct Client *from; /* == self, if Local Client, *NEVER* NULL! */ 72 73 struct Whowas *whowas; /* Pointers to whowas structs */ 74 time_t tsinfo; /* TS on the nick, SVINFO on server */ 75 uint32_t umodes; /* opers, normal users subset */ 76 uint32_t flags; /* client flags */ 77 uint32_t operflags; /* ugh. overflow */ 78 79 uint8_t hopcount; /* number of servers to this 0 = local */ 80 uint8_t status; /* Client type */ 81 uint8_t handler; /* Handler index */ 82 83 /* client->name is the unique name for a client nick or host */ 84 const char *name; 85 86 /* 87 * client->username is the username from ident or the USER message, 88 * If the client is idented the USER message is ignored, otherwise 89 * the username part of the USER message is put here prefixed with a 90 * tilde depending on the I:line, Once a client has registered, this 91 * field should be considered read-only. 92 */ 93 char username[USERLEN + 1]; /* client's username */ 94 /* 95 * client->host contains the resolved name or ip address 96 * as a string for the user, it may be fiddled with for oper spoofing etc. 97 * once it's changed the *real* address goes away. This should be 98 * considered a read-only field after the client has registered. 99 */ 100 char host[HOSTLEN + 1]; /* client's hostname */ 101 char sockhost[HOSTIPLEN + 1]; /* clients ip */ 102 char info[REALLEN + 1]; /* Free form additional client info */ 103 104 char id[IDLEN + 1]; /* UID/SID, unique on the network */ 105 106 /* list of who has this client on their allow list, its counterpart 107 * is in LocalUser 108 */ 109 rb_dlink_list on_allow_list; 110 111 112 struct LocalUser *localClient; 113 }; 114 115 struct _ssl_ctl; 116 117 struct LocalUser 118 { 119 rb_dlink_node tnode; /* This is the node for the local list type the client is on */ 120 /* 121 * The following fields are allocated only for local clients 122 * (directly connected to *this* server with a socket. 123 */ 124 /* Anti flooding part, all because of lamers... */ 125 time_t last_join_time; /* when this client last 126 joined a channel */ 127 time_t last_leave_time; /* when this client last 128 * left a channel */ 129 int join_leave_count; /* count of JOIN/LEAVE in less than 130 MIN_JOIN_LEAVE_TIME seconds */ 131 uint8_t oper_warn_count_down; /* warn opers of this possible 132 spambot every time this gets to 0 */ 133 time_t last_caller_id_time; 134 time_t first_received_message_time; 135 int received_number_of_privmsgs; 136 int flood_noticed; 137 138 time_t lasttime; /* last time we parsed something */ 139 time_t firsttime; /* time client was created */ 140 141 uint32_t serial; /* used to enforce 1 send per nick */ 142 143 /* Send and receive linebuf queues .. */ 144 buf_head_t buf_sendq; 145 buf_head_t buf_recvq; 146 147 unsigned long long int sendB; /* Statistics: total bytes sent */ 148 unsigned long long int receiveB; /* Statistics: total bytes received */ 149 uint32_t sendM; /* Statistics: protocol messages send */ 150 uint32_t receiveM; /* Statistics: protocol messages received */ 151 struct Listener *listener; /* listener accepted from */ 152 struct ConfItem *att_conf; /* attached conf */ 153 struct server_conf *att_sconf; 154 155 struct rb_sockaddr_storage ip; 156 time_t last_nick_change; 157 uint16_t number_of_nick_changes; 158 159 /* 160 * XXX - there is no reason to save this, it should be checked when it's 161 * received and not stored, this is not used after registration 162 */ 163 char *passwd; 164 char *opername; 165 char *fullcaps; 166 167 int caps; /* capabilities bit-field */ 168 rb_fde_t *F; 169 170 time_t last; 171 172 /* challenge stuff */ 173 time_t chal_time; 174 uint8_t *chal_resp; 175 176 /* clients allowed to talk through +g */ 177 rb_dlink_list allow_list; 178 179 /* nicknames theyre monitoring */ 180 rb_dlink_list monitor_list; 181 182 rb_dlink_list invited; /* chain of invite pointer blocks */ 183 184 /* 185 * Anti-flood stuff. We track how many messages were parsed and how 186 * many we were allowed in the current second, and apply a simple decay 187 * to avoid flooding. 188 * -- adrian 189 */ 190 uint16_t allow_read; /* how many we're allowed to read in this second */ 191 int16_t actually_read; /* how many we've actually read in this second */ 192 int16_t sent_parsed; /* how many messages we've parsed in this second */ 193 time_t last_knock; /* time of last knock */ 194 uint32_t random_ping; 195 struct AuthRequest *auth_request; 196 197 /* target change stuff */ 198 void *targets[10]; /* targets were aware of */ 199 uint8_t targinfo[2]; /* cyclic array, no in use */ 200 time_t target_last; /* last time we cleared a slot */ 201 struct rb_sockaddr_storage *lip; /* alloc before auth/freed after auth */ 202 struct _ssl_ctl *ssl_ctl; /* which ssl daemon we're associate with */ 203 struct _ssl_ctl *z_ctl; /* second ctl for ssl+zlib */ 204 uint32_t localflags; 205 struct ZipStats *zipstats; /* zipstats */ 206 uint16_t cork_count; /* used for corking/uncorking connections */ 207 struct ev_entry *event; /* used for associated events */ 208 }; 209 210 211 #endif 212