diff options
-rw-r--r-- | Changes | 1 | ||||
-rw-r--r-- | Changes.lang | 11 | ||||
-rw-r--r-- | include/extern.h | 4 | ||||
-rw-r--r-- | include/services.h | 5 | ||||
-rw-r--r-- | lang/cat.l | 20 | ||||
-rw-r--r-- | lang/de.l | 34 | ||||
-rw-r--r-- | lang/en_us.l | 29 | ||||
-rw-r--r-- | lang/es.l | 20 | ||||
-rw-r--r-- | lang/fr.l | 20 | ||||
-rw-r--r-- | lang/gr.l | 20 | ||||
-rw-r--r-- | lang/hun.l | 20 | ||||
-rw-r--r-- | lang/it.l | 20 | ||||
-rw-r--r-- | lang/nl.l | 20 | ||||
-rw-r--r-- | lang/pl.l | 22 | ||||
-rw-r--r-- | lang/pt.l | 20 | ||||
-rw-r--r-- | lang/ru.l | 20 | ||||
-rw-r--r-- | lang/tr.l | 20 | ||||
-rw-r--r-- | src/mysql.c | 29 | ||||
-rw-r--r-- | src/sessions.c | 472 | ||||
-rw-r--r-- | version.log | 6 |
20 files changed, 300 insertions, 513 deletions
@@ -41,6 +41,7 @@ Provided by Anope Dev. <dev@anope.org> - 2006 06/21 F Syntax for NickServ SET MSG showed syntax for SET PRIVATE. [ #00] 06/26 F A few small bugs with module configure scripts. [ #00] 07/02 F Fixed readonly stuff on memoserv del. [#529] +07/04 F Rewrote exception system due to a bug we couldn't track down. [#491] Provided by ThaPrince <jon@vile.com> - 2006 05/19 A Plexus 3 support. [ #00] diff --git a/Changes.lang b/Changes.lang index bf8c6527b..3c20094af 100644 --- a/Changes.lang +++ b/Changes.lang @@ -4,8 +4,19 @@ Anope Version S V N INVALID_TARGET *** Mod Strings: +OPER_EXCEPTION_LIST_FORMAT +OPER_EXCEPTION_LIST_COLHEAD +OPER_EXCEPTION_DEL_SYNTAX +OPER_EXCEPTION_SYNTAX +OPER_EXCEPTION_VIEW_FORMAT *** Del Strings: +OPER_EXCEPTION_MOVE_SYNTAX +OPER_EXCEPTION_MOVED +OPER_EXCEPTION_DELETED_ONE +OPER_EXCEPTION_DELETED_SEVERAL +OPER_EXCEPTION_NO_SUCH_ENTRY + Anope Version 1.7.14 -------------------- diff --git a/include/extern.h b/include/extern.h index ad6274754..488896779 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1016,7 +1016,7 @@ E void finish_sync(Server *serv, int sync_links); /**** sessions.c ****/ -E Exception *exceptions; +E Exception *exceptionlist[1024]; E int16 nexceptions; E Session *sessionlist[1024]; @@ -1038,7 +1038,7 @@ E void expire_exceptions(void); E Session *findsession(const char *host); E Exception *find_host_exception(const char *host); -E int exception_add(User * u, const char *mask, const int limit, +E Exception *exception_add(User * u, const char *mask, const int limit, const char *reason, const char *who, const time_t expires); diff --git a/include/services.h b/include/services.h index 2ee228233..b40d7e785 100644 --- a/include/services.h +++ b/include/services.h @@ -1069,16 +1069,13 @@ struct newsitem_ { struct exception_ { + Exception *prev, *next; char *mask; /* Hosts to which this exception applies */ int limit; /* Session limit for exception */ char who[NICKMAX]; /* Nick of person who added the exception */ char *reason; /* Reason for exception's addition */ time_t time; /* When this exception was added */ time_t expires; /* Time when it expires. 0 == no expiry */ - int num; /* Position in exception list; used to track - * positions when deleting entries. It is - * symbolic and used internally. It is - * calculated at load time and never saved. */ }; /*************************************************************************/ diff --git a/lang/cat.l b/lang/cat.l index bfac46693..9a9cbe230 100644 --- a/lang/cat.l +++ b/lang/cat.l @@ -3052,13 +3052,11 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [parametres] + EXCEPTION {ADD | DEL | LIST | VIEW} [parametres] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+expiració] mascara límit raó OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {mascara | llista} -OPER_EXCEPTION_MOVE_SYNTAX - EXCEPTION MOVE numero posició + EXCEPTION DEL {mascara} OPER_EXCEPTION_DISABLED Límits de sessions no disponibles. OPER_EXCEPTION_ALREADY_PRESENT @@ -3067,30 +3065,22 @@ OPER_EXCEPTION_TOO_MANY La llista d'excepcions al límit de sessiones esta plena! OPER_EXCEPTION_ADDED Límit de sessió per a %s establert a %d. -OPER_EXCEPTION_MOVED - Excepció per a %s (#%d) moguda a la posició %d. -OPER_EXCEPTION_NO_SUCH_ENTRY - La instància no existeix (#%d) a la llista d'excepcions al límit de sessions. OPER_EXCEPTION_NOT_FOUND %s no trobat a a la llista d'excepcions al límit de sessions. OPER_EXCEPTION_NO_MATCH No existeixen instàncies similars a la llista d'excepcions al límit de sessions. OPER_EXCEPTION_DELETED %s instàncies esborrades de la llista d'excepcions al límit de sessions. -OPER_EXCEPTION_DELETED_ONE - 1 instància esborrada de la llista d'excepcions al límit de sessions. -OPER_EXCEPTION_DELETED_SEVERAL - %d instàncies esborrades de la llista d'excepcions al límit de sessions. OPER_EXCEPTION_LIST_HEADER llista d'excepcions al límit de sessions actual: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %3d %4d %s + %4d %s OPER_EXCEPTION_LIST_COLHEAD - Num Límit Host + Límit Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %3d. %s (per %s a %s; %s) + %s (per %s a %s; %s) Límit: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Límit de sessió invàlid. Ha de ser un sencer vàlido més gran o igual a zero i mes petit que %d. @@ -2998,13 +2998,11 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [Parameter] + EXCEPTION {ADD | DEL | LIST | VIEW} [Parameter] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+Zeit] Hostmaske Limit Grund OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {Hostmaske | Liste} -OPER_EXCEPTION_MOVE_SYNTAX - EXCEPTION MOVE Nummer Position + EXCEPTION DEL {Hostmaske} OPER_EXCEPTION_DISABLED Eingeschränkte Verbindungen sind deaktiviert. OPER_EXCEPTION_ALREADY_PRESENT @@ -3013,11 +3011,6 @@ OPER_EXCEPTION_TOO_MANY Die Liste für eingeschränkte Verbindungen ist voll! OPER_EXCEPTION_ADDED Verbindungslimit für %s geändert auf %d. -OPER_EXCEPTION_MOVED - DIe Exception für %s (#%d) wurde auf die %d Position verschoben. -OPER_EXCEPTION_NO_SUCH_ENTRY - Kein solcher Eintrag (#%d) in der Liste der Verbindungs- - einschränkungen. OPER_EXCEPTION_NOT_FOUND %s nicht gefunden in der Liste der Verbindungs- einschränkungen. @@ -3027,22 +3020,16 @@ OPER_EXCEPTION_NO_MATCH OPER_EXCEPTION_DELETED %s wurde von der Liste der Verbindungseinschränkungen entfernt. -OPER_EXCEPTION_DELETED_ONE - Es wurde 1 Eintrag von der Liste der Verbindungs- - einschränkungen entfernt. -OPER_EXCEPTION_DELETED_SEVERAL - Es wurden %d Einträge von der Liste der Verbindungs- - einschränkungen entfernt. OPER_EXCEPTION_LIST_HEADER Aktuelle Liste für eingeschränkte Verbindungen: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %3d %4d %s + %4d %s OPER_EXCEPTION_LIST_COLHEAD - Nummer Limit Host + Limit Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %3d. %s (von %s am %s, %s) + %s (von %s am %s, %s) Limit: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Ungültige Verbindungseinschränkung. Es muss eine gültige Integer-Zahl sein, grösser oder gleich @@ -3082,10 +3069,9 @@ OPER_SESSION_VIEW_FORMAT OPER_HELP_EXCEPTION Syntax: EXCEPTION ADD [+Zeit] Hostmaske Limit Grund - EXCEPTION DEL {Hostmaske | Liste} - EXCEPTION MOVE Nummer Position - EXCEPTION LIST [Hostmaske | Liste] - EXCEPTION VIEW [Hostmaske | Liste] + EXCEPTION DEL {Hostmaske] + EXCEPTION LIST [Hostmaske] + EXCEPTION VIEW [Hostmaske] Erlaubt Services Administratoren, die Liste der Verbindungs- einschränkungen zu bearbeiten.Dadurch ist es möglich @@ -3112,10 +3098,6 @@ OPER_HELP_EXCEPTION EXCEPTION DEL entfernt den Host von der Liste. - EXCEPTION MOVE verschiebt den Eintrag mit der Nummer - auf die Position. Die Einträge dazwischen werden - hoch bzw runtergeschoben um die Lücken zu füllen. - EXCEPTION LIST und EXCEPTION VIEW zeigt alle aktuellen Verbindungseinschränkungen. Wird die optionale Hostmaske angegeben, werden nur die entsprechenden Einträge aus diff --git a/lang/en_us.l b/lang/en_us.l index 5aae18c2d..a3dd37b35 100644 --- a/lang/en_us.l +++ b/lang/en_us.l @@ -2938,13 +2938,11 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [params] + EXCEPTION {ADD | DEL | LIST | VIEW} [params] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+expiry] mask limit reason OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {mask | list} -OPER_EXCEPTION_MOVE_SYNTAX - EXCEPTION MOVE num position + EXCEPTION DEL {mask} OPER_EXCEPTION_DISABLED Session limiting is disabled. OPER_EXCEPTION_ALREADY_PRESENT @@ -2953,30 +2951,22 @@ OPER_EXCEPTION_TOO_MANY Session-limit exception list is full! OPER_EXCEPTION_ADDED Session limit for %s set to %d. -OPER_EXCEPTION_MOVED - Exception for %s (#%d) moved to position %d. -OPER_EXCEPTION_NO_SUCH_ENTRY - No such entry (#%d) session-limit exception list. OPER_EXCEPTION_NOT_FOUND %s not found on session-limit exception list. OPER_EXCEPTION_NO_MATCH No matching entries on session-limit exception list. OPER_EXCEPTION_DELETED %s deleted from session-limit exception list. -OPER_EXCEPTION_DELETED_ONE - Deleted 1 entry from session-limit exception list. -OPER_EXCEPTION_DELETED_SEVERAL - Deleted %d entries from session-limit exception list. OPER_EXCEPTION_LIST_HEADER Current Session Limit Exception list: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %3d %4d %s + %4d %s OPER_EXCEPTION_LIST_COLHEAD - Num Limit Host + Limit Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %3d. %s (by %s on %s; %s) + %s (by %s on %s; %s) Limit: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Invalid session limit. It must be a valid integer greater than or equal to zero and less than %d. @@ -3015,10 +3005,9 @@ OPER_SESSION_VIEW_FORMAT OPER_HELP_EXCEPTION Syntax: EXCEPTION ADD [+expiry] mask limit reason - EXCEPTION DEL {mask | list} - EXCEPTION MOVE num position - EXCEPTION LIST [mask | list] - EXCEPTION VIEW [mask | list] + EXCEPTION DEL {mask} + EXCEPTION LIST [mask] + EXCEPTION VIEW [mask] Allows Services admins to manipulate the list of hosts that have specific session limits - allowing certain machines, @@ -3039,8 +3028,6 @@ OPER_HELP_EXCEPTION unlimited session limit. See the AKILL help for details about the format of the optional expiry parameter. EXCEPTION DEL removes the given mask from the exception list. - EXCEPTION MOVE moves exception num to position. The - exceptions inbetween will be shifted up or down to fill the gap. EXCEPTION LIST and EXCEPTION VIEW show all current exceptions; if the optional mask is given, the list is limited to those exceptions matching the mask. The difference is that @@ -3026,13 +3026,11 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [parametros] + EXCEPTION {ADD | DEL | LIST | VIEW} [parametros] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+expiracion] mascara limite razon OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {mascara | lista} -OPER_EXCEPTION_MOVE_SYNTAX - EXCEPTION MOVE numero posicion + EXCEPTION DEL {mascara} OPER_EXCEPTION_DISABLED Limites de sesion no disponibles. OPER_EXCEPTION_ALREADY_PRESENT @@ -3041,30 +3039,22 @@ OPER_EXCEPTION_TOO_MANY La lista de excepciones al limite de sesiones esta llena! OPER_EXCEPTION_ADDED Limite de sesion para %s seteado a %d. -OPER_EXCEPTION_MOVED - Excepcion para %s (#%d) movido a la posicion %d. -OPER_EXCEPTION_NO_SUCH_ENTRY - La instancia no existe (#%d) en la lista de excepciones al limite de sesiones. OPER_EXCEPTION_NOT_FOUND %s no encontrado en la lista de excepciones al limite de sesiones. OPER_EXCEPTION_NO_MATCH No existen instancias similares en la lista de excepciones al limite de sesiones. OPER_EXCEPTION_DELETED %s instancias borradas de la lista de excepciones al limite de sesiones. -OPER_EXCEPTION_DELETED_ONE - 1 instancia borrada de la lista de excepciones al limite de sesiones. -OPER_EXCEPTION_DELETED_SEVERAL - %d instancias borradas de la lista de excepciones al limite de sesiones. OPER_EXCEPTION_LIST_HEADER Lista de excepciones al limite de sesiones actual: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %3d %4d %s + %4d %s OPER_EXCEPTION_LIST_COLHEAD - Num Limite Host + Limite Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %3d. %s (by %s on %s; %s) + %s (by %s on %s; %s) Limite: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Limite de sesion invalido. Debe ser un entero valido mayor o igual a cero y menor a %d. @@ -3076,13 +3076,11 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [paramètres] + EXCEPTION {ADD | DEL | LIST | VIEW} [paramètres] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+échéance] mask limite raison OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {mask | liste} -OPER_EXCEPTION_MOVE_SYNTAX - EXCEPTION MOVE num position + EXCEPTION DEL {mask} OPER_EXCEPTION_DISABLED La limitation de sessions est désactivée. OPER_EXCEPTION_ALREADY_PRESENT @@ -3091,30 +3089,22 @@ OPER_EXCEPTION_TOO_MANY La liste des exceptions à la limitation de sessions est pleine! OPER_EXCEPTION_ADDED La limite de sessions de %s est maintenant de %d. -OPER_EXCEPTION_MOVED - L'exception pour %s (#%d) a été déplacée à la position %d. -OPER_EXCEPTION_NO_SUCH_ENTRY - L'entrée %d n'existe pas sur la liste des exceptions à la limitation de sessions. OPER_EXCEPTION_NOT_FOUND %s non trouvé sur la liste des exceptions à la limitation de sessions. OPER_EXCEPTION_NO_MATCH Aucune entrée correspondante sur la liste des exceptions à la limitation de sessions. OPER_EXCEPTION_DELETED %s supprimé de la liste des exceptions à la limitation de sessions. -OPER_EXCEPTION_DELETED_ONE - 1 entrée supprimée de la liste des exceptions à la limitation de sessions. -OPER_EXCEPTION_DELETED_SEVERAL - %d entrées supprimées de la liste des exceptions à la limitation de sessions. OPER_EXCEPTION_LIST_HEADER Liste actuelle des exceptions à la limitation de sessions: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %3d %4d %s + %4d %s OPER_EXCEPTION_LIST_COLHEAD - Num Limite Host + Limite Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %3d. %s (par %s le %s; %s) + %s (par %s le %s; %s) Limite: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Limite de session invalide. Elle doit être un entier valide supérieur ou égal à zero et plus petit que %d. @@ -3054,13 +3054,11 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [params] + EXCEPTION {ADD | DEL | LIST | VIEW} [params] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+÷ñüíïò ëÞîçò] ìÜóêá üñéï ëüãïò OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {ìÜóêá | ëßóôá} -OPER_EXCEPTION_MOVE_SYNTAX - EXCEPTION MOVE íïýìåñï èÝóç + EXCEPTION DEL {ìÜóêá} OPER_EXCEPTION_DISABLED Ç Session limiting åíôïëÞ åßíáé áðåíåñãïðïéçìÝíç. OPER_EXCEPTION_ALREADY_PRESENT @@ -3069,30 +3067,22 @@ OPER_EXCEPTION_TOO_MANY Ç ëßóôá Session-limit exception åßíáé full! OPER_EXCEPTION_ADDED Session limit ãéá ôïí %s ñõèìßóôçêå óå %d. -OPER_EXCEPTION_MOVED - Exception ãéá %s (#%d) ìåôáêéíÞèçêå óôç èÝóç %d. -OPER_EXCEPTION_NO_SUCH_ENTRY - Äåí âñÝèçêå èÝóç (#%d) óôç ëßóôá session-limit exception. OPER_EXCEPTION_NOT_FOUND %s äåí âñÝèçêå óôçí ëßóôá session-limit exception. OPER_EXCEPTION_NO_MATCH Äåí âñÝèçêáí èÝóåéò óôçí ëßóôá session-limit exception. OPER_EXCEPTION_DELETED %s äéáãñÜöçêå áðü ôçí ëßóôá session-limit exception. -OPER_EXCEPTION_DELETED_ONE - ÄéáãñÜöçêå 1 èÝóç áðü ôçí ëßóôá session-limit exception. -OPER_EXCEPTION_DELETED_SEVERAL - ÄéáãñÜöçêáí %d èÝóåéò áðü ôçí ëßóôá session-limit exception. OPER_EXCEPTION_LIST_HEADER Ç Ýùò ôþñá ëßóôá Session Limit Exception åßíáé ïé åîÞò: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %3d %4d %s + %4d %s OPER_EXCEPTION_LIST_COLHEAD - Íïõ Limit Host + Limit Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %3d. %s (by %s on %s; %s) + %s (by %s on %s; %s) Limit: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT ËÜèïò session limit. ÐñÝðåé íá åßíáé ëÜèïò ï integer greater Þ ðñÝðåé íá åßíáé ìåôáîý ìçäÝí êáé %d. diff --git a/lang/hun.l b/lang/hun.l index 04a7c575e..07ed55339 100644 --- a/lang/hun.l +++ b/lang/hun.l @@ -2989,13 +2989,11 @@ MODULE_HELP_HEADER # EXCEPTION válaszok OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [paraméterek] + EXCEPTION {ADD | DEL | LIST | VIEW} [paraméterek] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+elévülés] maszk korlát indok OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {maszk | list} -OPER_EXCEPTION_MOVE_SYNTAX - EXCEPTION MOVE Szám helyzet + EXCEPTION DEL {maszk} OPER_EXCEPTION_DISABLED Session korlátozás tiltva. OPER_EXCEPTION_ALREADY_PRESENT @@ -3004,30 +3002,22 @@ OPER_EXCEPTION_TOO_MANY Session-korlát lista megtelt! OPER_EXCEPTION_ADDED Session korlát %s részére %d-re állítva. -OPER_EXCEPTION_MOVED - %s kivétel (#%d) áthelyezve a %d pozicíóba. -OPER_EXCEPTION_NO_SUCH_ENTRY - Nincs bejegyezve (#%d) session-korlát a kivétel listán. OPER_EXCEPTION_NOT_FOUND %s nem található a session-korlát kivétel listán. OPER_EXCEPTION_NO_MATCH Nincs ilyen bejegyzés a session-korlát kivétel listán. OPER_EXCEPTION_DELETED %s törölve a session-korlát kivétel listáról. -OPER_EXCEPTION_DELETED_ONE - Törölve 1 bejegyzés a session-korlát kivétel listáról. -OPER_EXCEPTION_DELETED_SEVERAL - Törölve %d bejegyzés a session-korlát kivétel listáról. OPER_EXCEPTION_LIST_HEADER Aktuális Session korlát kivétel lista: # mask, korlát OPER_EXCEPTION_LIST_FORMAT - %3d %4d %s + %4d %s OPER_EXCEPTION_LIST_COLHEAD - Szám Korlát Host + Korlát Host # maszk, set-by, set-idõ,lejárat, korlát, Indok OPER_EXCEPTION_VIEW_FORMAT - %3d. %s (%s által, ekkor: %s; %s) + %s (%s által, ekkor: %s; %s) Korlát: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Érvénytelen session korlát. Érvényes számnak kell lennie @@ -2948,13 +2948,11 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [parametri] + EXCEPTION {ADD | DEL | LIST | VIEW} [parametri] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+durata] mask limite motivo OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {mask | lista} -OPER_EXCEPTION_MOVE_SYNTAX - EXCEPTION MOVE num posizione + EXCEPTION DEL {mask} OPER_EXCEPTION_DISABLED Il limite delle sessioni è disabilitato. OPER_EXCEPTION_ALREADY_PRESENT @@ -2963,30 +2961,22 @@ OPER_EXCEPTION_TOO_MANY La lista delle eccezioni è piena! OPER_EXCEPTION_ADDED Il limite di sessioni per %s è stato impostato a %d. -OPER_EXCEPTION_MOVED - L'eccezione per %s (numero %d) è stata spostata alla posizione %d. -OPER_EXCEPTION_NO_SUCH_ENTRY - Il record specificato (%d) non esiste nella lista delle eccezioni. OPER_EXCEPTION_NOT_FOUND Impossibile trovare %s nella lista delle eccezioni. OPER_EXCEPTION_NO_MATCH Nessun record corrispondente nella lista delle eccezioni. OPER_EXCEPTION_DELETED %s eliminato dalla lista delle eccezioni. -OPER_EXCEPTION_DELETED_ONE - Eliminato 1 record dalla lista delle eccezioni. -OPER_EXCEPTION_DELETED_SEVERAL - Eliminati %d record dalla lista delle eccezioni. OPER_EXCEPTION_LIST_HEADER Lista delle eccezioni attuale: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %3d %4d %s + %4d %s OPER_EXCEPTION_LIST_COLHEAD - Num Limite Host + Limite Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %3d. %s (by %s on %s; %s) + %s (by %s on %s; %s) Limite: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Limite delle sessioni non valido. Deve essere un numero intero maggiore o uguale a zero e minore di %d. @@ -3008,13 +3008,11 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [paramenters] + EXCEPTION {ADD | DEL | LIST | VIEW} [paramenters] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+verloop] mask limiet reden OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {mask | lijst} -OPER_EXCEPTION_MOVE_SYNTAX - EXCEPTION MOVE nr positie + EXCEPTION DEL {mask} OPER_EXCEPTION_DISABLED Sessie limitering is tijdelijk uitgeschakeld. OPER_EXCEPTION_ALREADY_PRESENT @@ -3023,30 +3021,22 @@ OPER_EXCEPTION_TOO_MANY Sessie limiet uitzonderingenlijst is vol! OPER_EXCEPTION_ADDED Sessie limiet voor %s veranderd in %d. -OPER_EXCEPTION_MOVED - Uitzondering voor %s (#%d) verplaatst naar positie %d. -OPER_EXCEPTION_NO_SUCH_ENTRY - #%d bestaat niet op de sessie limiet uitzonderingenlijst. OPER_EXCEPTION_NOT_FOUND %s niet gevonden op de sessie limiet uitzonderingenlijst. OPER_EXCEPTION_NO_MATCH Geen overeenkomsten op de sessie limiet uitzonderingenlijst. OPER_EXCEPTION_DELETED %s verwijderd van de sessie limiet uitzonderingenlijst. -OPER_EXCEPTION_DELETED_ONE - 1 uitzondering verwijderd van de sessie limiet uitzonderingenlijst. -OPER_EXCEPTION_DELETED_SEVERAL - %d uitzonderingen verwijderd van de sessie limiet uitzonderingenlijst. OPER_EXCEPTION_LIST_HEADER Huidige Sessie Limiet Uitzonderingenlijst: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %3d %4d %s + %4d %s OPER_EXCEPTION_LIST_COLHEAD - Nr Limiet Host + Limiet Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %3d. %s (door %s op %s; %s) + %s (door %s op %s; %s) Limiet: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Ongeldige sessie limiet. Het moet een geldige integer groter dan of gelijk aan nul en kleiner dan %d. @@ -3203,13 +3203,11 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [params] + EXCEPTION {ADD | DEL | LIST | VIEW} [params] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+czastrwania] maska limit powód OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {maska | lista} -OPER_EXCEPTION_MOVE_SYNTAX - EXCEPTION MOVE nr pozycja + EXCEPTION DEL {maska} OPER_EXCEPTION_DISABLED Limitowanie sesji jest wy³±czone. OPER_EXCEPTION_ALREADY_PRESENT @@ -3218,11 +3216,6 @@ OPER_EXCEPTION_TOO_MANY Lista wyj±tków limitów sesji jest pe³na! OPER_EXCEPTION_ADDED Limit sesji dla %s zmieniono na %d. -OPER_EXCEPTION_MOVED - Wyj±tek dla %s (#%d) przeniesiono - na pozycje %d. -OPER_EXCEPTION_NO_SUCH_ENTRY - No such entry (#%d) session-limit exception list. OPER_EXCEPTION_NOT_FOUND %s nie znaleziono na li¶cie wyj±tków limitów sesji. @@ -3231,21 +3224,16 @@ OPER_EXCEPTION_NO_MATCH sesji. OPER_EXCEPTION_DELETED %s usuniêto z listy wyj±tków limitów sesji. -OPER_EXCEPTION_DELETED_ONE - Usuniêto 1 wpis z listy wyj±tków limitów sesji. -OPER_EXCEPTION_DELETED_SEVERAL - Usuniêto %d wpisy(ów) z listy wyj±tków limitów - sesji. OPER_EXCEPTION_LIST_HEADER Aktualna lista wyj±tków limitów sesji: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %3d %4d %s + %4d %s OPER_EXCEPTION_LIST_COLHEAD - Nr Limit Host + Limit Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %3d. %s (przez %s na %s; %s) + %s (przez %s na %s; %s) Limit: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Nieprawid³owy limit sesji. Musi byæ liczb± dodatni±, @@ -2963,13 +2963,11 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [parâmetros] + EXCEPTION {ADD | DEL | LIST | VIEW} [parâmetros] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+tempo] máscara limite motivo OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {máscara | lista} -OPER_EXCEPTION_MOVE_SYNTAX - EXCEPTION MOVE núm posição + EXCEPTION DEL {máscara} OPER_EXCEPTION_DISABLED Opção de limite de sessões desabilitada. OPER_EXCEPTION_ALREADY_PRESENT @@ -2978,30 +2976,22 @@ OPER_EXCEPTION_TOO_MANY Lista de limite de sessões está cheia! OPER_EXCEPTION_ADDED Limite de sessões para %s é agora de %d. -OPER_EXCEPTION_MOVED - Sessão para %s (#%d) alterada para a posição %d. -OPER_EXCEPTION_NO_SUCH_ENTRY - Nenhuma entrada equivalente (#%d) na lista de limite de sessões. OPER_EXCEPTION_NOT_FOUND %s não encontrado na lista de limite de sessões. OPER_EXCEPTION_NO_MATCH Nenhum resultado encontrado na lista de limite de sessões. OPER_EXCEPTION_DELETED %s removido da lista de limite de sessões. -OPER_EXCEPTION_DELETED_ONE - Removida 1 entrada da lista de limite de sessões. -OPER_EXCEPTION_DELETED_SEVERAL - Removidas %d entradas da lista de limite de sessões. OPER_EXCEPTION_LIST_HEADER Atual lista de Limite de sessões: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %3d %4d %s + %4d %s OPER_EXCEPTION_LIST_COLHEAD - Núm Limite Host + Limite Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %3d. %s (por %s em %s; %s) + %s (por %s em %s; %s) Limite: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Limite de sessão inválida. O limite deve ser um número inteiro maior ou igual a zero e menor que %d. @@ -3000,13 +3000,11 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [ïàðàìåòðû] + EXCEPTION {ADD | DEL | LIST | VIEW} [ïàðàìåòðû] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+âðåìÿ èñòå÷åíèÿ] ìàñêà ëèìèò ïðè÷èíà OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {ìàñêà | list} -OPER_EXCEPTION_MOVE_SYNTAX - EXCEPTION MOVE íîìåð ïîçèöèÿ + EXCEPTION DEL {ìàñêà} OPER_EXCEPTION_DISABLED Îãðàíè÷åíèå ñåññèé îòêëþ÷åíî. OPER_EXCEPTION_ALREADY_PRESENT @@ -3015,30 +3013,22 @@ OPER_EXCEPTION_TOO_MANY Ñïèñîê èñêëþ÷åíèé èç ëèìèòà ñåññèé ïåðåïîëíåí! OPER_EXCEPTION_ADDED Ëèìèò ñåññèé äëÿ %s óñòàíîâëåí â %d. -OPER_EXCEPTION_MOVED - Èñêëþ÷åíèå äëÿ %s (#%d) ïåðåìåùåíî â ïîçèöèþ %d. -OPER_EXCEPTION_NO_SUCH_ENTRY - Íåò òàêîé çàïèñè (#%d) â ñïèñêå èñêëþ÷åíèé èç ëèìèòâ ñåññèé. OPER_EXCEPTION_NOT_FOUND %s íå íàéäåí â ñïèñêå èñêëþ÷åíèé èç ëèìèò ñåññèé. OPER_EXCEPTION_NO_MATCH Íåò òàêèõ çíà÷åíèé â ñïèñêå èñêëþ÷åíèé èç ëèìèòà ñåññèé. OPER_EXCEPTION_DELETED %s óäàëåí èç ñïèñêà èñêëþ÷åíèé èç ëèìèòà ñåññèé. -OPER_EXCEPTION_DELETED_ONE - Óäàëåíà 1 çàïèñü èç ñïèñêà èñêëþ÷åíèé èç ëèìèòà ñåññèé. -OPER_EXCEPTION_DELETED_SEVERAL - Óäàëåíî %d çàïèñåé èç ñïèñêà èñêëþ÷åíèé èç ëèìèòà ñåññèé. OPER_EXCEPTION_LIST_HEADER Òåêóùèé ñïèñîê èñêëþ÷åíèé èç ëèìèòà ñåññèé: # ìàñêà, ëèìèò OPER_EXCEPTION_LIST_FORMAT - %3d %4d %s + %4d %s OPER_EXCEPTION_LIST_COLHEAD - Íîìåð Ëèìèò Õîñò + Ëèìèò Õîñò # ìåñêà, êåì óñòàíîâëåíî, êîãäà óñòàíîâëåíî, êîãäà èñòåêàåò, ëèìèò, ïðè÷èíà OPER_EXCEPTION_VIEW_FORMAT - %3d. %s (by %s on %s; %s) + %s (by %s on %s; %s) Ëèìèò: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Íåêîððåêòíûé ëèìèò ñåññèé. Îí äîëæåí áûòü öåëûì ÷èñëîì áîëüøå èëè ðàâíûì íóëÿ è ìåíüøå %d. @@ -3047,13 +3047,11 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [parametreler] + EXCEPTION {ADD | DEL | LIST | VIEW} [parametreler] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+zamanaþýmý] mask limit sebep OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {mask | liste} -OPER_EXCEPTION_MOVE_SYNTAX - EXCEPTION MOVE num pozisyon + EXCEPTION DEL {mask} OPER_EXCEPTION_DISABLED Session limit koyma devre dýþý. OPER_EXCEPTION_ALREADY_PRESENT @@ -3062,30 +3060,22 @@ OPER_EXCEPTION_TOO_MANY Session-limit exception listesi dolu! OPER_EXCEPTION_ADDED %s için session limit %d olarak deðiþtirildi. -OPER_EXCEPTION_MOVED - %s (#%d) için exception %d pozisyonuyla deðiþtirildi. -OPER_EXCEPTION_NO_SUCH_ENTRY - (#%d) böyle bir kayýt yok. session-limit exception listesi. OPER_EXCEPTION_NOT_FOUND %s session-limit exception listesinde bulunamadý. OPER_EXCEPTION_NO_MATCH session-limit exception listesinde uyuþan kayýt bulunamadý. OPER_EXCEPTION_DELETED %s session-limit exception listesinden silindi. -OPER_EXCEPTION_DELETED_ONE - Session-limit exception listesinden 1 kayýt silindi. -OPER_EXCEPTION_DELETED_SEVERAL - Session-limit exception listesinden %d kayýt silindi. OPER_EXCEPTION_LIST_HEADER Þu anki Session Limit Exception listesi: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %3d %4d %s + %4d %s OPER_EXCEPTION_LIST_COLHEAD - Sayý Limit Host + Limit Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %3d. %s (by %s on %s; %s) + %s (by %s on %s; %s) Limit: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Geçersiz session limiti. Sýfýrdan büyük yada eþit ve %d den az bir geçerli tamsayý olmalýdýr. diff --git a/src/mysql.c b/src/mysql.c index af319d5b6..889dcd40d 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -983,10 +983,13 @@ void db_mysql_load_news(void) mysql_free_result(mysql_res); } +#define HASH(host) (((host)[0]&31)<<5 | ((host)[1]&31)) + void db_mysql_load_exceptions(void) { char sqlcmd[MAX_SQL_BUF]; - int j; + Exception *exception; + int index; if (!do_mysql) return; @@ -1000,20 +1003,26 @@ void db_mysql_load_exceptions(void) } mysql_res = mysql_store_result(mysql); nexceptions = mysql_num_rows(mysql_res); - exceptions = scalloc(sizeof(Exception) * nexceptions, 1); - j = 0; + exception = scalloc(sizeof(Exception), 1); while ((mysql_row = mysql_fetch_row(mysql_res))) { - exceptions[j].mask = sstrdup(mysql_row[0]); - exceptions[j].limit = atoi(mysql_row[1]); - snprintf(exceptions[j].who, NICKMAX, "%s", mysql_row[2]); - exceptions[j].reason = sstrdup(mysql_row[3]); - exceptions[j].time = atoi(mysql_row[4]); - exceptions[j].expires = atoi(mysql_row[5]); - j++; + exception->mask = sstrdup(mysql_row[0]); + exception->limit = atoi(mysql_row[1]); + snprintf(exception->who, NICKMAX, "%s", mysql_row[2]); + exception->reason = sstrdup(mysql_row[3]); + exception->time = atoi(mysql_row[4]); + exception->expires = atoi(mysql_row[5]); + index = HASH(exception->mask); + exception->prev = NULL; + exception->next = exceptionlist[index]; + if (exception->next) + exception->next->prev = exception; + exceptionlist[index] = exception; } mysql_free_result(mysql_res); } +#undef HASH + #define HASH(host) ((tolower((host)[0])&31)<<5 | (tolower((host)[1])&31)) void db_mysql_load_os_dbase(void) diff --git a/src/sessions.c b/src/sessions.c index 2bf0605ea..29bb4b5f4 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -47,6 +47,12 @@ * exceptions. Comments and suggestions are more than welcome! * * -TheShadow (02 April 1999) + * + * The whole exception system has been rewritten to use linked list instead of + * an array due to a bug we couldn't track down. We don't need the numerical + * system anymore, it's not necessary to delete ranges. + * + * -Certus (04 July 2006) */ /*************************************************************************/ @@ -60,10 +66,82 @@ Session *sessionlist[1024]; int32 nsessions = 0; -Exception *exceptions = NULL; +Exception *exceptionlist[1024]; int16 nexceptions = 0; /*************************************************************************/ +/************************ Exception Manipulation *************************/ +/*************************************************************************/ + +Exception *exception_add(User * u, const char *mask, const int limit, + const char *reason, const char *who, + const time_t expires) +{ + int i, index; + Exception *exception, *ptr, *prev; + + /* Check if an exception already exists for this mask */ + for (i = 0; i < 1024; i++) { + for (exception = exceptionlist[i]; exception; exception = exception->next) { + if (!stricmp(mask, exception->mask)) { + if (exception->limit != limit) { + exception->limit = limit; + if (u) + notice_lang(s_OperServ, u, OPER_EXCEPTION_CHANGED, + mask, exception->limit); + return NULL; + } else { + if (u) + notice_lang(s_OperServ, u, OPER_EXCEPTION_EXISTS, + mask); + return NULL; + } + } + } + } + + nexceptions++; + exception = scalloc(sizeof(Exception), 1); + + exception->mask = sstrdup(mask); + exception->limit = limit; + exception->reason = sstrdup(reason); + exception->time = time(NULL); + strscpy(exception->who, who, NICKMAX); + exception->expires = expires; + + index = HASH(mask); /* bang! into the list! */ + + exception->prev = NULL; + exception->next = exceptionlist[index]; + if (exception->next) + exception->next->prev = exception; + exceptionlist[index] = exception; + + return exception; +} + +/*************************************************************************/ + +static int exception_del(Exception *exception) +{ + /* Remove the exception from the list */ + if (exception->next) + exception->next->prev = exception->prev; + if (exception->prev) + exception->prev->next = exception->next; + else + exceptionlist[HASH(exception->mask)] = exception->next; + + free(exception->mask); + free(exception->reason); + free(exception); + nexceptions--; + + return 1; +} + +/*************************************************************************/ /****************************** Statistics *******************************/ /*************************************************************************/ @@ -86,14 +164,18 @@ void get_session_stats(long *nrec, long *memuse) void get_exception_stats(long *nrec, long *memuse) { + Exception *exception; long mem; int i; mem = sizeof(Exception) * nexceptions; - for (i = 0; i < nexceptions; i++) { - mem += strlen(exceptions[i].mask) + 1; - mem += strlen(exceptions[i].reason) + 1; + for (i = 0; i < 1024; i++) { + for (exception = exceptionlist[i]; exception; exception = exception->next) { + mem += strlen(exception->mask) + 1; + mem += strlen(exception->reason) + 1; + } } + *nrec = nexceptions; *memuse = mem; } @@ -328,22 +410,20 @@ void del_session(const char *host) void expire_exceptions(void) { int i; + Exception *exception, *tmpexc; time_t now = time(NULL); - for (i = 0; i < nexceptions; i++) { - if (exceptions[i].expires == 0 || exceptions[i].expires > now) - continue; - if (WallExceptionExpire) - anope_cmd_global(s_OperServ, - "Session limit exception for %s has expired.", - exceptions[i].mask); - free(exceptions[i].mask); - free(exceptions[i].reason); - nexceptions--; - memmove(exceptions + i, exceptions + i + 1, - sizeof(Exception) * (nexceptions - i)); - exceptions = srealloc(exceptions, sizeof(Exception) * nexceptions); - i--; + for (i = 0; i < 1024; i++) { + for (exception = exceptionlist[i]; exception; exception = tmpexc) { + tmpexc = exception->next; + if (exception->expires == 0 || exception->expires > now) + continue; + if (WallExceptionExpire) + anope_cmd_global(s_OperServ, + "Session limit exception for %s has expired.", + exception->mask); + exception_del(exception); + } } } @@ -352,10 +432,12 @@ void expire_exceptions(void) Exception *find_host_exception(const char *host) { int i; + Exception *exception; - for (i = 0; i < nexceptions; i++) { - if (match_wild_nocase(exceptions[i].mask, host)) { - return &exceptions[i]; + for (i = 0; i < 1024; i++) { + for (exception = exceptionlist[i]; exception; exception = exception->next) { + if (match_wild_nocase(exception->mask, host)) + return exception; } } @@ -378,7 +460,7 @@ Exception *find_host_exception(const char *host) void load_exceptions() { dbFILE *f; - int i; + int i, index; uint16 n; uint16 tmp16; uint32 tmp32; @@ -392,21 +474,31 @@ void load_exceptions() case 7: SAFE(read_int16(&n, f)); nexceptions = n; - exceptions = scalloc(sizeof(Exception) * nexceptions, 1); if (!nexceptions) { close_db(f); return; } for (i = 0; i < nexceptions; i++) { - SAFE(read_string(&exceptions[i].mask, f)); + + Exception *exception = scalloc(sizeof(Exception), 1); + + SAFE(read_string(&exception->mask, f)); SAFE(read_int16(&tmp16, f)); - exceptions[i].limit = tmp16; - SAFE(read_buffer(exceptions[i].who, f)); - SAFE(read_string(&exceptions[i].reason, f)); + exception->limit = tmp16; + SAFE(read_buffer(exception->who, f)); + SAFE(read_string(&exception->reason, f)); SAFE(read_int32(&tmp32, f)); - exceptions[i].time = tmp32; + exception->time = tmp32; SAFE(read_int32(&tmp32, f)); - exceptions[i].expires = tmp32; + exception->expires = tmp32; + + index = HASH(exception->mask); + + exception->prev = NULL; + exception->next = exceptionlist[index]; + if (exception->next) + exception->next->prev = exception; + exceptionlist[index] = exception; } break; @@ -438,19 +530,22 @@ void save_exceptions() { dbFILE *f; int i; + Exception *exception; static time_t lastwarn = 0; if (! (f = open_db(s_OperServ, ExceptionDBName, "w", EXCEPTION_VERSION))) return; SAFE(write_int16(nexceptions, f)); - for (i = 0; i < nexceptions; i++) { - SAFE(write_string(exceptions[i].mask, f)); - SAFE(write_int16(exceptions[i].limit, f)); - SAFE(write_buffer(exceptions[i].who, f)); - SAFE(write_string(exceptions[i].reason, f)); - SAFE(write_int32(exceptions[i].time, f)); - SAFE(write_int32(exceptions[i].expires, f)); + for (i = 0; i < 1024; i++) { + for (exception = exceptionlist[i]; exception; exception = exception->next) { + SAFE(write_string(exception->mask, f)); + SAFE(write_int16(exception->limit, f)); + SAFE(write_buffer(exception->who, f)); + SAFE(write_string(exception->reason, f)); + SAFE(write_int32(exception->time, f)); + SAFE(write_int32(exception->expires, f)); + } } close_db(f); } @@ -463,156 +558,20 @@ void save_rdb_exceptions() { #ifdef USE_RDB int i; - Exception *e; + Exception *exception; if (!rdb_open()) return; rdb_clear_table("anope_os_exceptions"); - for (i = 0; i < nexceptions; i++) { - e = &exceptions[i]; - rdb_save_exceptions(e); + for (i = 0; i < 1024; i++) { + for (exception = exceptionlist[i]; exception; exception = exception->next) { + rdb_save_exceptions(exception); + } } rdb_close(); #endif } -/*************************************************************************/ -/************************ Exception Manipulation *************************/ -/*************************************************************************/ - -int exception_add(User * u, const char *mask, const int limit, - const char *reason, const char *who, - const time_t expires) -{ - int i; - - /* Check if an exception already exists for this mask */ - for (i = 0; i < nexceptions; i++) { - if (!stricmp(mask, exceptions[i].mask)) { - if (exceptions[i].limit != limit) { - exceptions[i].limit = limit; - if (u) - notice_lang(s_OperServ, u, OPER_EXCEPTION_CHANGED, - mask, exceptions[i].limit); - return -2; - } else { - if (u) - notice_lang(s_OperServ, u, OPER_EXCEPTION_EXISTS, - mask); - return -1; - } - } - } - - nexceptions++; - exceptions = srealloc(exceptions, sizeof(Exception) * nexceptions); - - exceptions[nexceptions - 1].mask = sstrdup(mask); - exceptions[nexceptions - 1].limit = limit; - exceptions[nexceptions - 1].reason = sstrdup(reason); - exceptions[nexceptions - 1].time = time(NULL); - strscpy(exceptions[nexceptions - 1].who, who, NICKMAX); - exceptions[nexceptions - 1].expires = expires; - exceptions[nexceptions - 1].num = nexceptions - 1; - - return 1; -} - -/*************************************************************************/ - -static int exception_del(const int index) -{ - if (index < 0 || index >= nexceptions) - return 0; - - free(exceptions[index].mask); - free(exceptions[index].reason); - nexceptions--; - memmove(exceptions + index, exceptions + index + 1, - sizeof(Exception) * (nexceptions - index)); - exceptions = srealloc(exceptions, sizeof(Exception) * nexceptions); - - return 1; -} - -/* We use the "num" property to keep track of the position of each exception - * when deleting using ranges. This is because an exception's position changes - * as others are deleted. The positions will be recalculated once the process - * is complete. -TheShadow - */ - -static int exception_del_callback(User * u, int num, va_list args) -{ - int i; - int *last = va_arg(args, int *); - - *last = num; - for (i = 0; i < nexceptions; i++) { - if (num - 1 == exceptions[i].num) - break; - } - if (i < nexceptions) - return exception_del(i); - else - return 0; -} - -static int exception_list(User * u, const int index, int *sent_header) -{ - if (index < 0 || index >= nexceptions) - return 0; - if (!*sent_header) { - notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_HEADER); - notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_COLHEAD); - *sent_header = 1; - } - notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_FORMAT, index + 1, - exceptions[index].limit, exceptions[index].mask); - return 1; -} - -static int exception_list_callback(User * u, int num, va_list args) -{ - int *sent_header = va_arg(args, int *); - - return exception_list(u, num - 1, sent_header); -} - -static int exception_view(User * u, const int index, int *sent_header) -{ - char timebuf[32], expirebuf[256]; - struct tm tm; - time_t t = time(NULL); - - if (index < 0 || index >= nexceptions) - return 0; - if (!*sent_header) { - notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_HEADER); - *sent_header = 1; - } - - tm = *localtime(exceptions[index].time ? &exceptions[index].time : &t); - strftime_lang(timebuf, sizeof(timebuf), - u, STRFTIME_SHORT_DATE_FORMAT, &tm); - - expire_left(u->na, expirebuf, sizeof(expirebuf), - exceptions[index].expires); - - notice_lang(s_OperServ, u, OPER_EXCEPTION_VIEW_FORMAT, - index + 1, exceptions[index].mask, - *exceptions[index].who ? - exceptions[index].who : "<unknown>", - timebuf, expirebuf, exceptions[index].limit, - exceptions[index].reason); - return 1; -} - -static int exception_view_callback(User * u, int num, va_list args) -{ - int *sent_header = va_arg(args, int *); - - return exception_view(u, num - 1, sent_header); -} /*************************************************************************/ @@ -629,9 +588,6 @@ static int exception_view_callback(User * u, int num, va_list args) * Syntax: EXCEPTION VIEW [mask] * Displays detailed information about each exception or those matching * mask. - * - * Syntax: EXCEPTION MOVE num position - * Moves the exception at position num to position. */ int do_exception(User * u) @@ -651,11 +607,11 @@ int do_exception(User * u) cmd = ""; if (stricmp(cmd, "ADD") == 0) { + /* gotta keep this check because of the dbs :( -Certus */ if (nexceptions >= 32767) { notice_lang(s_OperServ, u, OPER_EXCEPTION_TOO_MANY); return MOD_CONT; } - mask = strtok(NULL, " "); if (mask && *mask == '+') { expiry = mask; @@ -687,24 +643,27 @@ int do_exception(User * u) MaxSessionLimit); return MOD_CONT; - } else { + } else { /* finally when can add it */ + Exception *exception; + if (strchr(mask, '!') || strchr(mask, '@')) { notice_lang(s_OperServ, u, OPER_EXCEPTION_INVALID_HOSTMASK); return MOD_CONT; } - x = exception_add(u, mask, limit, reason, u->nick, expires); + exception = exception_add(u, mask, limit, reason, u->nick, expires); - if (x == 1) { - notice_lang(s_OperServ, u, OPER_EXCEPTION_ADDED, mask, - limit); - } + if (exception) + notice_lang(s_OperServ, u, OPER_EXCEPTION_ADDED, mask, limit); if (readonly) notice_lang(s_OperServ, u, READ_ONLY_MODE); } } else if (stricmp(cmd, "DEL") == 0) { + Exception *exception; + int deleted = 0; + mask = strtok(NULL, " "); if (!mask) { @@ -713,127 +672,76 @@ int do_exception(User * u) return MOD_CONT; } - if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { - int count, deleted, last = -1; - deleted = - process_numlist(mask, &count, exception_del_callback, u, - &last); - if (!deleted) { - if (count == 1) { - notice_lang(s_OperServ, u, - OPER_EXCEPTION_NO_SUCH_ENTRY, last); - } else { - notice_lang(s_OperServ, u, OPER_EXCEPTION_NO_MATCH); - } - } else if (deleted == 1) { - notice_lang(s_OperServ, u, OPER_EXCEPTION_DELETED_ONE); - } else { - notice_lang(s_OperServ, u, OPER_EXCEPTION_DELETED_SEVERAL, - deleted); - } - } else { - int deleted = 0; - - for (i = 0; i < nexceptions; i++) { - if (stricmp(mask, exceptions[i].mask) == 0) { - exception_del(i); - notice_lang(s_OperServ, u, OPER_EXCEPTION_DELETED, - mask); + for (i = 0; i < 1024; i++) { + for (exception = exceptionlist[i]; exception; exception = exception->next) { + if (!stricmp(mask, exception->mask)) { + exception_del(exception); + notice_lang(s_OperServ, u, OPER_EXCEPTION_DELETED, mask); deleted = 1; break; } } - if (!deleted && i == nexceptions) - notice_lang(s_OperServ, u, OPER_EXCEPTION_NOT_FOUND, mask); } - /* Renumber the exception list. I don't believe in having holes in - * lists - it makes code more complex, harder to debug and we end up - * with huge index numbers. Imho, fixed numbering is only beneficial - * when one doesn't have range capable manipulation. -TheShadow */ - - for (i = 0; i < nexceptions; i++) - exceptions[i].num = i; + if (!deleted) + notice_lang(s_OperServ, u, OPER_EXCEPTION_NOT_FOUND, mask); if (readonly) notice_lang(s_OperServ, u, READ_ONLY_MODE); - } else if (stricmp(cmd, "MOVE") == 0) { - Exception *exception; - char *n1str = strtok(NULL, " "); /* From position */ - char *n2str = strtok(NULL, " "); /* To position */ - int n1, n2; - - if (!n2str) { - syntax_error(s_OperServ, u, "EXCEPTION", - OPER_EXCEPTION_MOVE_SYNTAX); - return MOD_CONT; - } - - n1 = atoi(n1str) - 1; - n2 = atoi(n2str) - 1; - - if ((n1 >= 0 && n1 < nexceptions) && (n2 >= 0 && n2 < nexceptions) - && (n1 != n2)) { - exception = scalloc(sizeof(Exception), 1); - memcpy(exception, &exceptions[n1], sizeof(Exception)); - - if (n1 < n2) { - /* Shift upwards */ - memmove(&exceptions[n1], &exceptions[n1 + 1], - sizeof(Exception) * (n2 - n1)); - memmove(&exceptions[n2], exception, sizeof(Exception)); - } else { - /* Shift downwards */ - memmove(&exceptions[n2 + 1], &exceptions[n2], - sizeof(Exception) * (n1 - n2)); - memmove(&exceptions[n2], exception, sizeof(Exception)); - } - - free(exception); - notice_lang(s_OperServ, u, OPER_EXCEPTION_MOVED, - exceptions[n1].mask, n1 + 1, n2 + 1); - - /* Renumber the exception list. See the DEL block above for why. */ - for (i = 0; i < nexceptions; i++) - exceptions[i].num = i; - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - } else { - syntax_error(s_OperServ, u, "EXCEPTION", - OPER_EXCEPTION_MOVE_SYNTAX); - } } else if (stricmp(cmd, "LIST") == 0) { int sent_header = 0; + Exception *exception; + expire_exceptions(); mask = strtok(NULL, " "); - if (mask && strspn(mask, "1234567890,-") == strlen(mask)) { - process_numlist(mask, NULL, exception_list_callback, u, - &sent_header); - } else { - for (i = 0; i < nexceptions; i++) { - if (!mask || match_wild_nocase(mask, exceptions[i].mask)) - exception_list(u, i, &sent_header); + + for (i = 0; i < 1024; i++) { + for (exception = exceptionlist[i]; exception; exception = exception->next) { + if (!mask || match_wild_nocase(mask, exception->mask)) { + if (!sent_header) { + notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_HEADER); + notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_COLHEAD); + sent_header = 1; + } + notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_FORMAT, + exception->limit, exception->mask); + } } } + if (!sent_header) notice_lang(s_OperServ, u, OPER_EXCEPTION_NO_MATCH); } else if (stricmp(cmd, "VIEW") == 0) { int sent_header = 0; + Exception *exception; + char timebuf[32], expirebuf[256]; + struct tm tm; + time_t t = time(NULL); + expire_exceptions(); mask = strtok(NULL, " "); - if (mask && strspn(mask, "1234567890,-") == strlen(mask)) { - process_numlist(mask, NULL, exception_view_callback, u, - &sent_header); - } else { - for (i = 0; i < nexceptions; i++) { - if (!mask || match_wild_nocase(mask, exceptions[i].mask)) - exception_view(u, i, &sent_header); + + for (i = 0; i < 1024; i++) { + for (exception = exceptionlist[i]; exception; exception = exception->next) { + if (!mask || match_wild_nocase(mask, exception->mask)) { + if (!sent_header) { + notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_HEADER); + sent_header = 1; + } + tm = *localtime(exception->time ? &exception->time : &t); + strftime_lang(timebuf, sizeof(timebuf), u, + STRFTIME_SHORT_DATE_FORMAT, &tm); + expire_left(u->na, expirebuf, sizeof(expirebuf), exception->expires); + notice_lang(s_OperServ, u, OPER_EXCEPTION_VIEW_FORMAT, exception->mask, + exception->who ? exception->who : "<unknown>", timebuf, expirebuf, + exception->limit, exception->reason); + } } } + if (!sent_header) notice_lang(s_OperServ, u, OPER_EXCEPTION_NO_MATCH); diff --git a/version.log b/version.log index 80f031db6..640bf6bc3 100644 --- a/version.log +++ b/version.log @@ -9,10 +9,14 @@ VERSION_MAJOR="1" VERSION_MINOR="7" VERSION_PATCH="14" VERSION_EXTRA="" -VERSION_BUILD="1079" +VERSION_BUILD="1080" # $Log$ # +# BUILD : 1.7.14 (1080) +# BUGS : 491? +# NOTES : rewrote exception system due to a bug we couldn't track down. +# # BUILD : 1.7.14 (1079) # BUGS : 529 531 # NOTES : applied trystan's fix and fixed some readonly stuff |