summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-28 21:14:41 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-28 21:14:41 +0000
commit774747d8acc5d04d60c966eff91e1a9b81f2526b (patch)
tree91241870da5ff32f002db787ee54d9e33d379dc8
parent02a1173a5e689bf26bb1c2942de39a80e14a37c9 (diff)
Add Apply and DefaultApply.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8412 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/xline.h23
-rw-r--r--src/xline.cpp39
2 files changed, 54 insertions, 8 deletions
diff --git a/include/xline.h b/include/xline.h
index fd25976f4..d51ef7f49 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -33,7 +33,12 @@ const int APPLY_ALL = APPLY_GLINES | APPLY_KLINES | APPLY_QLINES | APPLY_ZLINES
*/
class CoreExport XLine : public classbase
{
- public:
+ protected:
+
+ InspIRCd* ServerInstance;
+ void DefaultApply(User* u, char line);
+
+ public:
/** Create an XLine.
* @param s_time The set time
@@ -41,8 +46,8 @@ class CoreExport XLine : public classbase
* @param src The sender of the xline
* @param re The reason of the xline
*/
- XLine(time_t s_time, long d, const char* src, const char* re)
- : set_time(s_time), duration(d)
+ XLine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re)
+ : ServerInstance(Instance), set_time(s_time), duration(d)
{
source = strdup(src);
reason = strdup(re);
@@ -63,6 +68,8 @@ class CoreExport XLine : public classbase
virtual bool Matches(const std::string &str);
+ virtual void Apply(User* u);
+
/** The time the line was added.
*/
time_t set_time;
@@ -101,7 +108,7 @@ class CoreExport KLine : public XLine
* @param ident Ident to match
* @param host Host to match
*/
- 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)
+ KLine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char* ident, const char* host) : XLine(Instance, s_time, d, src, re)
{
identmask = strdup(ident);
hostmask = strdup(host);
@@ -139,7 +146,7 @@ class CoreExport GLine : public XLine
* @param ident Ident to match
* @param host Host to match
*/
- 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)
+ GLine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char* ident, const char* host) : XLine(Instance, s_time, d, src, re)
{
identmask = strdup(ident);
hostmask = strdup(host);
@@ -177,7 +184,7 @@ class CoreExport ELine : public XLine
* @param ident Ident to match
* @param host Host to match
*/
- 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)
+ ELine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char* ident, const char* host) : XLine(Instance, s_time, d, src, re)
{
identmask = strdup(ident);
hostmask = strdup(host);
@@ -212,7 +219,7 @@ class CoreExport ZLine : public XLine
* @param re The reason of the xline
* @param ip IP to match
*/
- ZLine(time_t s_time, long d, const char* src, const char* re, const char* ip) : XLine(s_time, d, src, re)
+ ZLine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char* ip) : XLine(Instance, s_time, d, src, re)
{
ipaddr = strdup(ip);
type = 'Z';
@@ -246,7 +253,7 @@ class CoreExport QLine : public XLine
* @param re The reason of the xline
* @param nickname Nickname to match
*/
- QLine(time_t s_time, long d, const char* src, const char* re, const char* nickname) : XLine(s_time, d, src, re)
+ QLine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char* nickname) : XLine(Instance, s_time, d, src, re)
{
nick = strdup(nickname);
type = 'Q';
diff --git a/src/xline.cpp b/src/xline.cpp
index 428ea2c16..115ab0da6 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -693,6 +693,22 @@ bool XLine::Matches(const std::string &str)
return false;
}
+void XLine::Apply(User* u)
+{
+}
+
+void XLine::DefaultApply(User* u, char line)
+{
+ char reason[MAXBUF];
+ snprintf(reason, MAXBUF, "%c-Lined: %s", line, this->reason);
+ if (*ServerInstance->Config->MoronBanner)
+ u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner);
+ if (ServerInstance->Config->HideBans)
+ User::QuitUser(ServerInstance, u, line + std::string("-Lined"), reason);
+ else
+ User::QuitUser(ServerInstance, u, reason);
+}
+
bool KLine::Matches(User *u)
{
if ((match(u->ident, this->identmask)))
@@ -706,6 +722,11 @@ bool KLine::Matches(User *u)
return false;
}
+void KLine::Apply(User* u)
+{
+ DefaultApply(u, 'K');
+}
+
bool GLine::Matches(User *u)
{
if ((match(u->ident, this->identmask)))
@@ -719,6 +740,11 @@ bool GLine::Matches(User *u)
return false;
}
+void GLine::Apply(User* u)
+{
+ DefaultApply(u, 'G');
+}
+
bool ELine::Matches(User *u)
{
if ((match(u->ident, this->identmask)))
@@ -740,6 +766,12 @@ bool ZLine::Matches(User *u)
return false;
}
+void ZLine::Apply(User* u)
+{
+ DefaultApply(u, 'Z');
+}
+
+
bool QLine::Matches(User *u)
{
if (match(u->nick, this->nick))
@@ -748,6 +780,13 @@ bool QLine::Matches(User *u)
return false;
}
+void QLine::Apply(User* u)
+{
+ /* Can we force the user to their uid here instead? */
+ DefaultApply(u, 'Q');
+}
+
+
bool ZLine::Matches(const std::string &str)
{
if (match(str.c_str(), this->ipaddr, true))