| 1 |
|
/* |
| 2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 2 |
> |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
|
* |
| 4 |
< |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
| 4 |
> |
* Copyright (c) 1997-2014 ircd-hybrid development team |
| 5 |
|
* |
| 6 |
|
* This program is free software; you can redistribute it and/or modify |
| 7 |
|
* it under the terms of the GNU General Public License as published by |
| 36 |
|
#include "channel.h" |
| 37 |
|
#include "s_auth.h" |
| 38 |
|
|
| 39 |
+ |
struct MaskItem; |
| 40 |
+ |
|
| 41 |
|
/* |
| 42 |
|
* status macros. |
| 43 |
|
*/ |
| 53 |
|
#define REG_NEED_CAP 0x4 |
| 54 |
|
#define REG_INIT (REG_NEED_USER|REG_NEED_NICK) |
| 55 |
|
|
| 56 |
< |
#define HasID(x) ((x)->id[0] != '\0') |
| 55 |
< |
#define ID(x) (HasID(x) ? (x)->id : (x)->name) |
| 56 |
< |
#define ID_or_name(x,client_p) ((IsCapable(client_p, CAP_TS6) && HasID(x)) ? (x)->id : (x)->name) |
| 56 |
> |
#define ID_or_name(x,client_p) ((IsCapable(client_p->from, CAP_TS6) && (x)->id[0]) ? (x)->id : (x)->name) |
| 57 |
|
|
| 58 |
|
#define IsRegistered(x) ((x)->status > STAT_UNKNOWN) |
| 59 |
|
#define IsConnecting(x) ((x)->status == STAT_CONNECTING) |
| 64 |
|
#define IsClient(x) ((x)->status == STAT_CLIENT) |
| 65 |
|
|
| 66 |
|
#define SetConnecting(x) {(x)->status = STAT_CONNECTING; \ |
| 67 |
< |
(x)->handler = UNREGISTERED_HANDLER; } |
| 67 |
> |
(x)->handler = UNREGISTERED_HANDLER; } |
| 68 |
|
|
| 69 |
|
#define SetHandshake(x) {(x)->status = STAT_HANDSHAKE; \ |
| 70 |
< |
(x)->handler = UNREGISTERED_HANDLER; } |
| 70 |
> |
(x)->handler = UNREGISTERED_HANDLER; } |
| 71 |
|
|
| 72 |
|
#define SetMe(x) {(x)->status = STAT_ME; \ |
| 73 |
< |
(x)->handler = UNREGISTERED_HANDLER; } |
| 73 |
> |
(x)->handler = UNREGISTERED_HANDLER; } |
| 74 |
|
|
| 75 |
|
#define SetUnknown(x) {(x)->status = STAT_UNKNOWN; \ |
| 76 |
< |
(x)->handler = UNREGISTERED_HANDLER; } |
| 76 |
> |
(x)->handler = UNREGISTERED_HANDLER; } |
| 77 |
|
|
| 78 |
|
#define SetServer(x) {(x)->status = STAT_SERVER; \ |
| 79 |
< |
(x)->handler = SERVER_HANDLER; } |
| 79 |
> |
(x)->handler = SERVER_HANDLER; } |
| 80 |
|
|
| 81 |
|
#define SetClient(x) {(x)->status = STAT_CLIENT; \ |
| 82 |
< |
(x)->handler = HasUMode(x, UMODE_OPER) ? \ |
| 83 |
< |
OPER_HANDLER : CLIENT_HANDLER; } |
| 82 |
> |
(x)->handler = HasUMode(x, UMODE_OPER) ? \ |
| 83 |
> |
OPER_HANDLER : CLIENT_HANDLER; } |
| 84 |
|
|
| 85 |
|
#define MyConnect(x) ((x)->localClient != NULL) |
| 86 |
|
#define MyClient(x) (MyConnect(x) && IsClient(x)) |
| 88 |
|
/* |
| 89 |
|
* ts stuff |
| 90 |
|
*/ |
| 91 |
< |
#define TS_CURRENT 6 /**< current TS protocol version */ |
| 92 |
< |
#define TS_MIN 5 /**< minimum supported TS protocol version */ |
| 91 |
> |
#define TS_CURRENT 6 /**< Current TS protocol version */ |
| 92 |
> |
#define TS_MIN 6 /**< Minimum supported TS protocol version */ |
| 93 |
|
#define TS_DOESTS 0x20000000 |
| 94 |
|
#define DoesTS(x) ((x)->tsinfo == TS_DOESTS) |
| 95 |
|
|
| 97 |
|
|
| 98 |
|
#define CAP_MULTI_PREFIX 0x00000001 |
| 99 |
|
#define CAP_AWAY_NOTIFY 0x00000002 |
| 100 |
+ |
#define CAP_UHNAMES 0x00000004 |
| 101 |
|
|
| 102 |
|
#define HasCap(x, y) ((x)->localClient->cap_active & (y)) |
| 103 |
|
|
| 104 |
+ |
|
| 105 |
|
/* housekeeping flags */ |
| 106 |
|
#define FLAGS_PINGSENT 0x00000001 /**< Unreplied ping sent */ |
| 107 |
|
#define FLAGS_DEADSOCKET 0x00000002 /**< Local socket is dead--Exiting soon */ |
| 131 |
|
#define FLAGS_SERVICE 0x02000000 /**< Client/server is a network service */ |
| 132 |
|
#define FLAGS_AUTH_SPOOF 0x04000000 /**< user's hostname has been spoofed by an auth{} spoof*/ |
| 133 |
|
#define FLAGS_SSL 0x08000000 /**< User is connected via TLS/SSL */ |
| 134 |
+ |
#define FLAGS_SQUIT 0x10000000 |
| 135 |
|
|
| 136 |
|
#define HasFlag(x, y) ((x)->flags & (y)) |
| 137 |
|
#define AddFlag(x, y) ((x)->flags |= (y)) |
| 166 |
|
#define UMODE_FARCONNECT 0x00800000 /**< Can see remote client connects/exits */ |
| 167 |
|
#define UMODE_HIDDENHOST 0x01000000 /**< User's host is hidden */ |
| 168 |
|
#define UMODE_SSL 0x02000000 /**< User is connected via TLS/SSL */ |
| 169 |
+ |
#define UMODE_WEBIRC 0x04000000 /**< User connected via a webirc gateway */ |
| 170 |
|
|
| 171 |
|
|
| 172 |
|
#define UMODE_ALL UMODE_SERVNOTICE |
| 177 |
|
|
| 178 |
|
#define SEND_UMODES (UMODE_INVISIBLE | UMODE_OPER | UMODE_WALLOP |\ |
| 179 |
|
UMODE_REGONLY | UMODE_REGISTERED | UMODE_ADMIN |\ |
| 180 |
< |
UMODE_HIDDEN | UMODE_HIDDENHOST | UMODE_SSL) |
| 180 |
> |
UMODE_HIDDEN | UMODE_HIDDENHOST | UMODE_SSL |\ |
| 181 |
> |
UMODE_WEBIRC | UMODE_CALLERID | UMODE_SOFTCALLERID) |
| 182 |
|
|
| 183 |
|
|
| 184 |
|
|
| 185 |
|
/* oper priv flags */ |
| 186 |
< |
#define OPER_FLAG_KILL_REMOTE 0x00000001 /**< Oper can global kill */ |
| 187 |
< |
#define OPER_FLAG_KILL 0x00000002 /**< Oper can do local KILL */ |
| 188 |
< |
#define OPER_FLAG_UNKLINE 0x00000004 /**< Oper can use unkline */ |
| 189 |
< |
#define OPER_FLAG_GLINE 0x00000008 /**< Oper can use gline */ |
| 190 |
< |
#define OPER_FLAG_K 0x00000010 /**< Oper can kill/kline */ |
| 191 |
< |
#define OPER_FLAG_X 0x00000020 /**< Oper can xline */ |
| 192 |
< |
#define OPER_FLAG_DIE 0x00000040 /**< Oper can die */ |
| 193 |
< |
#define OPER_FLAG_REHASH 0x00000080 /**< Oper can rehash */ |
| 194 |
< |
#define OPER_FLAG_ADMIN 0x00000100 /**< Oper can set umode +a */ |
| 186 |
> |
#define OPER_FLAG_KILL_REMOTE 0x00000001 /**< Oper can global KILL */ |
| 187 |
> |
#define OPER_FLAG_KILL 0x00000002 /**< Oper can do local KILL */ |
| 188 |
> |
#define OPER_FLAG_UNKLINE 0x00000004 /**< Oper can use unkline*/ |
| 189 |
> |
#define OPER_FLAG_GLINE 0x00000008 /**< Oper can use gline */ |
| 190 |
> |
#define OPER_FLAG_K 0x00000010 /**< Oper can kline */ |
| 191 |
> |
#define OPER_FLAG_XLINE 0x00000020 /**< Oper can xline */ |
| 192 |
> |
#define OPER_FLAG_DIE 0x00000040 /**< Oper can die*/ |
| 193 |
> |
#define OPER_FLAG_REHASH 0x00000080 /**< Oper can rehash */ |
| 194 |
> |
#define OPER_FLAG_ADMIN 0x00000100 /**< Oper can set umode +a*/ |
| 195 |
|
#define OPER_FLAG_OPERWALL 0x00000200 /**< Oper can use OPERWALL command */ |
| 196 |
|
#define OPER_FLAG_REMOTEBAN 0x00000400 /**< Oper can set remote bans */ |
| 197 |
|
#define OPER_FLAG_GLOBOPS 0x00000800 /**< Oper can use GLOBOPS command */ |
| 206 |
|
#define OPER_FLAG_CONNECT_REMOTE 0x00100000 /**< Oper can do global CONNECT */ |
| 207 |
|
#define OPER_FLAG_WALLOPS 0x00200000 /**< Oper can do WALLOPS */ |
| 208 |
|
#define OPER_FLAG_LOCOPS 0x00400000 /**< Oper can do LOCOPS */ |
| 209 |
+ |
#define OPER_FLAG_UNXLINE 0x00800000 /**< Oper can unxline*/ |
| 210 |
+ |
|
| 211 |
|
|
| 212 |
|
#define HasOFlag(x, y) (MyConnect(x) ? (x)->localClient->operflags & (y) : 0) |
| 213 |
|
#define AddOFlag(x, y) ((x)->localClient->operflags |= (y)) |
| 220 |
|
#define IsAuthFinished(x) ((x)->flags & FLAGS_FINISHED_AUTH) |
| 221 |
|
#define IsDead(x) ((x)->flags & FLAGS_DEADSOCKET) |
| 222 |
|
#define SetDead(x) ((x)->flags |= FLAGS_DEADSOCKET) |
| 223 |
< |
#define IsClosing(x) ((x)->flags & FLAGS_CLOSING) |
| 224 |
< |
#define SetClosing(x) ((x)->flags |= FLAGS_CLOSING) |
| 225 |
< |
#define SetCanFlood(x) ((x)->flags |= FLAGS_CANFLOOD) |
| 226 |
< |
#define IsCanFlood(x) ((x)->flags & FLAGS_CANFLOOD) |
| 227 |
< |
#define IsDefunct(x) ((x)->flags & (FLAGS_DEADSOCKET|FLAGS_CLOSING| \ |
| 221 |
< |
FLAGS_KILLED)) |
| 223 |
> |
#define IsClosing(x) ((x)->flags & FLAGS_CLOSING) |
| 224 |
> |
#define SetClosing(x) ((x)->flags |= FLAGS_CLOSING) |
| 225 |
> |
#define SetCanFlood(x) ((x)->flags |= FLAGS_CANFLOOD) |
| 226 |
> |
#define IsCanFlood(x) ((x)->flags & FLAGS_CANFLOOD) |
| 227 |
> |
#define IsDefunct(x) ((x)->flags & (FLAGS_DEADSOCKET|FLAGS_CLOSING|FLAGS_KILLED)) |
| 228 |
|
|
| 229 |
|
/* oper flags */ |
| 230 |
|
#define MyOper(x) (MyConnect(x) && HasUMode(x, UMODE_OPER)) |
| 231 |
|
|
| 232 |
|
#define SetOper(x) {(x)->umodes |= UMODE_OPER; \ |
| 233 |
< |
if (!IsServer((x))) (x)->handler = OPER_HANDLER;} |
| 233 |
> |
if (!IsServer((x))) (x)->handler = OPER_HANDLER;} |
| 234 |
|
|
| 235 |
|
#define ClearOper(x) {(x)->umodes &= ~(UMODE_OPER|UMODE_ADMIN); \ |
| 236 |
< |
if (!HasUMode(x, UMODE_OPER) && !IsServer((x))) \ |
| 237 |
< |
(x)->handler = CLIENT_HANDLER; } |
| 236 |
> |
if (!HasUMode(x, UMODE_OPER) && !IsServer((x))) \ |
| 237 |
> |
(x)->handler = CLIENT_HANDLER; } |
| 238 |
|
|
| 239 |
< |
#define SetSendQExceeded(x) ((x)->flags |= FLAGS_SENDQEX) |
| 240 |
< |
#define IsSendQExceeded(x) ((x)->flags & FLAGS_SENDQEX) |
| 239 |
> |
#define SetSendQExceeded(x) ((x)->flags |= FLAGS_SENDQEX) |
| 240 |
> |
#define IsSendQExceeded(x) ((x)->flags & FLAGS_SENDQEX) |
| 241 |
|
|
| 242 |
|
#define SetIpHash(x) ((x)->flags |= FLAGS_IPHASH) |
| 243 |
|
#define ClearIpHash(x) ((x)->flags &= ~FLAGS_IPHASH) |
| 247 |
|
#define ClearUserHost(x) ((x)->flags &= ~FLAGS_USERHOST) |
| 248 |
|
#define IsUserHostIp(x) ((x)->flags & FLAGS_USERHOST) |
| 249 |
|
|
| 250 |
< |
#define SetPingSent(x) ((x)->flags |= FLAGS_PINGSENT) |
| 251 |
< |
#define IsPingSent(x) ((x)->flags & FLAGS_PINGSENT) |
| 252 |
< |
#define ClearPingSent(x) ((x)->flags &= ~FLAGS_PINGSENT) |
| 250 |
> |
#define SetPingSent(x) ((x)->flags |= FLAGS_PINGSENT) |
| 251 |
> |
#define IsPingSent(x) ((x)->flags & FLAGS_PINGSENT) |
| 252 |
> |
#define ClearPingSent(x) ((x)->flags &= ~FLAGS_PINGSENT) |
| 253 |
|
|
| 254 |
|
#define SetNeedId(x) ((x)->flags |= FLAGS_NEEDID) |
| 255 |
|
#define IsNeedId(x) ((x)->flags & FLAGS_NEEDID) |
| 276 |
|
#define IsHidden(x) ((x)->flags & FLAGS_HIDDEN) |
| 277 |
|
#define SetHidden(x) ((x)->flags |= FLAGS_HIDDEN) |
| 278 |
|
|
| 273 |
– |
#define IsSendqBlocked(x) ((x)->flags & FLAGS_BLOCKED) |
| 274 |
– |
#define SetSendqBlocked(x) ((x)->flags |= FLAGS_BLOCKED) |
| 275 |
– |
#define ClearSendqBlocked(x) ((x)->flags &= ~FLAGS_BLOCKED) |
| 276 |
– |
|
| 279 |
|
|
| 280 |
|
/*! \brief addr_mask_type enumeration */ |
| 281 |
|
enum addr_mask_type |
| 290 |
|
{ |
| 291 |
|
dlink_list server_list; /**< Servers on this server */ |
| 292 |
|
dlink_list client_list; /**< Clients on this server */ |
| 293 |
< |
char by[NICKLEN + 1]; /**< who activated this connection */ |
| 293 |
> |
char by[NICKLEN + 1]; /**< Who activated this connection */ |
| 294 |
|
}; |
| 295 |
|
|
| 296 |
|
/*! \brief ListTask structure */ |
| 297 |
|
struct ListTask |
| 298 |
|
{ |
| 299 |
< |
dlink_list show_mask; /**< show these channels.. */ |
| 300 |
< |
dlink_list hide_mask; /**< ..and hide these ones */ |
| 299 |
> |
dlink_list show_mask; /**< Channels to show */ |
| 300 |
> |
dlink_list hide_mask; /**< Channels to hide */ |
| 301 |
|
|
| 302 |
< |
unsigned int hash_index; /**< the bucket we are currently in */ |
| 302 |
> |
unsigned int hash_index; /**< The hash bucket we are currently in */ |
| 303 |
|
unsigned int users_min; |
| 304 |
|
unsigned int users_max; |
| 305 |
|
unsigned int created_min; |
| 408 |
|
|
| 409 |
|
char away[AWAYLEN + 1]; /**< Client's AWAY message. Can be set/unset via AWAY command */ |
| 410 |
|
char name[HOSTLEN + 1]; /**< unique name for a client nick or host */ |
| 411 |
< |
char svid[HOSTLEN + 1]; /**< Services ID. XXX: Going with HOSTLEN for now. NICKLEN might be too small |
| 410 |
< |
if dealing with timestamps */ |
| 411 |
> |
char svid[SVIDLEN + 1]; /**< Services ID. */ |
| 412 |
|
char id[IDLEN + 1]; /**< client ID, unique ID per client */ |
| 413 |
< |
/* |
| 413 |
> |
/* |
| 414 |
|
* client->username is the username from ident or the USER message, |
| 415 |
|
* If the client is idented the USER message is ignored, otherwise |
| 416 |
|
* the username part of the USER message is put here prefixed with a |
| 455 |
|
extern int accept_message(struct Client *, struct Client *); |
| 456 |
|
extern unsigned int idle_time_get(const struct Client *, const struct Client *); |
| 457 |
|
extern struct split_nuh_item *find_accept(const char *, const char *, |
| 458 |
< |
const char *, struct Client *, int); |
| 458 |
> |
const char *, struct Client *, |
| 459 |
> |
int (*)(const char *, const char *)); |
| 460 |
|
extern void del_accept(struct split_nuh_item *, struct Client *); |
| 461 |
|
extern void del_all_accepts(struct Client *); |
| 462 |
< |
extern void exit_client(struct Client *, struct Client *, const char *); |
| 462 |
> |
extern void exit_client(struct Client *, const char *); |
| 463 |
> |
extern void conf_try_ban(struct Client *, struct MaskItem *); |
| 464 |
|
extern void check_conf_klines(void); |
| 465 |
|
extern void client_init(void); |
| 466 |
|
extern void dead_link_on_write(struct Client *, int); |
| 468 |
|
extern void exit_aborted_clients(void); |
| 469 |
|
extern void free_exited_clients(void); |
| 470 |
|
extern struct Client *make_client(struct Client *); |
| 471 |
< |
extern struct Client *find_chasing(struct Client *, struct Client *, const char *, int *); |
| 471 |
> |
extern struct Client *find_chasing(struct Client *, const char *); |
| 472 |
|
extern struct Client *find_person(const struct Client *const, const char *); |
| 473 |
|
extern const char *get_client_name(const struct Client *, enum addr_mask_type); |
| 474 |
|
|