2004-05-16 14:58:40 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
2006-01-15 15:59:11 +00:00
|
|
|
* InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
|
2004-05-16 14:58:40 +00:00
|
|
|
* E-mail:
|
|
|
|
* <brain@chatspike.net>
|
|
|
|
* <Craig@chatspike.net>
|
|
|
|
*
|
|
|
|
* Written by Craig Edwards, Craig McLure, and others.
|
|
|
|
* This program is free but copyrighted software; see
|
|
|
|
* the file COPYING for details.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2004-04-24 15:50:55 +00:00
|
|
|
#ifndef __XLINE_H
|
|
|
|
#define __XLINE_H
|
|
|
|
|
|
|
|
// include the common header files
|
|
|
|
|
|
|
|
#include <typeinfo>
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
#include <deque>
|
|
|
|
#include <sstream>
|
|
|
|
#include <vector>
|
|
|
|
#include "users.h"
|
|
|
|
#include "channels.h"
|
|
|
|
|
2005-12-14 09:43:31 +00:00
|
|
|
const int APPLY_GLINES = 1;
|
|
|
|
const int APPLY_KLINES = 2;
|
|
|
|
const int APPLY_QLINES = 4;
|
|
|
|
const int APPLY_ZLINES = 8;
|
|
|
|
const int APPLY_ALL = APPLY_GLINES | APPLY_KLINES | APPLY_QLINES | APPLY_ZLINES;
|
2004-04-24 15:50:55 +00:00
|
|
|
|
2004-04-24 15:59:40 +00:00
|
|
|
/** XLine is the base class for ban lines such as G lines and K lines.
|
|
|
|
*/
|
|
|
|
class XLine : public classbase
|
|
|
|
{
|
2004-04-24 18:15:37 +00:00
|
|
|
public:
|
2004-04-24 15:59:40 +00:00
|
|
|
|
|
|
|
/** The time the line was added.
|
|
|
|
*/
|
|
|
|
time_t set_time;
|
|
|
|
|
|
|
|
/** The duration of the ban, or 0 if permenant
|
|
|
|
*/
|
|
|
|
long duration;
|
|
|
|
|
|
|
|
/** Source of the ban. This can be a servername or an oper nickname
|
|
|
|
*/
|
2005-05-12 19:09:42 +00:00
|
|
|
char source[256];
|
2004-04-24 15:59:40 +00:00
|
|
|
|
|
|
|
/** Reason for the ban
|
|
|
|
*/
|
|
|
|
char reason[MAXBUF];
|
|
|
|
|
|
|
|
/** Number of times the core matches the ban, for statistics
|
|
|
|
*/
|
|
|
|
long n_matches;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2004-04-24 18:15:37 +00:00
|
|
|
/** KLine class
|
|
|
|
*/
|
2004-04-24 15:59:40 +00:00
|
|
|
class KLine : public XLine
|
|
|
|
{
|
2004-04-24 18:15:37 +00:00
|
|
|
public:
|
2004-04-24 15:59:40 +00:00
|
|
|
/** Hostmask (ident@host) to match against
|
|
|
|
* May contain wildcards.
|
|
|
|
*/
|
2005-05-12 19:09:42 +00:00
|
|
|
char hostmask[200];
|
2004-04-24 15:59:40 +00:00
|
|
|
};
|
|
|
|
|
2004-04-24 18:15:37 +00:00
|
|
|
/** GLine class
|
|
|
|
*/
|
2004-04-24 15:59:40 +00:00
|
|
|
class GLine : public XLine
|
|
|
|
{
|
2004-04-24 18:15:37 +00:00
|
|
|
public:
|
2004-04-24 15:59:40 +00:00
|
|
|
/** Hostmask (ident@host) to match against
|
|
|
|
* May contain wildcards.
|
|
|
|
*/
|
2005-05-12 19:09:42 +00:00
|
|
|
char hostmask[200];
|
2004-04-24 15:59:40 +00:00
|
|
|
};
|
|
|
|
|
2005-04-04 17:55:48 +00:00
|
|
|
class ELine : public XLine
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** Hostmask (ident@host) to match against
|
|
|
|
* May contain wildcards.
|
|
|
|
*/
|
2005-05-12 19:09:42 +00:00
|
|
|
char hostmask[200];
|
2005-04-04 17:55:48 +00:00
|
|
|
};
|
|
|
|
|
2004-04-24 18:15:37 +00:00
|
|
|
/** ZLine class
|
|
|
|
*/
|
2004-04-24 15:59:40 +00:00
|
|
|
class ZLine : public XLine
|
|
|
|
{
|
2004-04-24 18:15:37 +00:00
|
|
|
public:
|
2004-04-24 15:59:40 +00:00
|
|
|
/** IP Address (xx.yy.zz.aa) to match against
|
2004-04-24 18:15:37 +00:00
|
|
|
* May contain wildcards.
|
2004-04-24 15:59:40 +00:00
|
|
|
*/
|
2005-05-12 19:09:42 +00:00
|
|
|
char ipaddr[40];
|
2004-04-25 14:01:33 +00:00
|
|
|
/** Set if this is a global Z:line
|
|
|
|
* (e.g. it came from another server)
|
|
|
|
*/
|
2004-04-25 13:54:16 +00:00
|
|
|
bool is_global;
|
2004-04-24 15:59:40 +00:00
|
|
|
};
|
|
|
|
|
2004-04-24 18:15:37 +00:00
|
|
|
/** QLine class
|
|
|
|
*/
|
2004-04-24 15:59:40 +00:00
|
|
|
class QLine : public XLine
|
|
|
|
{
|
2004-04-24 18:15:37 +00:00
|
|
|
public:
|
2004-04-24 15:59:40 +00:00
|
|
|
/** Nickname to match against.
|
|
|
|
* May contain wildcards.
|
|
|
|
*/
|
2005-05-12 19:09:42 +00:00
|
|
|
char nick[64];
|
2004-04-25 14:01:33 +00:00
|
|
|
/** Set if this is a global Z:line
|
|
|
|
* (e.g. it came from another server)
|
|
|
|
*/
|
2004-04-25 13:54:16 +00:00
|
|
|
bool is_global;
|
2004-04-24 15:59:40 +00:00
|
|
|
};
|
2004-04-24 15:50:55 +00:00
|
|
|
|
2004-04-24 18:15:37 +00:00
|
|
|
void read_xline_defaults();
|
|
|
|
|
2006-02-08 18:14:12 +00:00
|
|
|
bool add_gline(long duration, const char* source, const char* reason, const char* hostmask);
|
|
|
|
bool add_qline(long duration, const char* source, const char* reason, const char* nickname);
|
|
|
|
bool add_zline(long duration, const char* source, const char* reason, const char* ipaddr);
|
|
|
|
bool add_kline(long duration, const char* source, const char* reason, const char* hostmask);
|
|
|
|
bool add_eline(long duration, const char* source, const char* reason, const char* hostmask);
|
2005-04-13 12:41:46 +00:00
|
|
|
|
|
|
|
bool del_gline(const char* hostmask);
|
|
|
|
bool del_qline(const char* nickname);
|
|
|
|
bool del_zline(const char* ipaddr);
|
|
|
|
bool del_kline(const char* hostmask);
|
|
|
|
bool del_eline(const char* hostmask);
|
2004-04-24 18:15:37 +00:00
|
|
|
|
|
|
|
char* matches_qline(const char* nick);
|
|
|
|
char* matches_gline(const char* host);
|
|
|
|
char* matches_zline(const char* ipaddr);
|
|
|
|
char* matches_kline(const char* host);
|
2005-04-04 17:55:48 +00:00
|
|
|
char* matches_exception(const char* host);
|
2004-04-24 18:15:37 +00:00
|
|
|
|
|
|
|
void expire_lines();
|
2005-12-14 09:43:31 +00:00
|
|
|
void apply_lines(const int What);
|
2004-04-24 18:15:37 +00:00
|
|
|
|
2004-04-24 20:01:06 +00:00
|
|
|
void stats_k(userrec* user);
|
|
|
|
void stats_g(userrec* user);
|
|
|
|
void stats_q(userrec* user);
|
|
|
|
void stats_z(userrec* user);
|
2005-04-04 17:55:48 +00:00
|
|
|
void stats_e(userrec* user);
|
2004-04-24 20:01:06 +00:00
|
|
|
|
2004-04-24 21:21:29 +00:00
|
|
|
void gline_set_creation_time(char* host, time_t create_time);
|
|
|
|
void qline_set_creation_time(char* nick, time_t create_time);
|
|
|
|
void zline_set_creation_time(char* ip, time_t create_time);
|
2005-12-08 16:39:22 +00:00
|
|
|
void eline_set_creation_time(char* host, time_t create_time);
|
|
|
|
|
2005-04-13 12:41:46 +00:00
|
|
|
bool zline_make_global(const char* ipaddr);
|
|
|
|
bool qline_make_global(const char* nickname);
|
2004-04-25 13:54:16 +00:00
|
|
|
|
2004-04-24 15:50:55 +00:00
|
|
|
#endif
|