|
@@ -574,8 +574,9 @@ static bool detect_chan_flood(memberlist* m, const char *from, struct chanset_t
|
|
|
)))
|
|
)))
|
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
|
|
- char h[UHOSTLEN] = "", ftype[12] = "", *p = NULL;
|
|
|
|
|
|
|
+ char h[UHOSTLEN] = "", ftype[14] = "", *p = NULL;
|
|
|
int thr = 0;
|
|
int thr = 0;
|
|
|
|
|
+ int increment = 1;
|
|
|
time_t lapse = 0;
|
|
time_t lapse = 0;
|
|
|
|
|
|
|
|
/* Determine how many are necessary to make a flood. */
|
|
/* Determine how many are necessary to make a flood. */
|
|
@@ -586,6 +587,12 @@ static bool detect_chan_flood(memberlist* m, const char *from, struct chanset_t
|
|
|
lapse = chan->flood_pub_time;
|
|
lapse = chan->flood_pub_time;
|
|
|
strlcpy(ftype, "pub", sizeof(ftype));
|
|
strlcpy(ftype, "pub", sizeof(ftype));
|
|
|
break;
|
|
break;
|
|
|
|
|
+ case FLOOD_BYTES:
|
|
|
|
|
+ thr = chan->flood_bytes_thr;
|
|
|
|
|
+ lapse = chan->flood_bytes_time;
|
|
|
|
|
+ strlcpy(ftype, "bytes", sizeof(ftype));
|
|
|
|
|
+ increment = static_cast<int>(strlen(msg));
|
|
|
|
|
+ break;
|
|
|
case FLOOD_CTCP:
|
|
case FLOOD_CTCP:
|
|
|
thr = chan->flood_ctcp_thr;
|
|
thr = chan->flood_ctcp_thr;
|
|
|
lapse = chan->flood_ctcp_time;
|
|
lapse = chan->flood_ctcp_time;
|
|
@@ -637,7 +644,7 @@ static bool detect_chan_flood(memberlist* m, const char *from, struct chanset_t
|
|
|
// If not found, add them and start the count for next iteration
|
|
// If not found, add them and start the count for next iteration
|
|
|
if (!chan->channel.floodtime->contains(m->userhost)) {
|
|
if (!chan->channel.floodtime->contains(m->userhost)) {
|
|
|
(*chan->channel.floodtime)[m->userhost][which] = now;
|
|
(*chan->channel.floodtime)[m->userhost][which] = now;
|
|
|
- (*chan->channel.floodnum)[m->userhost][which] = 1;
|
|
|
|
|
|
|
+ (*chan->channel.floodnum)[m->userhost][which] = increment;
|
|
|
return 0;
|
|
return 0;
|
|
|
} else {
|
|
} else {
|
|
|
floodtime = &(*chan->channel.floodtime)[m->userhost];
|
|
floodtime = &(*chan->channel.floodtime)[m->userhost];
|
|
@@ -649,7 +656,7 @@ static bool detect_chan_flood(memberlist* m, const char *from, struct chanset_t
|
|
|
// If not found, add them and start the count for next iteration
|
|
// If not found, add them and start the count for next iteration
|
|
|
if (!m->floodtime->contains(which)) {
|
|
if (!m->floodtime->contains(which)) {
|
|
|
(*m->floodtime)[which] = now;
|
|
(*m->floodtime)[which] = now;
|
|
|
- (*m->floodnum)[which] = 1;
|
|
|
|
|
|
|
+ (*m->floodnum)[which] = increment;
|
|
|
return 0;
|
|
return 0;
|
|
|
} else {
|
|
} else {
|
|
|
floodtime = m->floodtime;
|
|
floodtime = m->floodtime;
|
|
@@ -661,10 +668,11 @@ static bool detect_chan_flood(memberlist* m, const char *from, struct chanset_t
|
|
|
if ((*floodtime)[which] < now - lapse) {
|
|
if ((*floodtime)[which] < now - lapse) {
|
|
|
/* Flood timer expired, reset it */
|
|
/* Flood timer expired, reset it */
|
|
|
(*floodtime)[which] = now;
|
|
(*floodtime)[which] = now;
|
|
|
- (*floodnum)[which] = 1;
|
|
|
|
|
|
|
+ (*floodnum)[which] = increment;
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
- (*floodnum)[which]++;
|
|
|
|
|
|
|
+ (*floodnum)[which] += increment;
|
|
|
|
|
+
|
|
|
if ((*floodnum)[which] >= thr) { /* FLOOD */
|
|
if ((*floodnum)[which] >= thr) { /* FLOOD */
|
|
|
/* Reset counters */
|
|
/* Reset counters */
|
|
|
(*floodnum).remove(which);
|
|
(*floodnum).remove(which);
|
|
@@ -673,6 +681,7 @@ static bool detect_chan_flood(memberlist* m, const char *from, struct chanset_t
|
|
|
case FLOOD_PRIVMSG:
|
|
case FLOOD_PRIVMSG:
|
|
|
case FLOOD_NOTICE:
|
|
case FLOOD_NOTICE:
|
|
|
case FLOOD_CTCP:
|
|
case FLOOD_CTCP:
|
|
|
|
|
+ case FLOOD_BYTES:
|
|
|
/* Flooding chan! either by public or notice */
|
|
/* Flooding chan! either by public or notice */
|
|
|
if (!chan_sentkick(m) && me_op(chan)) {
|
|
if (!chan_sentkick(m) && me_op(chan)) {
|
|
|
if (channel_floodban(chan)) {
|
|
if (channel_floodban(chan)) {
|
|
@@ -705,7 +714,7 @@ static bool detect_chan_flood(memberlist* m, const char *from, struct chanset_t
|
|
|
putlog(LOG_MISC | LOG_JOIN, chan->dname, "JOIN flood from @%s! Banning.", p);
|
|
putlog(LOG_MISC | LOG_JOIN, chan->dname, "JOIN flood from @%s! Banning.", p);
|
|
|
else
|
|
else
|
|
|
putlog(LOG_MISC | LOG_JOIN, chan->dname, "NICK flood from @%s! Banning.", p);
|
|
putlog(LOG_MISC | LOG_JOIN, chan->dname, "NICK flood from @%s! Banning.", p);
|
|
|
- strlcpy(ftype + 4, " flood", sizeof(ftype) - 4);
|
|
|
|
|
|
|
+ strlcat(ftype, " flood", sizeof(ftype));
|
|
|
u_addmask('b', chan, h, conf.bot->nick, ftype, now + (60 * chan->ban_time), 0);
|
|
u_addmask('b', chan, h, conf.bot->nick, ftype, now + (60 * chan->ban_time), 0);
|
|
|
if (which == FLOOD_PART)
|
|
if (which == FLOOD_PART)
|
|
|
add_mode(chan, '+', 'b', h);
|
|
add_mode(chan, '+', 'b', h);
|
|
@@ -3203,6 +3212,7 @@ static int gotmsg(char *from, char *msg)
|
|
|
strcpy(p1 - 1, p + 1);
|
|
strcpy(p1 - 1, p + 1);
|
|
|
if (m) {
|
|
if (m) {
|
|
|
detect_chan_flood(m, from, chan, strncmp(ctcp, "ACTION ", 7) ? FLOOD_CTCP : FLOOD_PRIVMSG);
|
|
detect_chan_flood(m, from, chan, strncmp(ctcp, "ACTION ", 7) ? FLOOD_CTCP : FLOOD_PRIVMSG);
|
|
|
|
|
+ detect_chan_flood(m, from, chan, FLOOD_BYTES, msg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* Respond to the first answer_ctcp */
|
|
/* Respond to the first answer_ctcp */
|
|
@@ -3254,6 +3264,7 @@ static int gotmsg(char *from, char *msg)
|
|
|
|
|
|
|
|
if (m) {
|
|
if (m) {
|
|
|
detect_chan_flood(m, from, chan, FLOOD_PRIVMSG);
|
|
detect_chan_flood(m, from, chan, FLOOD_PRIVMSG);
|
|
|
|
|
+ detect_chan_flood(m, from, chan, FLOOD_BYTES, msg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (auth_chan) {
|
|
if (auth_chan) {
|
|
@@ -3350,6 +3361,7 @@ static int gotnotice(char *from, char *msg)
|
|
|
p = strchr(msg, 1);
|
|
p = strchr(msg, 1);
|
|
|
if (m) {
|
|
if (m) {
|
|
|
detect_chan_flood(m, from, chan, strncmp(ctcp, "ACTION ", 7) ? FLOOD_CTCP : FLOOD_PRIVMSG);
|
|
detect_chan_flood(m, from, chan, strncmp(ctcp, "ACTION ", 7) ? FLOOD_CTCP : FLOOD_PRIVMSG);
|
|
|
|
|
+ detect_chan_flood(m, from, chan, FLOOD_BYTES, msg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (ctcp[0] != ' ') {
|
|
if (ctcp[0] != ' ') {
|
|
@@ -3369,6 +3381,7 @@ static int gotnotice(char *from, char *msg)
|
|
|
if (msg[0]) {
|
|
if (msg[0]) {
|
|
|
if (m) {
|
|
if (m) {
|
|
|
detect_chan_flood(m, from, chan, FLOOD_NOTICE);
|
|
detect_chan_flood(m, from, chan, FLOOD_NOTICE);
|
|
|
|
|
+ detect_chan_flood(m, from, chan, FLOOD_BYTES, msg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
update_idle(chan->dname, nick);
|
|
update_idle(chan->dname, nick);
|