| 25 |
|
#ifndef INCLUDED_client_h |
| 26 |
|
#define INCLUDED_client_h |
| 27 |
|
|
| 28 |
+ |
#include "list.h" |
| 29 |
|
#include "fdlist.h" |
| 30 |
< |
#include "setup.h" |
| 30 |
> |
#include "config.h" |
| 31 |
|
#include "ircd_defs.h" |
| 32 |
|
#include "ircd_handler.h" |
| 33 |
|
#include "dbuf.h" |
| 45 |
|
*/ |
| 46 |
|
struct AccessItem; |
| 47 |
|
struct Whowas; |
| 47 |
– |
struct DNSReply; |
| 48 |
|
struct Listener; |
| 49 |
|
struct Client; |
| 50 |
|
struct LocalUser; |
| 51 |
|
|
| 52 |
– |
/* |
| 53 |
– |
* Client structures |
| 54 |
– |
*/ |
| 52 |
|
|
| 53 |
|
struct Server |
| 54 |
|
{ |
| 58 |
– |
char by[NICKLEN]; /* who activated this connection */ |
| 55 |
|
struct ConfItem *sconf; /* ConfItem connect{} pointer for this server */ |
| 56 |
< |
dlink_list servers; /* Servers on this server */ |
| 57 |
< |
dlink_list users; /* Users on this server */ |
| 58 |
< |
int dep_servers; /* Total number of dependent servers on all levels */ |
| 63 |
< |
int dep_users; /* Total number of dependent users on all levels */ |
| 56 |
> |
dlink_list server_list; /* Servers on this server */ |
| 57 |
> |
dlink_list client_list; /* Clients on this server */ |
| 58 |
> |
char by[NICKLEN]; /* who activated this connection */ |
| 59 |
|
}; |
| 60 |
|
|
| 61 |
|
struct SlinkRpl |
| 69 |
|
|
| 70 |
|
struct ZipStats |
| 71 |
|
{ |
| 72 |
< |
unsigned long in; |
| 73 |
< |
unsigned long in_wire; |
| 74 |
< |
unsigned long out; |
| 75 |
< |
unsigned long out_wire; |
| 72 |
> |
uint64_t in; |
| 73 |
> |
uint64_t in_wire; |
| 74 |
> |
uint64_t out; |
| 75 |
> |
uint64_t out_wire; |
| 76 |
|
double in_ratio; |
| 77 |
|
double out_ratio; |
| 78 |
|
}; |
| 79 |
|
|
| 80 |
|
struct ListTask |
| 81 |
|
{ |
| 82 |
< |
int hash_index; /* the bucket we are currently in */ |
| 82 |
> |
unsigned int hash_index; /* the bucket we are currently in */ |
| 83 |
|
dlink_list show_mask; /* show these channels.. */ |
| 84 |
|
dlink_list hide_mask; /* ..and hide these ones */ |
| 85 |
|
unsigned int users_min, users_max; |
| 92 |
|
dlink_node node; |
| 93 |
|
dlink_node lnode; /* Used for Server->servers/users */ |
| 94 |
|
|
| 95 |
< |
struct Client *hnext; /* For client hash table lookups by name */ |
| 96 |
< |
struct Client *idhnext; /* For SID hash table lookups by sid */ |
| 97 |
< |
|
| 98 |
< |
struct Server* serv; /* ...defined, if this is a server */ |
| 99 |
< |
struct Client* servptr; /* Points to server this Client is on */ |
| 100 |
< |
struct Client* from; /* == self, if Local Client, *NEVER* NULL! */ |
| 95 |
> |
struct LocalUser *localClient; |
| 96 |
> |
struct Client *hnext; /* For client hash table lookups by name */ |
| 97 |
> |
struct Client *idhnext; /* For SID hash table lookups by sid */ |
| 98 |
> |
struct Server *serv; /* ...defined, if this is a server */ |
| 99 |
> |
struct Client *servptr; /* Points to server this Client is on */ |
| 100 |
> |
struct Client *from; /* == self, if Local Client, *NEVER* NULL! */ |
| 101 |
> |
struct Whowas *whowas; /* Pointers to whowas structs */ |
| 102 |
> |
char *away; |
| 103 |
|
|
| 107 |
– |
struct Whowas* whowas; /* Pointers to whowas structs */ |
| 104 |
|
time_t lasttime; /* ...should be only LOCAL clients? --msa */ |
| 105 |
|
time_t firsttime; /* time client was created */ |
| 106 |
|
time_t since; /* last time we parsed something */ |
| 107 |
|
time_t tsinfo; /* TS on the nick, SVINFO on server */ |
| 108 |
< |
unsigned long connect_id; /* unique connection ID */ |
| 108 |
> |
uint64_t flags; /* client flags */ |
| 109 |
> |
|
| 110 |
|
unsigned int umodes; /* opers, normal users subset */ |
| 111 |
< |
unsigned int flags; /* client flags */ |
| 111 |
> |
unsigned int hopcount; /* number of servers to this 0 = local */ |
| 112 |
> |
unsigned int status; /* Client type */ |
| 113 |
> |
unsigned int handler; /* Handler index */ |
| 114 |
> |
unsigned int serial; /* used to enforce 1 send per nick */ |
| 115 |
> |
|
| 116 |
> |
dlink_list channel; /* chain of channel pointer blocks */ |
| 117 |
|
|
| 116 |
– |
unsigned short hopcount; /* number of servers to this 0 = local */ |
| 117 |
– |
unsigned short status; /* Client type */ |
| 118 |
– |
unsigned char handler; /* Handler index */ |
| 119 |
– |
unsigned long serial; /* used to enforce 1 send per nick */ |
| 120 |
– |
unsigned long lazyLinkClientExists; /* This client exists on the |
| 121 |
– |
* bit mapped lazylink servers |
| 122 |
– |
* mapped here |
| 123 |
– |
*/ |
| 124 |
– |
char *away; |
| 118 |
|
/* |
| 119 |
|
* client->name is the unique name for a client nick or host |
| 120 |
|
*/ |
| 121 |
|
char name[HOSTLEN + 1]; |
| 122 |
|
char id[IDLEN + 1]; /* client ID, unique ID per client */ |
| 123 |
|
|
| 131 |
– |
/* |
| 132 |
– |
* client->llname is used to store the clients requested nick |
| 133 |
– |
* temporarily for new connections. |
| 134 |
– |
*/ |
| 135 |
– |
char llname[NICKLEN]; |
| 136 |
– |
|
| 124 |
|
/* |
| 125 |
|
* client->username is the username from ident or the USER message, |
| 126 |
|
* If the client is idented the USER message is ignored, otherwise |
| 152 |
|
*/ |
| 153 |
|
char sockhost[HOSTIPLEN + 1]; /* This is the host name from the |
| 154 |
|
socket ip address as string */ |
| 168 |
– |
/* caller ID allow list */ |
| 169 |
– |
/* This has to be here, since a client on an on_allow_list could |
| 170 |
– |
* be a remote client. simpler to keep both here. |
| 171 |
– |
*/ |
| 172 |
– |
dlink_list allow_list; /* clients I'll allow to talk to me */ |
| 173 |
– |
dlink_list on_allow_list; /* clients that have =me= on their allow list*/ |
| 174 |
– |
|
| 175 |
– |
dlink_list channel; /* chain of channel pointer blocks */ |
| 176 |
– |
|
| 177 |
– |
struct LocalUser *localClient; |
| 155 |
|
}; |
| 156 |
|
|
| 157 |
|
struct LocalUser |
| 160 |
|
* The following fields are allocated only for local clients |
| 161 |
|
* (directly connected to *this* server with a socket. |
| 162 |
|
*/ |
| 163 |
+ |
dlink_node lclient_node; |
| 164 |
+ |
|
| 165 |
+ |
|
| 166 |
+ |
|
| 167 |
|
unsigned int registration; |
| 168 |
|
unsigned int cap_client; /* Client capabilities (from us) */ |
| 169 |
|
unsigned int cap_active; /* Active capabilities (to us) */ |
| 170 |
|
|
| 171 |
+ |
unsigned int operflags; /* oper priv flags */ |
| 172 |
+ |
unsigned int random_ping; |
| 173 |
+ |
|
| 174 |
+ |
|
| 175 |
|
/* Anti flooding part, all because of lamers... */ |
| 176 |
< |
time_t last_away; /* Away since... */ |
| 177 |
< |
time_t last_join_time; /* when this client last |
| 178 |
< |
joined a channel */ |
| 179 |
< |
time_t last_leave_time; /* when this client last |
| 176 |
> |
time_t last_knock; /* time of last knock */ |
| 177 |
> |
time_t last_away; /* Away since... */ |
| 178 |
> |
time_t last_join_time; /* when this client last |
| 179 |
> |
joined a channel */ |
| 180 |
> |
time_t last_leave_time; /* when this client last |
| 181 |
|
* left a channel */ |
| 182 |
< |
int join_leave_count; /* count of JOIN/LEAVE in less than |
| 182 |
> |
int join_leave_count; /* count of JOIN/LEAVE in less than |
| 183 |
|
MIN_JOIN_LEAVE_TIME seconds */ |
| 184 |
< |
int oper_warn_count_down; /* warn opers of this possible |
| 184 |
> |
int oper_warn_count_down; /* warn opers of this possible |
| 185 |
|
spambot every time this gets to 0 */ |
| 186 |
< |
time_t reject_delay; |
| 187 |
< |
time_t last_caller_id_time; |
| 188 |
< |
time_t first_received_message_time; |
| 189 |
< |
int received_number_of_privmsgs; |
| 204 |
< |
int flood_noticed; |
| 205 |
< |
|
| 206 |
< |
dlink_node lclient_node; |
| 186 |
> |
time_t reject_delay; |
| 187 |
> |
time_t last_caller_id_time; |
| 188 |
> |
time_t first_received_message_time; |
| 189 |
> |
time_t last_nick_change; |
| 190 |
|
|
| 191 |
< |
unsigned int operflags; /* oper priv flags */ |
| 191 |
> |
int received_number_of_privmsgs; |
| 192 |
> |
unsigned int number_of_nick_changes; |
| 193 |
|
|
| 194 |
< |
struct ListTask *list_task; |
| 194 |
> |
struct ListTask *list_task; |
| 195 |
|
/* Send and receive dbufs .. */ |
| 196 |
|
struct dbuf_queue buf_sendq; |
| 197 |
|
struct dbuf_queue buf_recvq; |
| 201 |
|
uint64_t bytes; /* Statistics: total bytes sent/received */ |
| 202 |
|
} recv, send; |
| 203 |
|
|
| 204 |
+ |
struct AuthRequest *auth; |
| 205 |
|
struct Listener *listener; /* listener accepted from */ |
| 206 |
+ |
dlink_list acceptlist; /* clients I'll allow to talk to me */ |
| 207 |
+ |
dlink_list watches; /* chain of Watch pointer blocks */ |
| 208 |
|
dlink_list confs; /* Configuration record associated */ |
| 209 |
|
dlink_list invited; /* chain of invite pointer blocks */ |
| 210 |
|
struct irc_ssaddr ip; |
| 211 |
|
int aftype; /* Makes life easier for DNS res in IPV6 */ |
| 225 |
– |
struct DNSQuery *dns_query; /* result returned from resolver query */ |
| 226 |
– |
unsigned long serverMask; /* Only used for Lazy Links */ |
| 212 |
|
time_t last; /* Last time we got a PRIVMSG */ |
| 228 |
– |
time_t last_nick_change; |
| 229 |
– |
int number_of_nick_changes; |
| 213 |
|
|
| 214 |
|
char *passwd; |
| 215 |
< |
int caps; /* capabilities bit-field */ |
| 216 |
< |
int enc_caps; /* cipher capabilities bit-field */ |
| 215 |
> |
unsigned int caps; /* capabilities bit-field */ |
| 216 |
> |
unsigned int enc_caps; /* cipher capabilities bit-field */ |
| 217 |
|
|
| 218 |
|
#ifdef HAVE_LIBCRYPTO |
| 219 |
|
struct EncCapability *in_cipher; |
| 241 |
|
*/ |
| 242 |
|
int allow_read; /* how many we're allowed to read in this second */ |
| 243 |
|
int sent_parsed; /* how many messages we've parsed in this second */ |
| 261 |
– |
time_t last_knock; /* time of last knock */ |
| 262 |
– |
unsigned long random_ping; |
| 244 |
|
|
| 245 |
|
char* response; /* expected response from client */ |
| 246 |
|
char* auth_oper; /* Operator to become if they supply the response.*/ |
| 315 |
|
#define CAP_MULTI_PREFIX 0x00000001 |
| 316 |
|
|
| 317 |
|
/* housekeeping flags */ |
| 318 |
< |
#define FLAGS_PINGSENT 0x00000001 /* Unreplied ping sent */ |
| 319 |
< |
#define FLAGS_DEADSOCKET 0x00000002 /* Local socket is dead--Exiting soon */ |
| 320 |
< |
#define FLAGS_KILLED 0x00000004 /* Prevents "QUIT" from being sent for this */ |
| 321 |
< |
#define FLAGS_CLOSING 0x00000008 /* set when closing to suppress errors */ |
| 322 |
< |
#define FLAGS_GOTID 0x00000010 /* successful ident lookup achieved */ |
| 323 |
< |
#define FLAGS_NEEDID 0x00000020 /* I-lines say must use ident return */ |
| 324 |
< |
#define FLAGS_SENDQEX 0x00000040 /* Sendq exceeded */ |
| 325 |
< |
#define FLAGS_IPHASH 0x00000080 /* iphashed this client */ |
| 326 |
< |
#define FLAGS_CRYPTIN 0x00000100 /* incoming data must be decrypted */ |
| 327 |
< |
#define FLAGS_CRYPTOUT 0x00000200 /* outgoing data must be encrypted */ |
| 328 |
< |
#define FLAGS_WAITAUTH 0x00000400 /* waiting for CRYPTLINK AUTH command */ |
| 329 |
< |
#define FLAGS_SERVLINK 0x00000800 /* servlink has servlink process */ |
| 330 |
< |
#define FLAGS_MARK 0x00001000 /* marked client */ |
| 331 |
< |
#define FLAGS_CANFLOOD 0x00002000 /* client has the ability to flood */ |
| 332 |
< |
#define FLAGS_EXEMPTGLINE 0x00004000 /* client can't be G-lined */ |
| 333 |
< |
#define FLAGS_EXEMPTKLINE 0x00008000 /* client is exempt from kline */ |
| 334 |
< |
#define FLAGS_NOLIMIT 0x00010000 /* client is exempt from limits */ |
| 335 |
< |
#define FLAGS_RESTRICTED 0x00020000 /* client cannot op others */ |
| 336 |
< |
#define FLAGS_PING_COOKIE 0x00040000 /* PING Cookie */ |
| 337 |
< |
#define FLAGS_IDLE_LINED 0x00080000 /* client is exempt from idle-time limits */ |
| 338 |
< |
#define FLAGS_IP_SPOOFING 0x00100000 /* client IP is spoofed */ |
| 339 |
< |
#define FLAGS_FLOODDONE 0x00200000 /* Flood grace period has been ended. */ |
| 340 |
< |
#define FLAGS_EOB 0x00400000 /* server has received EOB */ |
| 341 |
< |
#define FLAGS_HIDDEN 0x00800000 /* a hidden server. not shown in /links */ |
| 342 |
< |
#define FLAGS_BLOCKED 0x01000000 /* must wait for COMM_SELECT_WRITE */ |
| 343 |
< |
#define FLAGS_SBLOCKED 0x02000000 /* slinkq is blocked */ |
| 344 |
< |
#define FLAGS_USERHOST 0x04000000 /* client is in userhost hash */ |
| 345 |
< |
#define FLAGS_BURSTED 0x08000000 /* user was already bursted */ |
| 346 |
< |
#define FLAGS_EXEMPTRESV 0x10000000 /* client is exempt from RESV */ |
| 347 |
< |
#define FLAGS_GOTUSER 0x20000000 /* if we received a USER command */ |
| 348 |
< |
#define FLAGS_PINGWARNING 0x40000000 /* unreplied ping warning already sent */ |
| 349 |
< |
#define FLAGS_FINISHED_AUTH 0x80000000 /* Client has been released from auth */ |
| 318 |
> |
#define FLAGS_PINGSENT 0x0000000000000001 /* Unreplied ping sent */ |
| 319 |
> |
#define FLAGS_DEADSOCKET 0x0000000000000002 /* Local socket is dead--Exiting soon */ |
| 320 |
> |
#define FLAGS_KILLED 0x0000000000000004 /* Prevents "QUIT" from being sent for this */ |
| 321 |
> |
#define FLAGS_CLOSING 0x0000000000000008 /* set when closing to suppress errors */ |
| 322 |
> |
#define FLAGS_GOTID 0x0000000000000010 /* successful ident lookup achieved */ |
| 323 |
> |
#define FLAGS_NEEDID 0x0000000000000020 /* I-lines say must use ident return */ |
| 324 |
> |
#define FLAGS_SENDQEX 0x0000000000000040 /* Sendq exceeded */ |
| 325 |
> |
#define FLAGS_IPHASH 0x0000000000000080 /* iphashed this client */ |
| 326 |
> |
#define FLAGS_CRYPTIN 0x0000000000000100 /* incoming data must be decrypted */ |
| 327 |
> |
#define FLAGS_CRYPTOUT 0x0000000000000200 /* outgoing data must be encrypted */ |
| 328 |
> |
#define FLAGS_WAITAUTH 0x0000000000000400 /* waiting for CRYPTLINK AUTH command */ |
| 329 |
> |
#define FLAGS_SERVLINK 0x0000000000000800 /* servlink has servlink process */ |
| 330 |
> |
#define FLAGS_MARK 0x0000000000001000 /* marked client */ |
| 331 |
> |
#define FLAGS_CANFLOOD 0x0000000000002000 /* client has the ability to flood */ |
| 332 |
> |
#define FLAGS_EXEMPTGLINE 0x0000000000004000 /* client can't be G-lined */ |
| 333 |
> |
#define FLAGS_EXEMPTKLINE 0x0000000000008000 /* client is exempt from kline */ |
| 334 |
> |
#define FLAGS_NOLIMIT 0x0000000000010000 /* client is exempt from limits */ |
| 335 |
> |
#define FLAGS_RESTRICTED 0x0000000000020000 /* client cannot op others */ |
| 336 |
> |
#define FLAGS_PING_COOKIE 0x0000000000040000 /* PING Cookie */ |
| 337 |
> |
#define FLAGS_IDLE_LINED 0x0000000000080000 /* client is exempt from idle-time limits */ |
| 338 |
> |
#define FLAGS_IP_SPOOFING 0x0000000000100000 /* client IP is spoofed */ |
| 339 |
> |
#define FLAGS_FLOODDONE 0x0000000000200000 /* Flood grace period has been ended. */ |
| 340 |
> |
#define FLAGS_EOB 0x0000000000400000 /* server has received EOB */ |
| 341 |
> |
#define FLAGS_HIDDEN 0x0000000000800000 /* a hidden server. not shown in /links */ |
| 342 |
> |
#define FLAGS_BLOCKED 0x0000000001000000 /* must wait for COMM_SELECT_WRITE */ |
| 343 |
> |
#define FLAGS_SBLOCKED 0x0000000002000000 /* slinkq is blocked */ |
| 344 |
> |
#define FLAGS_USERHOST 0x0000000004000000 /* client is in userhost hash */ |
| 345 |
> |
#define FLAGS_BURSTED 0x0000000008000000 /* user was already bursted */ |
| 346 |
> |
#define FLAGS_EXEMPTRESV 0x0000000010000000 /* client is exempt from RESV */ |
| 347 |
> |
#define FLAGS_GOTUSER 0x0000000020000000 /* if we received a USER command */ |
| 348 |
> |
#define FLAGS_PINGWARNING 0x0000000040000000 /* unreplied ping warning already sent */ |
| 349 |
> |
#define FLAGS_FINISHED_AUTH 0x0000000080000000 /* Client has been released from auth */ |
| 350 |
> |
#define FLAGS_FLOOD_NOTICED 0x0000000100000000 |
| 351 |
|
|
| 352 |
|
|
| 353 |
|
/* umodes, settable flags */ |
| 402 |
|
|
| 403 |
|
|
| 404 |
|
/* flags macros. */ |
| 405 |
+ |
#define IsMsgFloodNoticed(x) ((x)->flags & FLAGS_FLOOD_NOTICED) |
| 406 |
+ |
#define SetMsgFloodNoticed(x) ((x)->flags |= FLAGS_FLOOD_NOTICED) |
| 407 |
+ |
#define ClearMsgFloodNoticed(x) ((x)->flags &= ~FLAGS_FLOOD_NOTICED) |
| 408 |
|
#define IsAuthFinished(x) ((x)->flags & FLAGS_FINISHED_AUTH) |
| 409 |
|
#define IsDead(x) ((x)->flags & FLAGS_DEADSOCKET) |
| 410 |
|
#define SetDead(x) ((x)->flags |= FLAGS_DEADSOCKET) |
| 450 |
|
(UMODE_CALLERID|UMODE_SOFTCALLERID)) |
| 451 |
|
#define IsSoftCallerId(x) ((x)->umodes & UMODE_SOFTCALLERID) |
| 452 |
|
#define IsDeaf(x) ((x)->umodes & UMODE_DEAF) |
| 453 |
+ |
#define IsFull(x) ((x)->umodes & UMODE_CCONN_FULL) |
| 454 |
|
|
| 455 |
|
#define SetSendQExceeded(x) ((x)->flags |= FLAGS_SENDQEX) |
| 456 |
|
#define IsSendQExceeded(x) ((x)->flags & FLAGS_SENDQEX) |
| 545 |
|
extern dlink_list global_client_list; |
| 546 |
|
|
| 547 |
|
extern int accept_message(struct Client *, struct Client *); |
| 548 |
< |
extern void set_initial_nick(struct Client *, struct Client *, const char *); |
| 548 |
> |
extern struct split_nuh_item *find_accept(const char *, const char *, |
| 549 |
> |
const char *, struct Client *, int); |
| 550 |
> |
extern void del_accept(struct split_nuh_item *, struct Client *); |
| 551 |
> |
extern void del_all_accepts(struct Client *); |
| 552 |
|
extern void exit_client(struct Client *, struct Client *, const char *); |
| 553 |
|
extern void check_conf_klines(void); |
| 554 |
|
extern void init_client(void); |
| 566 |
– |
extern void del_from_accept(struct Client *, struct Client *); |
| 567 |
– |
extern void del_all_accepts(struct Client *); |
| 568 |
– |
extern void del_all_their_accepts(struct Client *); |
| 555 |
|
extern void change_local_nick(struct Client *, struct Client *, const char *); |
| 556 |
|
extern void dead_link_on_write(struct Client *, int); |
| 557 |
|
extern void dead_link_on_read(struct Client *, int); |