summaryrefslogtreecommitdiff
path: root/src/xline.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-04-04 17:55:48 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-04-04 17:55:48 +0000
commitb54f879f3539c298646449ede2e8d458fc305605 (patch)
tree69b852c9896b8efb214a2a208efeb825cf56c2c9 /src/xline.cpp
parent38749462c62a659b7006976c2c7c4da6ac6d0df7 (diff)
Added E:Lines, a form of ban exception that can prevent opers, netadmins etc from being glined. Can be added and removed
either in the config or by an oper with the correct permissions to use the /ELINE command git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@975 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/xline.cpp')
-rw-r--r--src/xline.cpp79
1 files changed, 77 insertions, 2 deletions
diff --git a/src/xline.cpp b/src/xline.cpp
index 15032b32a..ce6257a66 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -186,6 +186,7 @@ std::vector<KLine> klines;
std::vector<GLine> glines;
std::vector<ZLine> zlines;
std::vector<QLine> qlines;
+std::vector<ELine> elines;
// Reads the default bans from the config file.
// only a very small number of bans are defined
@@ -222,6 +223,13 @@ void read_xline_defaults()
add_kline(0,"<Config>",reason,host);
log(DEBUG,"Read K line (badhost tag): host=%s reason=%s",host,reason);
}
+ for (int i = 0; i < ConfValueEnum("exception",&config_f); i++)
+ {
+ ConfValue("exception","host",i,host,&config_f);
+ ConfValue("exception","reason",i,reason,&config_f);
+ add_eline(0,"<Config>",reason,host);
+ log(DEBUG,"Read E line (exception tag): host=%s reason=%s",host,reason);
+ }
}
// adds a g:line
@@ -239,6 +247,21 @@ void add_gline(long duration, char* source, char* reason, char* hostmask)
glines.push_back(item);
}
+// adds an e:line (exception to bans)
+
+void add_eline(long duration, char* source, char* reason, char* hostmask)
+{
+ del_eline(hostmask);
+ ELine item;
+ item.duration = duration;
+ strlcpy(item.hostmask,hostmask,MAXBUF);
+ strlcpy(item.reason,reason,MAXBUF);
+ strlcpy(item.source,source,MAXBUF);
+ item.n_matches = 0;
+ item.set_time = time(NULL);
+ elines.push_back(item);
+}
+
// adds a q:line
void add_qline(long duration, char* source, char* reason, char* nickname)
@@ -301,6 +324,21 @@ bool del_gline(char* hostmask)
return false;
}
+// deletes a e:line, returns true if the line existed and was removed
+
+bool del_eline(char* hostmask)
+{
+ for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
+ {
+ if (!strcasecmp(hostmask,i->hostmask))
+ {
+ elines.erase(i);
+ return true;
+ }
+ }
+ return false;
+}
+
// deletes a q:line, returns true if the line existed and was removed
bool del_qline(char* nickname)
@@ -430,6 +468,21 @@ char* matches_gline(const char* host)
return NULL;
}
+char* matches_exception(const char* host)
+{
+ char host2[MAXBUF];
+ snprintf(host2,MAXBUF,"*@%s",host);
+ for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
+ {
+ if ((match(host,i->hostmask)) || (match(host2,i->hostmask)))
+ {
+ return i->reason;
+ }
+ }
+ return NULL;
+}
+
+
void gline_set_creation_time(char* host, time_t create_time)
{
for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
@@ -521,6 +574,17 @@ void expire_lines()
}
}
+ for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
+ {
+ if ((current > (i->duration + i->set_time)) && (i->duration > 0))
+ {
+ WriteOpers("Expiring timed E-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
+ elines.erase(i);
+ go_again = true;
+ break;
+ }
+ }
+
for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
{
if ((current > (i->duration + i->set_time)) && (i->duration > 0))
@@ -575,6 +639,12 @@ void apply_lines()
if (!strcasecmp(u->second->server,ServerName))
{
snprintf(host,MAXBUF,"%s@%s",u->second->ident,u->second->host);
+ if (elines.size())
+ {
+ // ignore people matching exempts
+ if (matches_exception(host))
+ continue;
+ }
if (glines.size())
{
char* check = matches_gline(host);
@@ -660,5 +730,10 @@ void stats_z(userrec* user)
}
}
-
-
+void stats_e(userrec* user)
+{
+ for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
+ {
+ WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
+ }
+}