// include the common header files
-#include <typeinfo>
-#include <iostream>
#include <string>
#include <deque>
-#include <sstream>
#include <vector>
#include "users.h"
#include "channels.h"
{
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;
/** 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
/** Hostmask (ident@host) to match against
* May contain wildcards.
*/
- 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
/** Hostmask (ident@host) to match against
* May contain wildcards.
*/
- 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
/** Hostmask (ident@host) to match against
* May contain wildcards.
*/
- 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
/** 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
/** 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;
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 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<std::string, std::string> IdentHostPair;
/** XLineManager is a class used to manage glines, klines, elines, zlines and qlines.
*/
/** This functor is used by the std::sort() function to keep glines in order
*/
- static bool XLineManager::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 XLineManager::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 XLineManager::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 XLineManager::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 XLineManager::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<KLine> klines;
+ std::vector<KLine*> klines;
/** Temporary Glines */
- std::vector<GLine> glines;
+ std::vector<GLine*> glines;
/** Temporary Zlines */
- std::vector<ZLine> zlines;
+ std::vector<ZLine*> zlines;
/** Temporary QLines */
- std::vector<QLine> qlines;
+ std::vector<QLine*> qlines;
/** Temporary ELines */
- std::vector<ELine> elines;
+ std::vector<ELine*> elines;
/* Seperate lists for perm XLines that isnt checked by expiry functions */
/** Permenant KLines */
- std::vector<KLine> pklines;
+ std::vector<KLine*> pklines;
/** Permenant GLines */
- std::vector<GLine> pglines;
+ std::vector<GLine*> pglines;
/** Permenant ZLines */
- std::vector<ZLine> pzlines;
+ std::vector<ZLine*> pzlines;
/** Permenant QLines */
- std::vector<QLine> pqlines;
+ std::vector<QLine*> pqlines;
/** Permenant ELines */
- std::vector<ELine> pelines;
+ std::vector<ELine*> pelines;
/** Constructor
* @param Instance A pointer to the creator object
*/
XLineManager(InspIRCd* Instance);
+ IdentHostPair IdentSplit(const std::string &ident_and_host);
+
/** Add a new GLine
* @param duration The duration of the line
* @param source The source of the line
* @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);
/** Check if a hostname matches a GLine
- * @return host The host to check against
+ * @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(const char* host);
+ GLine* matches_gline(userrec* user);
/** Check if a IP matches a ZLine
- * @return ipaddr The IP to check against
+ * @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);
/** Check if a hostname matches a KLine
- * @return host The host to check against
+ * @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(const char* host);
+ KLine* matches_kline(userrec* user);
/** Check if a hostname matches a ELine
- * @return host The host to check against
+ * @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(const char* host);
+ ELine* matches_exception(userrec* user);
/** Expire any pending non-permenant lines
*/
* @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