diff options
author | Robin Burchell w00t@inspircd.org <Robin Burchell w00t@inspircd.org@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-09-30 21:54:22 +0000 |
---|---|---|
committer | Robin Burchell w00t@inspircd.org <Robin Burchell w00t@inspircd.org@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-09-30 21:54:22 +0000 |
commit | f70f57219f010962cef8779734deefc1ef355913 (patch) | |
tree | b5eb5a539024bf9213a2b5433bf7ca3cf356cdf5 /src | |
parent | 0464e2eb14e0c5becc7ebeb7f494f7941d556ca9 (diff) |
Merge commit 'trunk' into anopeng
Conflicts:
src/process.c
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1279 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r-- | src/core/os_ignore.c | 1 | ||||
-rw-r--r-- | src/messages.c | 2 | ||||
-rw-r--r-- | src/process.c | 171 |
3 files changed, 95 insertions, 79 deletions
diff --git a/src/core/os_ignore.c b/src/core/os_ignore.c index ffac6b036..b6d47764a 100644 --- a/src/core/os_ignore.c +++ b/src/core/os_ignore.c @@ -95,7 +95,6 @@ int do_ignoreuser(User * u) notice_lang(s_OperServ, u, OPER_IGNORE_VALID_TIME); return MOD_CONT; } else if (t == 0) { - t = 157248000; /* if 0 is given, we set time to 157248000 seconds == 5 years (let's hope the next restart will be before that time ;-)) */ add_ignore(nick, t); notice_lang(s_OperServ, u, OPER_IGNORE_PERM_DONE, nick); } else { diff --git a/src/messages.c b/src/messages.c index db81fdc80..6b119bd8f 100644 --- a/src/messages.c +++ b/src/messages.c @@ -136,7 +136,7 @@ int m_privmsg(const char *source, const char *receiver, const char *msg) /* Check if we should ignore. Operators always get through. */ if (allow_ignore && !is_oper(u)) { IgnoreData *ign = get_ignore(source); - if (ign && ign->time > time(NULL)) { + if (ign) { alog("Ignored message from %s: \"%s\"", source, inbuf); return MOD_CONT; } diff --git a/src/process.c b/src/process.c index 8cb4f14bc..552bb93b8 100644 --- a/src/process.c +++ b/src/process.c @@ -27,38 +27,46 @@ IgnoreData *ignore; /*************************************************************************/ /** - * Add a mask/nick to the ignorelits for delta seconds. - * @param nick Nick or (nick!)user@host to add to the ignorelist. - * @param delta Seconds untill new entry is set to expire. + * Add a mask/nick to the ignorelits for delta seconds.
+ * @param nick Nick or (nick!)user@host to add to the ignorelist.
+ * @param delta Seconds untill new entry is set to expire. 0 for permanent.
*/ void add_ignore(const char *nick, time_t delta) { IgnoreData *ign; char tmp[BUFSIZE]; char *mask, *user, *host; - time_t now = time(NULL); - if (!nick) + User *u; + time_t now; +
if (!nick) return; - - /* Determine whether we get a nick or a mask. */ - if ((host = strchr(nick, '@'))) { - /* Check whether we have a nick too.. */ + now = time(NULL); +
+ /* If it s an existing user, we ignore the hostmask. */
+ if ((u = finduser(nick))) { + snprintf(tmp, sizeof(tmp), "*!*@%s", u->host); + mask = sstrdup(tmp); +
+ /* Determine whether we get a nick or a mask. */
+ } else if ((host = strchr(nick, '@'))) { + /* Check whether we have a nick too.. */
if ((user = strchr(nick, '!'))) { - /* this should never happen */ + /* this should never happen */
if (user > host) return; mask = sstrdup(nick); } else { - /* We have user@host. Add nick wildcard. */ + /* We have user@host. Add nick wildcard. */
snprintf(tmp, sizeof(tmp), "*!%s", nick); mask = sstrdup(tmp); } +
+ /* We only got a nick.. */
} else { - /* We only got a nick.. */ - snprintf(tmp, sizeof(tmp), "%s!*@*", nick); +
snprintf(tmp, sizeof(tmp), "%s!*@*", nick); mask = sstrdup(tmp); } - +
/* Check if we already got an identical entry. */ for (ign = ignore; ign; ign = ign->next) if (stricmp(ign->mask, mask) == 0) @@ -66,13 +74,15 @@ void add_ignore(const char *nick, time_t delta) /* Found one.. */ if (ign) { - if (ign->time < now + delta) + if (delta == 0) + ign->time = 0; + else if (ign->time < now + delta) ign->time = now + delta; /* Create new entry.. */ } else { ign = (IgnoreData *)scalloc(sizeof(*ign), 1); ign->mask = mask; - ign->time = now + delta; + ign->time = (delta == 0 ? 0 : now + delta); ign->prev = NULL; ign->next = ignore; if (ignore) @@ -87,9 +97,9 @@ void add_ignore(const char *nick, time_t delta) /** * Retrieve an ignorance record for a nick or mask. - * If the nick isn't being ignored, we return NULL and if necesary - * flush the record from the in-core list (i.e. ignore timed out). - * @param nick Nick or (nick!)user@host to look for on the ignorelist. + * If the nick isn't being ignored, we return NULL and if necesary + * flush the record from the ignore list (i.e. ignore timed out). + * @param nick Nick or (nick!)user@host to look for on the ignorelist.
* @return Pointer to the ignore record, NULL if none was found. */ IgnoreData *get_ignore(const char *nick) @@ -97,49 +107,53 @@ IgnoreData *get_ignore(const char *nick) IgnoreData *ign; char tmp[BUFSIZE]; char *user, *host; - time_t now = time(NULL); - User *u = finduser(nick); - if (!nick) + time_t now; + User *u; +
if (!nick) return NULL; - /* User has disabled the IGNORE system */ +
+ /* User has disabled the IGNORE system */ if (!allow_ignore) return NULL; - /* If we found a real user, match his mask against the ignorelist. */ +
now = time(NULL); +
u = finduser(nick); +
+ /* If we find a real user, match his mask against the ignorelist. */ if (u) { - /* Opers are not ignored, even if a matching entry may be present. */ + /* Opers are not ignored, even if a matching entry may be present. */ if (is_oper(u)) return NULL; for (ign = ignore; ign; ign = ign->next) if (match_usermask(ign->mask, u)) break; - } else { - /* We didn't get a user.. generate a valid mask. */ +
} else { + /* We didn't get a user.. generate a valid mask. */
if ((host = strchr(nick, '@'))) { if ((user = strchr(nick, '!'))) { - /* this should never happen */ + /* this should never happen */ if (user > host) return NULL; snprintf(tmp, sizeof(tmp), "%s", nick); } else { - /* We have user@host. Add nick wildcard. */ + /* We have user@host. Add nick wildcard. */
snprintf(tmp, sizeof(tmp), "*!%s", nick); } - } else { - /* We only got a nick.. */ - snprintf(tmp, sizeof(tmp), "%s!*@*", nick); - } - for (ign = ignore; ign; ign = ign->next) +
+ /* We only got a nick.. */
+ } else +
snprintf(tmp, sizeof(tmp), "%s!*@*", nick); +
for (ign = ignore; ign; ign = ign->next) if (match_wild_nocase(ign->mask, tmp)) break; } - - /* Check whether the entry has timed out */ - if (ign && ign->time <= now) { +
+ /* Check whether the entry has timed out */
+ if (ign && ign->time != 0 && ign->time <= now) { if (debug) alog("debug: Expiring ignore entry %s", ign->mask); if (ign->prev) ign->prev->next = ign->next; - else if (ignore == ign) + else if (ignore == ign) ignore = ign->next; if (ign->next) ign->next->prev = ign->prev; @@ -147,7 +161,7 @@ IgnoreData *get_ignore(const char *nick) free(ign); ign = NULL; } - if (ign && debug) +
if (ign && debug) alog("debug: Found ignore entry (%s) for %s", ign->mask, nick); return ign; } @@ -162,67 +176,71 @@ IgnoreData *get_ignore(const char *nick) */ int delete_ignore(const char *nick) { - IgnoreData * ign; + IgnoreData *ign; char tmp[BUFSIZE]; char *user, *host; - if (!nick) + User *u; +
if (!nick) return 0; - - /* Determine whether we get a nick or a mask. */ - if ((host = strchr(nick, '@'))) { - /* Check whether we have a nick too.. */ +
+ /* If it s an existing user, we ignore the hostmask. */
+ if ((u = finduser(nick))) { + snprintf(tmp, sizeof(tmp), "*!*@%s", u->host); +
+ /* Determine whether we get a nick or a mask. */
+ } else if ((host = strchr(nick, '@'))) { + /* Check whether we have a nick too.. */
if ((user = strchr(nick, '!'))) { - /* this should never happen */ + /* this should never happen */
if (user > host) return 0; snprintf(tmp, sizeof(tmp), "%s", nick); } else { - /* We have user@host. Add nick wildcard. */ + /* We have user@host. Add nick wildcard. */
snprintf(tmp, sizeof(tmp), "*!%s", nick); } - } else { - /* We only got a nick.. */ - snprintf(tmp, sizeof(tmp), "%s!*@*", nick); - } +
+ /* We only got a nick.. */
+ } else +
snprintf(tmp, sizeof(tmp), "%s!*@*", nick); + for (ign = ignore; ign; ign = ign->next) if (stricmp(ign->mask, tmp) == 0) break; - - /* No matching ignore found. */ +
+ /* No matching ignore found. */
if (!ign) return 0; - if (debug) +
if (debug) alog("Deleting ignore entry %s", ign->mask); - - /* Delete the entry and all references to it. */ +
+ /* Delete the entry and all references to it. */
if (ign->prev) ign->prev->next = ign->next; - else if (ignore == ign) + else if (ignore == ign) ignore = ign->next; if (ign->next) ign->next->prev = ign->prev; - free(ign->mask); +
free(ign->mask); free(ign); ign = NULL; - return 1; - -} - - - -/*************************************************************************/ - -/** - * Clear the ignorelist. - * @return The number of entries deleted. - */ -int clear_ignores() +
return 1; +
} + +
+/*************************************************************************/
+
+/**
+ * Clear the ignorelist.
+ * @return The number of entries deleted.
+ */
+int clear_ignores()
{ - IgnoreData * ign, *next; + IgnoreData *ign, *next; int i = 0; - if (!ignore) +
if (!ignore) return 0; - for (ign = ignore; ign; ign = next) { +
for (ign = ignore; ign; ign = next) { next = ign->next; if (debug) alog("Deleting ignore entry %s", ign->mask); @@ -230,10 +248,9 @@ int clear_ignores() free(ign); i++; } - ignore = NULL; +
ignore = NULL; return i; - -} +
} /*************************************************************************/ |