X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fxline.h;h=0aa831670582eba64814083a5fe5047bcb96a940;hb=38ca8be9a3881a3cb3cf6864e67b779ffbab6874;hp=34bd0d920c84e7d18872a339d8e5f908ef6670e3;hpb=a9c93027da4901123f9170a654d7c9802c40ea65;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/xline.h b/include/xline.h index 34bd0d920..0aa831670 100644 --- a/include/xline.h +++ b/include/xline.h @@ -2,12 +2,9 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. - * E-mail: - * - * - * - * Written by Craig Edwards, Craig McLure, and others. + * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits + * * This program is free but copyrighted software; see * the file COPYING for details. * @@ -25,11 +22,12 @@ #include "users.h" #include "channels.h" -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; +const int APPLY_GLINES = 1; +const int APPLY_KLINES = 2; +const int APPLY_QLINES = 4; +const int APPLY_ZLINES = 8; +const int APPLY_PERM_ONLY = 16; +const int APPLY_ALL = APPLY_GLINES | APPLY_KLINES | APPLY_QLINES | APPLY_ZLINES; /** XLine is the base class for ban lines such as G lines and K lines. */ @@ -37,6 +35,19 @@ class XLine : public classbase { public: + XLine(time_t s_time, long d, const char* src, const char* re) + : set_time(s_time), duration(d) + { + source = strdup(src); + reason = strdup(re); + expiry = set_time + duration; + } + + virtual ~XLine() + { + free(reason); + free(source); + } /** The time the line was added. */ time_t set_time; @@ -47,16 +58,15 @@ class XLine : public classbase /** Source of the ban. This can be a servername or an oper nickname */ - char source[256]; + char* source; /** Reason for the ban */ - char reason[MAXBUF]; - - /** Number of times the core matches the ban, for statistics + char* reason; + + /** Expiry time */ - long n_matches; - + time_t expiry; }; /** KLine class @@ -67,8 +77,20 @@ class KLine : public XLine /** Hostmask (ident@host) to match against * May contain wildcards. */ - char identmask[20]; - char hostmask[200]; + KLine(time_t s_time, long d, const char* src, const char* re, const char* ident, const char* host) : XLine(s_time, d, src, re) + { + identmask = strdup(ident); + hostmask = strdup(host); + } + + ~KLine() + { + free(identmask); + free(hostmask); + } + + char* identmask; + char* hostmask; }; /** GLine class @@ -79,8 +101,20 @@ class GLine : public XLine /** Hostmask (ident@host) to match against * May contain wildcards. */ - char identmask[20]; - char hostmask[200]; + GLine(time_t s_time, long d, const char* src, const char* re, const char* ident, const char* host) : XLine(s_time, d, src, re) + { + identmask = strdup(ident); + hostmask = strdup(host); + } + + ~GLine() + { + free(identmask); + free(hostmask); + } + + char* identmask; + char* hostmask; }; /** ELine class @@ -91,8 +125,20 @@ class ELine : public XLine /** Hostmask (ident@host) to match against * May contain wildcards. */ - char identmask[20]; - char hostmask[200]; + ELine(time_t s_time, long d, const char* src, const char* re, const char* ident, const char* host) : XLine(s_time, d, src, re) + { + identmask = strdup(ident); + hostmask = strdup(host); + } + + ~ELine() + { + free(identmask); + free(hostmask); + } + + char* identmask; + char* hostmask; }; /** ZLine class @@ -103,11 +149,17 @@ class ZLine : public XLine /** IP Address (xx.yy.zz.aa) to match against * May contain wildcards. */ - char ipaddr[40]; - /** Set if this is a global Z:line - * (e.g. it came from another server) - */ - bool is_global; + ZLine(time_t s_time, long d, const char* src, const char* re, const char* ip) : XLine(s_time, d, src, re) + { + ipaddr = strdup(ip); + } + + ~ZLine() + { + free(ipaddr); + } + + char* ipaddr; }; /** QLine class @@ -118,23 +170,33 @@ class QLine : public XLine /** Nickname to match against. * May contain wildcards. */ - char nick[64]; - /** Set if this is a global Z:line - * (e.g. it came from another server) - */ - bool is_global; + QLine(time_t s_time, long d, const char* src, const char* re, const char* nickname) : XLine(s_time, d, src, re) + { + nick = strdup(nickname); + } + + ~QLine() + { + free(nick); + } + + char* nick; }; class ServerConfig; class InspIRCd; bool InitXLine(ServerConfig* conf, const char* tag); -bool DoneXLine(ServerConfig* conf, const char* tag); -bool DoZLine(ServerConfig* conf, const char* tag, char** entries, void** values, int* types); -bool DoQLine(ServerConfig* conf, const char* tag, char** entries, void** values, int* types); -bool DoKLine(ServerConfig* conf, const char* tag, char** entries, void** values, int* types); -bool DoELine(ServerConfig* conf, const char* tag, char** entries, void** values, int* types); +bool DoneZLine(ServerConfig* conf, const char* tag); +bool DoneQLine(ServerConfig* conf, const char* tag); +bool DoneKLine(ServerConfig* conf, const char* tag); +bool DoneELine(ServerConfig* conf, const char* tag); + +bool DoZLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types); +bool DoQLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types); +bool DoKLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types); +bool DoELine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types); typedef std::pair IdentHostPair; @@ -149,64 +211,64 @@ class XLineManager /** This functor is used by the std::sort() function to keep glines in order */ - static bool GSortComparison ( const GLine one, const GLine two ); + static bool GSortComparison ( const GLine* one, const GLine* two ); /** This functor is used by the std::sort() function to keep elines in order */ - static bool ESortComparison ( const ELine one, const ELine two ); + static bool ESortComparison ( const ELine* one, const ELine* two ); /** This functor is used by the std::sort() function to keep zlines in order */ - static bool ZSortComparison ( const ZLine one, const ZLine two ); + static bool ZSortComparison ( const ZLine* one, const ZLine* two ); /** This functor is used by the std::sort() function to keep klines in order */ - static bool KSortComparison ( const KLine one, const KLine two ); + static bool KSortComparison ( const KLine* one, const KLine* two ); /** This functor is used by the std::sort() function to keep qlines in order */ - static bool QSortComparison ( const QLine one, const QLine two ); + static bool QSortComparison ( const QLine* one, const QLine* two ); public: /* Lists for temporary lines with an expiry time */ /** Temporary KLines */ - std::vector klines; + std::vector klines; /** Temporary Glines */ - std::vector glines; + std::vector glines; /** Temporary Zlines */ - std::vector zlines; + std::vector zlines; /** Temporary QLines */ - std::vector qlines; + std::vector qlines; /** Temporary ELines */ - std::vector elines; + std::vector elines; /* Seperate lists for perm XLines that isnt checked by expiry functions */ /** Permenant KLines */ - std::vector pklines; + std::vector pklines; /** Permenant GLines */ - std::vector pglines; + std::vector pglines; /** Permenant ZLines */ - std::vector pzlines; + std::vector pzlines; /** Permenant QLines */ - std::vector pqlines; + std::vector pqlines; /** Permenant ELines */ - std::vector pelines; + std::vector pelines; /** Constructor * @param Instance A pointer to the creator object */ XLineManager(InspIRCd* Instance); - IdentHostPair XLineManager::IdentSplit(const std::string &ident_and_host); + IdentHostPair IdentSplit(const std::string &ident_and_host); /** Add a new GLine * @param duration The duration of the line @@ -287,31 +349,31 @@ class XLineManager * @return nick The nick to check against * @return The reason for the line if there is a match, or NULL if there is no match */ - char* matches_qline(const char* nick); + QLine* matches_qline(const char* nick, bool permonly = false); /** Check if a hostname matches a GLine * @param user The user to check against * @return The reason for the line if there is a match, or NULL if there is no match */ - char* matches_gline(userrec* user); + GLine* matches_gline(userrec* user, bool permonly = false); /** Check if a IP matches a ZLine * @param ipaddr The IP to check against * @return The reason for the line if there is a match, or NULL if there is no match */ - char* matches_zline(const char* ipaddr); + ZLine* matches_zline(const char* ipaddr, bool permonly = false); /** Check if a hostname matches a KLine * @param user The user to check against * @return The reason for the line if there is a match, or NULL if there is no match */ - char* matches_kline(userrec* user); + KLine* matches_kline(userrec* user, bool permonly = false); /** Check if a hostname matches a ELine * @param user The user to check against * @return The reason for the line if there is a match, or NULL if there is no match */ - char* matches_exception(userrec* user); + ELine* matches_exception(userrec* user, bool permonly = false); /** Expire any pending non-permenant lines */ @@ -320,6 +382,7 @@ class XLineManager /** Apply any new lines * @param What The types of lines to apply, from the set * APPLY_GLINES | APPLY_KLINES | APPLY_QLINES | APPLY_ZLINES | APPLY_ALL + * | APPLY_LOCAL_ONLY */ void apply_lines(const int What); @@ -376,18 +439,6 @@ class XLineManager * @param create_Time The new creation time */ void eline_set_creation_time(const char* host, time_t create_time); - - /** Make a ZLine global - * @param ipaddr The zline to change - * @return True if the zline was updated - */ - bool zline_make_global(const char* ipaddr); - - /** Make a QLine global - * @param nickname The qline to change - * @return True if the qline was updated - */ - bool qline_make_global(const char* nickname); }; #endif