[IRC-Dev CVS] [CVS] Module ircd-ircdev: Change committed
Brought to you by:
zolty
From: Toni G. <zo...@us...> - 2005-06-22 07:54:50
|
CVSROOT : /cvsroot/irc-dev Module : ircd-ircdev Commit time: 2005-06-22 07:54:40 UTC Modified files: ChangeLog ChangeLog.es include/channel.h include/class.h include/ddb.h include/ircd_string.h include/list.h include/numeric.h include/patchlevel.h include/watch.h ircd/IPcheck.c ircd/channel.c ircd/class.c ircd/client.c ircd/ddb.c ircd/ddb_events.c ircd/ircd.c ircd/ircd_res.c ircd/ircd_string.c ircd/list.c ircd/m_burst.c ircd/m_clearmode.c ircd/m_dbq.c ircd/m_endburst.c ircd/m_invite.c ircd/m_server.c ircd/m_topic.c ircd/match.c ircd/s_bsd.c ircd/s_conf.c ircd/s_debug.c ircd/s_err.c ircd/s_serv.c ircd/s_stats.c ircd/s_user.c ircd/send.c ircd/watch.c ircd/test/.cvsignore ircd/test/Makefile.in ircd/test/kill-block-1.cmd ircd/test/run-tests.sh Log message: Author: zoltan <zo...@ir...> Log message: 2005-06-22 Toni García <zo...@ir...> 1.0.alpha39 * Limpieza * Fixs de bugs estéticos ---------------------- diff included ---------------------- Index: ircd-ircdev/ChangeLog diff -u ircd-ircdev/ChangeLog:1.40 ircd-ircdev/ChangeLog:1.41 --- ircd-ircdev/ChangeLog:1.40 Thu May 26 03:34:12 2005 +++ ircd-ircdev/ChangeLog Wed Jun 22 00:54:28 2005 @@ -1,10 +1,14 @@ # # ChangeLog for ircd-ircdev # -# $Id: ChangeLog,v 1.40 2005/05/26 10:34:12 zolty Exp $ +# $Id: ChangeLog,v 1.41 2005/06/22 07:54:28 zolty Exp $ # # Insert new changes at beginning of the change list. # +2005-06-22 Toni García <zo...@ir...> 1.0.alpha39 + * Cleanups + * Estetic bugfixes + 2005-05-26 Toni García <zo...@ir...> 1.0.alpha38 * Fix bugs last release. Index: ircd-ircdev/ChangeLog.es diff -u ircd-ircdev/ChangeLog.es:1.40 ircd-ircdev/ChangeLog.es:1.41 --- ircd-ircdev/ChangeLog.es:1.40 Thu May 26 03:34:13 2005 +++ ircd-ircdev/ChangeLog.es Wed Jun 22 00:54:29 2005 @@ -1,10 +1,14 @@ # # Log de Cambios para ircd-ircdev # -# $Id: ChangeLog.es,v 1.40 2005/05/26 10:34:13 zolty Exp $ +# $Id: ChangeLog.es,v 1.41 2005/06/22 07:54:29 zolty Exp $ # # Insertar los nuevos cambios al principio de esta lista de cambios. # +2005-06-22 Toni García <zo...@ir...> 1.0.alpha39 + * Limpieza + * Fixs de bugs estéticos + 2005-05-26 Toni García <zo...@ir...> 1.0.alpha38 * Fix de bugs de la release anterior Index: ircd-ircdev/include/channel.h diff -u ircd-ircdev/include/channel.h:1.10 ircd-ircdev/include/channel.h:1.11 --- ircd-ircdev/include/channel.h:1.10 Wed May 25 09:56:23 2005 +++ ircd-ircdev/include/channel.h Wed Jun 22 00:54:29 2005 @@ -22,7 +22,7 @@ */ /** @file * @brief Channel management and maintenance. - * @version $Id: channel.h,v 1.10 2005/05/25 16:56:23 zolty Exp $ + * @version $Id: channel.h,v 1.11 2005/06/22 07:54:29 zolty Exp $ */ #ifndef INCLUDED_channel_h #define INCLUDED_channel_h @@ -319,14 +319,14 @@ /** A single ban for a channel. */ struct Ban { - struct Ban* next; /**< next ban in the channel */ + struct Ban* next; /**< next ban in the channel */ struct irc_in_addr address; /**< addres for BAN_IPMASK bans */ - time_t when; /**< timestamp when ban was added */ - unsigned short flags; /**< modifier flags for the ban */ - unsigned char nu_len; /**< length of nick!user part of banstr */ - unsigned char addrbits; /**< netmask length for BAN_IPMASK bans */ - char *who; /**< name of client that set the ban */ - char *banstr; /**< hostmask that the ban matches */ + time_t when; /**< timestamp when ban was added */ + unsigned short flags; /**< modifier flags for the ban */ + unsigned char nu_len; /**< length of nick!user part of banstr */ + unsigned char addrbits; /**< netmask length for BAN_IPMASK bans */ + char who[NICKLEN+1]; /**< name of client that set the ban */ + char banstr[NICKLEN+USERLEN+HOSTLEN+3]; /**< hostmask that the ban matches */ }; /** Information about a channel */ Index: ircd-ircdev/include/class.h diff -u ircd-ircdev/include/class.h:1.6 ircd-ircdev/include/class.h:1.7 --- ircd-ircdev/include/class.h:1.6 Mon Jan 10 04:21:59 2005 +++ ircd-ircdev/include/class.h Wed Jun 22 00:54:29 2005 @@ -22,7 +22,7 @@ */ /** @file * @brief Declarations and interfaces for handling connection classes. - * @version $Id: class.h,v 1.6 2005/01/10 12:21:59 zolty Exp $ + * @version $Id: class.h,v 1.7 2005/06/22 07:54:29 zolty Exp $ */ #ifndef INCLUDED_class_h #define INCLUDED_class_h @@ -103,7 +103,6 @@ extern struct ConnectionClass *find_class(const char *name); extern struct ConnectionClass *make_class(void); extern void free_class(struct ConnectionClass * tmp); -extern unsigned int get_con_freq(struct ConnectionClass * clptr); extern char *get_conf_class(const struct ConfItem *aconf); extern int get_conf_ping(const struct ConfItem *aconf); extern char *get_client_class(struct Client *acptr); Index: ircd-ircdev/include/ddb.h diff -u ircd-ircdev/include/ddb.h:1.9 ircd-ircdev/include/ddb.h:1.10 --- ircd-ircdev/include/ddb.h:1.9 Wed May 25 09:56:23 2005 +++ ircd-ircdev/include/ddb.h Wed Jun 22 00:54:29 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Distributed DataBases structures, macros and functions. - * @version $Id: ddb.h,v 1.9 2005/05/25 16:56:23 zolty Exp $ + * @version $Id: ddb.h,v 1.10 2005/06/22 07:54:29 zolty Exp $ */ #ifndef INCLUDED_ddb_h #define INCLUDED_ddb_h @@ -149,6 +149,7 @@ extern void ddb_reload(void); extern void ddb_die(const char *pattern, ...); extern void ddb_report_stats(struct Client* to, const struct StatDesc* sd, char* param); +extern void ddb_count_memory(size_t* count_out, size_t* bytes_out); /* ddb_db_*.c externs */ extern void ddb_db_init(void); Index: ircd-ircdev/include/ircd_string.h diff -u ircd-ircdev/include/ircd_string.h:1.5 ircd-ircdev/include/ircd_string.h:1.6 --- ircd-ircdev/include/ircd_string.h:1.5 Mon Jan 10 04:22:00 2005 +++ ircd-ircdev/include/ircd_string.h Wed Jun 22 00:54:29 2005 @@ -21,7 +21,7 @@ */ /** @file ircd_string.h * @brief Public declarations and APIs for string operations. - * @version $Id: ircd_string.h,v 1.5 2005/01/10 12:22:00 zolty Exp $ + * @version $Id: ircd_string.h,v 1.6 2005/06/22 07:54:29 zolty Exp $ */ #ifndef INCLUDED_ircd_string_h #define INCLUDED_ircd_string_h @@ -30,6 +30,8 @@ #include "ircd_chattr.h" #endif +#include <string.h> /* for DupString()'s strcpy, strlen */ + struct irc_in_addr; /* @@ -38,13 +40,6 @@ /** Check whether \a x is a NULL or empty string. */ #define EmptyString(x) (!(x) || !(*x)) -/* - * initialize recognizers - */ -extern int init_string(void); - -extern int string_is_hostname(const char* str); -extern int string_is_address(const char* str); extern int string_has_wildcards(const char* str); extern char* ircd_strncpy(char* dest, const char* src, size_t len); @@ -139,9 +134,4 @@ #endif #endif /* FORCEINLINE */ -/* - * Proto types of other externally visible functions - */ -extern int strnChattr(const char *s, const size_t n); - #endif /* INCLUDED_ircd_string_h */ Index: ircd-ircdev/include/list.h diff -u ircd-ircdev/include/list.h:1.5 ircd-ircdev/include/list.h:1.6 --- ircd-ircdev/include/list.h:1.5 Mon Jan 10 04:22:00 2005 +++ ircd-ircdev/include/list.h Wed Jun 22 00:54:29 2005 @@ -21,7 +21,7 @@ */ /** @file list.h * @brief Singly and doubly linked list manipulation interface. - * @version $Id: list.h,v 1.5 2005/01/10 12:22:00 zolty Exp $ + * @version $Id: list.h,v 1.6 2005/06/22 07:54:29 zolty Exp $ */ #ifndef INCLUDED_list_h #define INCLUDED_list_h @@ -71,7 +71,6 @@ extern void free_link(struct SLink *lp); extern struct SLink *make_link(void); -extern struct SLink *find_user_link(struct SLink *lp, struct Client *ptr); extern void init_list(void); extern struct Client *make_client(struct Client *from, int status); extern void free_connection(struct Connection *con); Index: ircd-ircdev/include/numeric.h diff -u ircd-ircdev/include/numeric.h:1.13 ircd-ircdev/include/numeric.h:1.14 --- ircd-ircdev/include/numeric.h:1.13 Sat May 7 15:23:39 2005 +++ ircd-ircdev/include/numeric.h Wed Jun 22 00:54:29 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Declarations of numeric replies and supporting functions. - * @version $Id: numeric.h,v 1.13 2005/05/07 22:23:39 zolty Exp $ + * @version $Id: numeric.h,v 1.14 2005/06/22 07:54:29 zolty Exp $ */ #ifndef INCLUDED_numeric_h #define INCLUDED_numeric_h @@ -121,12 +121,12 @@ #define RPL_STATSALINE 226 /* Hybrid, Undernet */ #define RPL_STATSQLINE 228 /* Undernet extension */ -#define RPL_SERVICEINFO 231 /* unused */ -#define RPL_ENDOFSERVICES 232 /* unused */ +/* RPL_SERVICEINFO 231 unused */ +/* RPL_ENDOFSERVICES 232 unused */ /* RPL_RULES 232 unreal */ -#define RPL_SERVICE 233 /* unused */ -#define RPL_SERVLIST 234 /* unused */ -#define RPL_SERVLISTEND 235 /* unused */ +/* RPL_SERVICE 233 unused */ +/* RPL_SERVLIST 234 unused */ +/* RPL_SERVLISTEND 235 unused */ #define RPL_STATSVERBOSE 236 /* Undernet verbose server list */ #define RPL_STATSENGINE 237 /* Undernet engine name */ @@ -161,7 +161,7 @@ #define RPL_ADMINLOC2 258 #define RPL_ADMINEMAIL 259 -#define RPL_TRACELOG 261 /* unused */ +/* RPL_TRACELOG 261 unused */ #define RPL_TRACEEND 262 /* efnet/IRCnet */ /* RPL_LOAD_THROTTLED 263 efnet/hybrid */ /* RPL_TRYAGAIN 263 Numerics List: IRCnet */ @@ -206,11 +206,11 @@ /* RPL_END_CHANINFO 299 aircd */ -#define RPL_NONE 300 /* unused */ +/* RPL_NONE 300 unused */ #define RPL_AWAY 301 #define RPL_USERHOST 302 #define RPL_ISON 303 -#define RPL_TEXT 304 /* unused */ +/* RPL_TEXT 304 unused */ #define RPL_UNAWAY 305 #define RPL_NOWAWAY 306 /* NotAway, aircd */ @@ -276,7 +276,7 @@ See also RPL_ENDOFWHO */ #define RPL_DELNAMREPLY 355 /* QuakeNet extension */ -#define RPL_KILLDONE 361 /* not used */ +/* RPL_KILLDONE 361 not used */ #define RPL_CLOSING 362 #define RPL_CLOSEEND 363 #define RPL_LINKS 364 @@ -303,12 +303,12 @@ #define RPL_YOUREOPER 381 #define RPL_REHASHING 382 /* RPL_YOURSERVICE 383 Numeric List: various */ -#define RPL_MYPORTIS 384 /* not used */ -#define RPL_NOTOPERANYMORE 385 /* Extension to RFC1459, not used */ +/* RPL_MYPORTIS 384 not used */ +/* RPL_NOTOPERANYMORE 385 Extension to RFC1459, not used */ /* RPL_QLIST 386 unreal */ /* RPL_ENDOFQLIST 387 unreal */ /* RPL_ALIST 388 unreal */ -/* RPL_ENDOFALIST 389 unreal */ +/* RPL_ENDOFALIST 389 unreal */ #define RPL_WHOISSUSPEND 390 /* IRC-Dev extension */ #define RPL_TIME 391 @@ -322,7 +322,7 @@ * Errors are in the range from 400-599 currently and are grouped by what * commands they come from. */ -#define ERR_FIRSTERROR 400 /* unused */ +/* ERR_FIRSTERROR 400 unused */ #define ERR_NOSUCHNICK 401 #define ERR_NOSUCHSERVER 402 #define ERR_NOSUCHCHANNEL 403 Index: ircd-ircdev/include/patchlevel.h diff -u ircd-ircdev/include/patchlevel.h:1.39 ircd-ircdev/include/patchlevel.h:1.40 --- ircd-ircdev/include/patchlevel.h:1.39 Thu May 26 03:34:13 2005 +++ ircd-ircdev/include/patchlevel.h Wed Jun 22 00:54:29 2005 @@ -17,10 +17,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: patchlevel.h,v 1.39 2005/05/26 10:34:13 zolty Exp $ + * $Id: patchlevel.h,v 1.40 2005/06/22 07:54:29 zolty Exp $ * */ -#define PATCHLEVEL ".alpha38" +#define PATCHLEVEL ".alpha39" #define RELEASE "1.0" Index: ircd-ircdev/include/watch.h diff -u ircd-ircdev/include/watch.h:1.3 ircd-ircdev/include/watch.h:1.4 --- ircd-ircdev/include/watch.h:1.3 Mon Jan 10 04:22:00 2005 +++ ircd-ircdev/include/watch.h Wed Jun 22 00:54:29 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: watch.h,v 1.3 2005/01/10 12:22:00 zolty Exp $ + * $Id: watch.h,v 1.4 2005/06/22 07:54:29 zolty Exp $ * */ #ifndef INCLUDED_watch_h @@ -65,6 +65,6 @@ extern int add_nick_watch(struct Client *sptr, char *nick); extern int del_nick_watch(struct Client *sptr, char *nick); extern int del_list_watch(struct Client *sptr); -extern int watch_memory_count(size_t *wt_size); +extern void watch_count_memory(size_t* count_out, size_t* bytes_out); #endif /* INCLUDED_watch_h */ Index: ircd-ircdev/ircd/IPcheck.c diff -u ircd-ircdev/ircd/IPcheck.c:1.10 ircd-ircdev/ircd/IPcheck.c:1.11 --- ircd-ircdev/ircd/IPcheck.c:1.10 Mon Mar 21 10:39:05 2005 +++ ircd-ircdev/ircd/IPcheck.c Wed Jun 22 00:54:29 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Code to count users connected from particular IP addresses. - * @version $Id: IPcheck.c,v 1.10 2005/03/21 18:39:05 zolty Exp $ + * @version $Id: IPcheck.c,v 1.11 2005/06/22 07:54:29 zolty Exp $ */ #include "config.h" @@ -30,11 +30,11 @@ #include "ircd.h" #include "match.h" #include "msg.h" -#include "numnicks.h" /* NumNick, NumServ (GODMODE) */ #include "ircd_alloc.h" #include "ircd_events.h" #include "ircd_features.h" #include "ircd_log.h" +#include "ircd_string.h" /* ircd_ntoa */ #include "s_debug.h" /* Debug */ #include "s_user.h" /* TARGET_DELAY */ #include "send.h" @@ -222,6 +222,7 @@ /* * expired */ + Debug((DEBUG_DNS, "IPcheck expiring registry for %s (no clients connected).", ircd_ntoa(&entry->addr))); ip_registry_remove(entry); ip_registry_delete_entry(entry); } @@ -278,16 +279,18 @@ entry = ip_registry_new_entry(); ip_registry_canonicalize(&entry->addr, addr); ip_registry_add(entry); + Debug((DEBUG_DNS, "IPcheck added new registry for local connection from %s.", ircd_ntoa(&entry->addr))); return 1; } - /* Note that this also connects server connects. + /* Note that this also counts server connects. * It is hard and not interesting, to change that. * - * Don't allow more then 255 connects from one IP number, ever + * Refuse connection if it would overflow the counter. */ if (0 == ++entry->connected) { entry->connected--; + Debug((DEBUG_DNS, "IPcheck refusing local connection from %s: counter overflow.", ircd_ntoa(&entry->addr))); return 0; } @@ -305,17 +308,17 @@ *next_target_out = CurrentTime - (TARGET_DELAY * free_targets - 1); } else if ((CurrentTime - cli_since(&me)) > IPCHECK_CLONE_DELAY) { - /* + /* * Don't refuse connection when we just rebooted the server */ -#ifdef NOTHROTTLE - return 1; -#else +#ifndef NOTHROTTLE assert(entry->connected > 0); --entry->connected; + Debug((DEBUG_DNS, "IPcheck refusing local connection from %s: too fast.", ircd_ntoa(&entry->addr))); return 0; -#endif +#endif } + Debug((DEBUG_DNS, "IPcheck accepting local connection from %s.", ircd_ntoa(&entry->addr))); return 1; } @@ -335,8 +338,10 @@ * Mark that we did add/update an IPregistry entry */ SetIPChecked(cptr); - if (!irc_in_addr_valid(&cli_ip(cptr))) + if (!irc_in_addr_valid(&cli_ip(cptr))) { + Debug((DEBUG_DNS, "IPcheck accepting remote connection from invalid %s.", ircd_ntoa(&cli_ip(cptr)))); return 1; + } entry = ip_registry_find(&cli_ip(cptr)); if (0 == entry) { entry = ip_registry_new_entry(); @@ -344,27 +349,27 @@ if (is_burst) entry->attempts = 0; ip_registry_add(entry); + Debug((DEBUG_DNS, "IPcheck added new registry for remote connection from %s.", ircd_ntoa(&entry->addr))); + return 1; } - else { - if (0 == ++entry->connected) { - /* - * Don't allow more then 255 connects from one IP number, ever + /* Avoid overflowing the connection counter. */ + if (0 == ++entry->connected) { + Debug((DEBUG_DNS, "IPcheck refusing remote connection from %s: counter overflow.", ircd_ntoa(&entry->addr))); + return 0; + } + if (CONNECTED_SINCE(entry->last_connect) > IPCHECK_CLONE_PERIOD) + entry->attempts = 0; + if (!is_burst) { + if (0 == ++entry->attempts) { + /* + * Check for overflow */ - return 0; - } - if (CONNECTED_SINCE(entry->last_connect) > IPCHECK_CLONE_PERIOD) - entry->attempts = 0; - if (!is_burst) { - if (0 == ++entry->attempts) { - /* - * Check for overflow - */ - --entry->attempts; - } - ip_registry_update_free_targets(entry); - entry->last_connect = NOW; + --entry->attempts; } + ip_registry_update_free_targets(entry); + entry->last_connect = NOW; } + Debug((DEBUG_DNS, "IPcheck counting remote connection from %s.", ircd_ntoa(&entry->addr))); return 1; } @@ -376,10 +381,9 @@ void ip_registry_connect_fail(const struct irc_in_addr *addr) { struct IPRegistryEntry* entry = ip_registry_find(addr); - if (entry) - { - if (0 == --entry->attempts) - ++entry->attempts; + if (entry && 0 == --entry->attempts) { + Debug((DEBUG_DNS, "IPcheck noting local connection failure for %s.", ircd_ntoa(&entry->addr))); + ++entry->attempts; } } @@ -395,15 +399,13 @@ unsigned int free_targets = STARTTARGETS; struct IPRegistryEntry* entry = ip_registry_find(&cli_ip(cptr)); - if (!entry) { - Debug((DEBUG_ERROR, "Missing registry entry for: %s", cli_sock_ip(cptr))); - return; - } + assert(entry); if (entry->target) { memcpy(cli_targets(cptr), entry->target->targets, MAXTARGETS); free_targets = entry->target->count; tr = " tr"; } + Debug((DEBUG_DNS, "IPcheck noting local connection success for %s.", ircd_ntoa(&entry->addr))); sendcmdto_one(&me, CMD_NOTICE, cptr, "%C :on %u ca %u(%u) ft %u(%u)%s", cptr, entry->connected, entry->attempts, IPCHECK_CLONE_LIMIT, free_targets, STARTTARGETS, tr); @@ -417,17 +419,16 @@ void ip_registry_disconnect(struct Client *cptr) { struct IPRegistryEntry* entry = ip_registry_find(&cli_ip(cptr)); - if (0 == entry) { - /* - * trying to find an entry for a server causes this to happen, - * servers should never have FLAG_IPCHECK set - */ + if (!irc_in_addr_valid(&cli_ip(cptr))) { + Debug((DEBUG_DNS, "IPcheck noting dicconnect from invalid %s.", ircd_ntoa(&cli_ip(cptr)))); return; } + assert(entry); + assert(entry->connected > 0); + Debug((DEBUG_DNS, "IPcheck noting disconnect from %s.", ircd_ntoa(&entry->addr))); /* * If this was the last one, set `last_connect' to disconnect time (used for expiration) */ - /* assert(entry->connected > 0); */ if (0 == --entry->connected) { if (CONNECTED_SINCE(entry->last_connect) > IPCHECK_CLONE_LIMIT * IPCHECK_CLONE_PERIOD) { /* Index: ircd-ircdev/ircd/channel.c diff -u ircd-ircdev/ircd/channel.c:1.23 ircd-ircdev/ircd/channel.c:1.24 --- ircd-ircdev/ircd/channel.c:1.23 Thu May 26 03:34:13 2005 +++ ircd-ircdev/ircd/channel.c Wed Jun 22 00:54:29 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Channel management and maintanance - * @version $Id: channel.c,v 1.23 2005/05/26 10:34:13 zolty Exp $ + * @version $Id: channel.c,v 1.24 2005/06/22 07:54:29 zolty Exp $ */ #include "config.h" @@ -70,6 +70,10 @@ static struct Membership* membershipFreeList; /** Freelist for struct Ban*'s */ static struct Ban* free_bans; +/** Number of ban structures allocated. */ +static size_t bans_alloc; +/** Number of ban structures in use. */ +static size_t bans_inuse; #if !defined(NDEBUG) /** return the length (>=0) of a chain of links. @@ -94,10 +98,9 @@ set_ban_mask(struct Ban *ban, const char *banstr) { char *sep; - MyFree(ban->banstr); - if (!banstr) - return; - DupString(ban->banstr, banstr); + + assert(banstr != NULL); + ircd_strncpy(ban->banstr, banstr, sizeof(ban->banstr) - 1); sep = strrchr(banstr, '@'); if (sep) { ban->nu_len = sep - banstr; @@ -120,6 +123,9 @@ } else if (!(ban = MyMalloc(sizeof(*ban)))) return NULL; + else + bans_alloc++; + bans_inuse++; memset(ban, 0, sizeof(*ban)); set_ban_mask(ban, banstr); return ban; @@ -131,12 +137,24 @@ void free_ban(struct Ban *ban) { - MyFree(ban->who); - MyFree(ban->banstr); ban->next = free_bans; free_bans = ban; + bans_inuse--; } +/** Report ban usage to \a cptr. + * @param[in] cptr Client requesting information. + */ +void bans_send_meminfo(struct Client *cptr) +{ + struct Ban *ban; + size_t num_free; + for (num_free = 0, ban = free_bans; ban; ban = ban->next) + num_free++; + send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Bans: inuse %zu(%zu) free %zu alloc %zu", + bans_inuse, bans_inuse * sizeof(*ban), num_free, bans_alloc); + } + /** return the struct Membership* that represents a client on a channel * This function finds a struct Membership* which holds the state about * a client on a specific channel. The code is smart enough to iterate @@ -741,9 +759,9 @@ struct Membership *member; assert(0 != cptr); /* - * Servers can always speak on channels. + * Servers and channel services can always speak on channels. */ - if (IsServer(cptr)) + if (IsServer(cptr) || IsChannelService(cptr)) return 1; member = find_channel_member(cptr, chptr); @@ -847,7 +865,11 @@ *mbuf++ = 'k'; if (previous_parameter) strcat(pbuf, " "); +#if defined(DDB) || defined(SERVICES) + if (is_chan_owner(cptr, chptr) || is_chan_op(cptr, chptr) || IsServer(cptr)) { +#else if (is_chan_op(cptr, chptr) || IsServer(cptr)) { +#endif strcat(pbuf, chptr->mode.key); } else strcat(pbuf, "*"); @@ -2951,8 +2973,6 @@ if (!bmatch(ban, newban)) { if (do_free) free_ban(newban); - else - MyFree(newban); return 1; } if (!(ban->flags & (BAN_OVERLAPPED|BAN_DEL))) { @@ -2983,14 +3003,10 @@ /* If no matches were found, fail. */ if (do_free) free_ban(newban); - else - MyFree(newban->banstr); return 3; } if (do_free) free_ban(newban); - else - MyFree(newban->banstr); return 4; } @@ -3047,9 +3063,8 @@ newban->next = 0; newban->flags = ((state->dir == MODE_ADD) ? BAN_ADD : BAN_DEL) | (*flag_p == MODE_BAN ? 0 : BAN_EXCEPTION); - newban->banstr = NULL; set_ban_mask(newban, collapse(pretty_mask(t_str))); - newban->who = cli_name(state->sptr); + ircd_strncpy(newban->who, cli_name(state->sptr), HOSTLEN); newban->when = TStime(); apply_ban(&state->chptr->banlist, newban, 0); } @@ -3081,12 +3096,13 @@ count--; len -= banlen; - MyFree(ban->banstr); - continue; } else if (ban->flags & BAN_DEL) { /* Deleted a ban? */ + char *bandup; + + DupString(bandup, ban->banstr); modebuf_mode_string(state->mbuf, MODE_DEL | MODE_BAN, - ban->banstr, 1); + bandup, 1); if (state->flags & MODE_PARSE_SET) { /* Ok, make it take effect */ if (prevban) /* clip it out of the list... */ @@ -3096,9 +3112,6 @@ count--; len -= banlen; - - ban->banstr = NULL; /* modebuf_mode_string() gave ownership of - * the ban string to state->mbuf */ free_ban(ban); changed++; @@ -3116,7 +3129,6 @@ !(state->flags & MODE_PARSE_BOUNCE)) { count--; len -= banlen; - MyFree(ban->banstr); } else { if (state->flags & MODE_PARSE_SET && MyUser(state->sptr) && (len > (feature_int(FEAT_AVBANLEN) * feature_int(FEAT_MAXBANS)) || @@ -3125,15 +3137,17 @@ ban->banstr); count--; len -= banlen; - MyFree(ban->banstr); } else { + char *bandup; + /* add the ban to the buffer */ + DupString(bandup, ban->banstr); modebuf_mode_string(state->mbuf, MODE_ADD | MODE_BAN, - ban->banstr, 1); + bandup, 1); if (state->flags & MODE_PARSE_SET) { /* create a new ban */ newban = make_ban(ban->banstr); - DupString(newban->who, ban->who); + strcpy(newban->who, ban->who); newban->when = ban->when; newban->flags = ban->flags & BAN_IPMASK; @@ -3149,13 +3163,6 @@ prevban = ban; } /* for (prevban = 0, ban = state->chptr->banlist; ban; ban = nextban) { */ - /* Release all masks of removed bans */ - for (count = 0; count < state->numbans; ++count) { - ban = state->banlist + count; - if (ban->flags & BAN_DEL) - MyFree(ban->banstr); - } - if (changed) /* if we changed the ban list, we must invalidate the bans */ mode_ban_invalidate(state->chptr); } @@ -3436,7 +3443,7 @@ for (i = 0; i < MAXPARA; i++) { /* initialize ops/voices arrays */ state.banlist[i].next = 0; - state.banlist[i].who = 0; + state.banlist[i].who[0] = '\0'; state.banlist[i].when = 0; state.banlist[i].flags = 0; state.cli_change[i].flag = 0; @@ -3819,7 +3826,8 @@ /* RevealDelayedJoin: sends a join for a hidden user */ -void RevealDelayedJoin(struct Membership *member) { +void RevealDelayedJoin(struct Membership *member) +{ ClearDelayedJoin(member); sendcmdto_channel_butserv_butone(member->user, CMD_JOIN, member->channel, member->user, 0, ":%H", member->channel); @@ -3828,14 +3836,15 @@ /* CheckDelayedJoins: checks and clear +d if necessary */ -void CheckDelayedJoins(struct Channel *chan) { +void CheckDelayedJoins(struct Channel *chan) +{ struct Membership *memb2; - + if (chan->mode.mode & MODE_WASDELJOINS) { for (memb2=chan->members;memb2;memb2=memb2->next_member) if (IsDelayedJoin(memb2)) break; - + if (!memb2) { /* clear +d */ chan->mode.mode &= ~MODE_WASDELJOINS; Index: ircd-ircdev/ircd/class.c diff -u ircd-ircdev/ircd/class.c:1.7 ircd-ircdev/ircd/class.c:1.8 --- ircd-ircdev/ircd/class.c:1.7 Fri Apr 22 09:22:13 2005 +++ ircd-ircdev/ircd/class.c Wed Jun 22 00:54:29 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Implementation of connection class handling functions. - * @version $Id: class.c,v 1.7 2005/04/22 16:22:13 zolty Exp $ + * @version $Id: class.c,v 1.8 2005/06/22 07:54:29 zolty Exp $ */ #include "config.h" @@ -199,19 +199,6 @@ return "(null-class)"; } -/** Get connection interval for a connection class. - * @param[in] clptr Connection class to check (or NULL). - * @return If \a clptr != NULL, its connection frequency; else default - * connection frequency. - */ -unsigned int get_con_freq(struct ConnectionClass * clptr) -{ - if (clptr) - return (ConFreq(clptr)); - else - return feature_int(FEAT_CONNECTFREQUENCY); -} - /** Make sure we have a connection class named \a name. * If one does not exist, create it. Then set its ping frequency, * connection frequency, maximum link count, and max SendQ according Index: ircd-ircdev/ircd/client.c diff -u ircd-ircdev/ircd/client.c:1.8 ircd-ircdev/ircd/client.c:1.9 --- ircd-ircdev/ircd/client.c:1.8 Wed Mar 9 10:12:34 2005 +++ ircd-ircdev/ircd/client.c Wed Jun 22 00:54:29 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Implementation of functions for handling local clients. - * @version $Id: client.c,v 1.8 2005/03/09 18:12:34 zolty Exp $ + * @version $Id: client.c,v 1.9 2005/06/22 07:54:29 zolty Exp $ */ #include "config.h" @@ -232,8 +232,8 @@ P(GLINE), P(LOCAL_GLINE), P(JUPE), P(LOCAL_JUPE), P(OPMODE), P(LOCAL_OPMODE), P(SET), P(WHOX), P(BADCHAN), P(LOCAL_BADCHAN), P(SEE_CHAN), P(PROPAGATE), - P(DISPLAY), P(SEE_OPERS), P(FORCE_OPMODE), P(FORCE_LOCAL_OPMODE), - P(WIDE_GLINE), + P(DISPLAY), P(SEE_OPERS), P(WIDE_GLINE), P(LIST_CHAN), + P(FORCE_OPMODE), P(FORCE_LOCAL_OPMODE), P(APASS_OPMODE), #undef P { 0, 0 } }; Index: ircd-ircdev/ircd/ddb.c diff -u ircd-ircdev/ircd/ddb.c:1.10 ircd-ircdev/ircd/ddb.c:1.11 --- ircd-ircdev/ircd/ddb.c:1.10 Wed May 25 09:56:24 2005 +++ ircd-ircdev/ircd/ddb.c Wed Jun 22 00:54:29 2005 @@ -22,7 +22,7 @@ */ /** @file * @brief Implementation of Distributed DataBase. - * @version $Id: ddb.c,v 1.10 2005/05/25 16:56:24 zolty Exp $ + * @version $Id: ddb.c,v 1.11 2005/06/22 07:54:29 zolty Exp $ */ #include "config.h" @@ -56,6 +56,8 @@ * TODO, explicacion del sistema */ +/** Count of allocated Ddb structures. */ +static int ddbCount = 0; /** DDB registers cache. */ static struct Ddb ddb_buf_cache[DDB_BUF_CACHE]; /** Buffer cache. */ @@ -396,6 +398,7 @@ ddb_next(ddb) = ddb_data_table[table][hashi]; ddb_data_table[table][hashi] = ddb; ddb_count_table[table]++; + ddbCount++; return delete; } @@ -426,6 +429,7 @@ delete = 1; DdbFree(ddb); ddb_count_table[table]--; + ddbCount--; break; } ddb3 = &(ddb_next(ddb)); @@ -791,3 +795,15 @@ } } } + +/** Find number of DDB structs allocated and memory used by them. + * @param[out] count_out Receives number of DDB structs allocated. + * @param[out] bytes_out Receives number of bytes used by DDB structs. + */ +void ddb_count_memory(size_t* count_out, size_t* bytes_out) +{ + assert(0 != count_out); + assert(0 != bytes_out); + *count_out = ddbCount; + *bytes_out = ddbCount * sizeof(struct Ddb); +} Index: ircd-ircdev/ircd/ddb_events.c diff -u ircd-ircdev/ircd/ddb_events.c:1.6 ircd-ircdev/ircd/ddb_events.c:1.7 --- ircd-ircdev/ircd/ddb_events.c:1.6 Thu May 26 03:34:13 2005 +++ ircd-ircdev/ircd/ddb_events.c Wed Jun 22 00:54:29 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Events of Distributed DataBases. - * @version $Id: ddb_events.c,v 1.6 2005/05/26 10:34:13 zolty Exp $ + * @version $Id: ddb_events.c,v 1.7 2005/06/22 07:54:29 zolty Exp $ */ #include "config.h" @@ -173,18 +173,15 @@ /* Quitar -q */ for (member = chptr->members; member; member = member->next_member) { - if (IsChanOwner(member)) + if (IsChanOwner(member) && MyUser(member->user)) { ClearChanOwner(member); - if (MyUser(member->user)) - { - sendcmdbotto_channel_butserv_butone(botname, CMD_MODE, - member->channel, NULL, 0, "%H -q %C", - member->channel, member->user); - sendcmdto_serv_butone(&me, CMD_BMODE, NULL, "%s %H -q %C", - DDB_CHANSERV, member->channel, member->user); - } - break; + sendcmdbotto_channel_butserv_butone(botname, CMD_MODE, + member->channel, NULL, 0, "%H -q %C", + member->channel, member->user); + sendcmdto_serv_butone(&me, CMD_BMODE, NULL, "%s %H -q %C", + DDB_CHANSERV, member->channel, member->user); + break; } } Index: ircd-ircdev/ircd/ircd.c diff -u ircd-ircdev/ircd/ircd.c:1.19 ircd-ircdev/ircd/ircd.c:1.20 --- ircd-ircdev/ircd/ircd.c:1.19 Mon May 16 04:22:50 2005 +++ ircd-ircdev/ircd/ircd.c Wed Jun 22 00:54:29 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Entry point and other initialization functions for the daemon. - * @version $Id: ircd.c,v 1.19 2005/05/16 11:22:50 zolty Exp $ + * @version $Id: ircd.c,v 1.20 2005/06/22 07:54:29 zolty Exp $ */ #include "config.h" @@ -691,11 +691,6 @@ log_init(*argv); set_nomem_handler(outofmemory); - if (!init_string()) { - log_write(LS_SYSTEM, L_CRIT, 0, "Failed to initialize string module"); - return 6; - } - initload(); init_list(); init_hash(); Index: ircd-ircdev/ircd/ircd_res.c diff -u ircd-ircdev/ircd/ircd_res.c:1.8 ircd-ircdev/ircd/ircd_res.c:1.9 --- ircd-ircdev/ircd/ircd_res.c:1.8 Sat Apr 2 11:47:35 2005 +++ ircd-ircdev/ircd/ircd_res.c Wed Jun 22 00:54:29 2005 @@ -22,8 +22,8 @@ * */ /* - * A rewrite of Darren Reeds original res.c As there is nothing - * left of Darrens original code, this is now licensed by the hybrid group. + * A rewrite of Darren Reed's original res.c As there is nothing + * left of Darren's original code, this is now licensed by the hybrid group. * (Well, some of the function names are the same, and bits of the structs..) * You can use it where it is useful, free even. Buy us a beer and stuff. * @@ -41,7 +41,7 @@ */ /** @file * @brief IRC resolver functions. - * @version $Id: ircd_res.c,v 1.8 2005/04/02 19:47:35 zolty Exp $ + * @version $Id: ircd_res.c,v 1.9 2005/06/22 07:54:29 zolty Exp $ */ #include "client.h" #include "ircd_alloc.h" @@ -749,7 +749,13 @@ * but its possible its just a broken nameserver with still * valid answers. But lets do some rudimentary logging for now... */ - log_write(LS_RESOLVER, L_ERROR, 0, "irc_res.c bogus type %d", type); + log_write(LS_RESOLVER, L_ERROR, 0, "irc_res.c bogus type %d", type); + + if ((char*)current + rd_length >= (char*)current) + current += rd_length; + else + return(0); + break; } } @@ -780,6 +786,12 @@ return; /* + * check against possibly fake replies + */ + if (!res_ourserver(&lsin)) + return; + + /* * convert DNS reply reader from Network byte order to CPU byte order. */ header = (HEADER *)buf; @@ -795,12 +807,6 @@ if (0 == (request = find_id(header->id))) return; - /* - * check against possibly fake replies - */ - if (!res_ourserver(&lsin)) - return; - if ((header->rcode != NO_ERRORS) || (header->ancount == 0)) { if (SERVFAIL == header->rcode) Index: ircd-ircdev/ircd/ircd_string.c diff -u ircd-ircdev/ircd/ircd_string.c:1.10 ircd-ircdev/ircd/ircd_string.c:1.11 --- ircd-ircdev/ircd/ircd_string.c:1.10 Mon Apr 11 01:45:00 2005 +++ ircd-ircdev/ircd/ircd_string.c Wed Jun 22 00:54:29 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Implementation of string operations. - * @version $Id: ircd_string.c,v 1.10 2005/04/11 08:45:00 zolty Exp $ + * @version $Id: ircd_string.c,v 1.11 2005/06/22 07:54:29 zolty Exp $ */ #include "config.h" @@ -32,7 +32,6 @@ #include "res.h" /* #include <assert.h> -- Now using assert in ircd_log.h */ -#include <string.h> #include <regex.h> #include <sys/types.h> #include <netinet/in.h> @@ -42,68 +41,6 @@ */ #include "chattr.tab.c" - -/* - * Disallow a hostname label to contain anything but a [-a-zA-Z0-9]. - * It may not start or end on a '.'. - * A label may not end on a '-', the maximum length of a label is - * 63 characters. - * On top of that (which seems to be the RFC) we demand that the - * top domain does not contain any digits. - */ -/** Regular expression to match a hostname. - * Matches zero or more alphanumeric labels followed by '.' and a - * final label that may only contain alphabetic characters. - */ -static const char* hostExpr = "^([-0-9A-Za-z]*[0-9A-Za-z]\\.)+[A-Za-z]+$"; -/** Compiled regex to match a hostname. Built from #hostExpr. */ -static regex_t hostRegex; - -/** Regular expression to match an IP address. */ -static const char* addrExpr = - "^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.){1,3}" - "(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$"; -/** Compiled regex to match an IP address. Built from #addrExpr. */ -static regex_t addrRegex; - -/** Initialize the string matching code. */ -int init_string(void) -{ - /* - * initialize matching expressions - * XXX - expressions MUST be correct, don't change expressions - * without testing them. Might be a good idea to exit if these fail, - * important code depends on them. - * TODO: use regerror for an error message - */ - if (regcomp(&hostRegex, hostExpr, REG_EXTENDED | REG_NOSUB)) - return 0; - - if (regcomp(&addrRegex, addrExpr, REG_EXTENDED | REG_NOSUB)) - return 0; - return 1; -} - -/** Check whether \a str looks like a hostname. - * @param[in] str String that might be a hostname. - * @return Non-zero if it conforms to the rules, zero if not. - */ -int string_is_hostname(const char* str) -{ - assert(0 != str); - return (strlen(str) <= HOSTLEN && 0 == regexec(&hostRegex, str, 0, 0, 0)); -} - -/** Check whether \a str looks like an IP address. - * @param[in] str String that might be an address. - * @return Non-zero if it conforms to the rules, zero if not. - */ -int string_is_address(const char* str) -{ - assert(0 != str); - return (0 == regexec(&addrRegex, str, 0, 0, 0)); -} - /** Check whether \a str contains wildcard characters. * @param[in] str String that might contain wildcards. * @return Non-zero if \a str contains naked (non-escaped) wildcards, @@ -235,21 +172,6 @@ * Other functions visible externally */ -/** Find common character attributes for the start of a string. - * @param[in] s Input string to scan. - * @param[in] n Maximum number of bytes to check. - * @return Bitmask of all character attributes shared by the start of \a s. - */ -int strnChattr(const char *s, const size_t n) -{ - const char *rs = s; - unsigned int x = ~0; - int r = n; - while (*rs && r--) - x &= IRCD_CharAttrTab[*rs++ - CHAR_MIN]; - return x; -} - /** Case insensitive string comparison. * @param[in] a First string to compare. * @param[in] b Second string to compare. Index: ircd-ircdev/ircd/list.c diff -u ircd-ircdev/ircd/list.c:1.7 ircd-ircdev/ircd/list.c:1.8 --- ircd-ircdev/ircd/list.c:1.7 Mon Mar 21 10:39:08 2005 +++ ircd-ircdev/ircd/list.c Wed Jun 22 00:54:29 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Singly and doubly linked list manipulation implementation. - * @version $Id: list.c,v 1.7 2005/03/21 18:39:08 zolty Exp $ + * @version $Id: list.c,v 1.8 2005/06/22 07:54:29 zolty Exp $ */ #include "config.h" @@ -52,25 +52,19 @@ #include <unistd.h> /* close */ #include <string.h> -#ifdef DEBUGMODE /** Stores linked list statistics for various types of lists. */ static struct liststats { - int inuse; -} clients, connections, users, servs, links; -#endif + size_t alloc; /**< Number of structures ever allocated. */ + size_t inuse; /**< Number of structures currently in use. */ + size_t mem; /**< Memory used by in-use structures. */ +} clients, connections, servs, links; -/** Count of allocated Client structures. */ -static unsigned int clientAllocCount; /** Linked list of currently unused Client structures. */ static struct Client* clientFreeList; -/** Count of allocated Connection structures. */ -static unsigned int connectionAllocCount; /** Linked list of currently unused Connection structures. */ static struct Connection* connectionFreeList; -/** Count of allocated SLink structures. */ -static unsigned int slinkAllocCount; /** Linked list of currently unused SLink structures. */ static struct SLink* slinkFreeList; @@ -89,21 +83,14 @@ cptr = (struct Client*) MyMalloc(sizeof(struct Client)); cli_next(cptr) = clientFreeList; clientFreeList = cptr; - ++clientAllocCount; + clients.alloc++; con = (struct Connection*) MyMalloc(sizeof(struct Connection)); con_next(con) = connectionFreeList; connectionFreeList = con; - ++connectionAllocCount; + connections.alloc++; } -#ifdef DEBUGMODE - memset(&clients, 0, sizeof(clients)); - memset(&connections, 0, sizeof(connections)); - memset(&users, 0, sizeof(users)); - memset(&servs, 0, sizeof(servs)); - memset(&links, 0, sizeof(links)); -#endif } /** Allocate a new Client structure. @@ -117,13 +104,11 @@ if (!cptr) { cptr = (struct Client*) MyMalloc(sizeof(struct Client)); - ++clientAllocCount; + clients.alloc++; } else clientFreeList = cli_next(cptr); -#ifdef DEBUGMODE clients.inuse++; -#endif memset(cptr, 0, sizeof(struct Client)); @@ -138,9 +123,7 @@ assert(cli_verify(cptr)); assert(0 == cli_connect(cptr)); -#ifdef DEBUGMODE --clients.inuse; -#endif cli_next(cptr) = clientFreeList; clientFreeList = cptr; @@ -159,13 +142,11 @@ if (!con) { con = (struct Connection*) MyMalloc(sizeof(struct Connection)); - ++connectionAllocCount; + connections.alloc++; } else connectionFreeList = con_next(con); -#ifdef DEBUGMODE connections.inuse++; -#endif memset(con, 0, sizeof(struct Connection)); timer_init(&(con_proc(con))); @@ -199,9 +180,7 @@ if (con_listener(con)) release_listener(con_listener(con)); -#ifdef DEBUGMODE --connections.inuse; -#endif con_next(con) = connectionFreeList; connectionFreeList = con; @@ -339,9 +318,8 @@ serv = (struct Server*) MyMalloc(sizeof(struct Server)); assert(0 != serv); memset(serv, 0, sizeof(struct Server)); /* All variables are 0 by default */ -#ifdef DEBUGMODE servs.inuse++; -#endif + servs.alloc++; cli_serv(cptr) = serv; cli_serv(cptr)->lag = 60000; *serv->by = '\0'; @@ -398,9 +376,8 @@ MyFree(cli_serv(cptr)->client_list); MyFree(cli_serv(cptr)->last_error_msg); MyFree(cli_serv(cptr)); -#ifdef DEBUGMODE --servs.inuse; -#endif + --servs.alloc; } free_client(cptr); } @@ -444,30 +421,13 @@ assert(cli_prev(client) == prev); /* Verify that the list hasn't become circular */ assert(cli_next(client) != GlobalClientList); - assert(visited <= clientAllocCount); + assert(visited <= client.alloc); /* Remember what should precede us */ prev = client; } } #endif /* DEBUGMODE */ -/** Find the list element that corresponds to a client. - * @param[in] lp Head of singly linked list. - * @param[in] ptr %Client to search for. - * @return SLink element from \a lp that contains \a ptr, or NULL if none exist. - */ -struct SLink *find_user_link(struct SLink *lp, struct Client *ptr) -{ - if (ptr) { - while (lp) { - if (lp->value.cptr == ptr) - return (lp); - lp = lp->next; - } - } - return NULL; -} - /** Allocate a new SLink element. * Pulls from #slinkFreeList if it contains anything, else it * allocates a new one from the heap. @@ -480,12 +440,10 @@ slinkFreeList = lp->next; else { lp = (struct SLink*) MyMalloc(sizeof(struct SLink)); - ++slinkAllocCount; + links.alloc++; } assert(0 != lp); -#ifdef DEBUGMODE links.inuse++; -#endif return lp; } @@ -498,9 +456,7 @@ lp->next = slinkFreeList; slinkFreeList = lp; } -#ifdef DEBUGMODE links.inuse--; -#endif } /** Add an element to a doubly linked list. @@ -541,42 +497,54 @@ MyFree(lp); } -#ifdef DEBUGMODE +/** Report memory usage of a list to \a cptr. + * @param[in] cptr Client requesting information. + * @param[in] lstats List statistics descriptor. + * @param[in] itemname Plural name of item type. + * @param[in,out] totals If non-null, accumulates item counts and memory usage. + */ +void send_liststats(struct Client *cptr, const struct liststats *lstats, + const char *itemname, struct liststats *totals) +{ + send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":%s: inuse %zu(%zu) alloc %zu", + itemname, lstats->inuse, lstats->mem, lstats->alloc); + if (totals) + { + totals->inuse += lstats->inuse; + totals->alloc += lstats->alloc; + totals->mem += lstats->mem; + } +} + /** Report memory usage of list elements to \a cptr. * @param[in] cptr Client requesting information. * @param[in] name Unused pointer. */ void send_listinfo(struct Client *cptr, char *name) { - int inuse = 0, mem = 0, tmp = 0; + struct liststats total; + struct liststats confs; + struct ConfItem *conf; - send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Clients: inuse: %d(%d)", - clients.inuse, tmp = clients.inuse * sizeof(struct Client)); - mem += tmp; - inuse += clients.inuse; - send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, "Connections: inuse: %d(%d)", - connections.inuse, - tmp = connections.inuse * sizeof(struct Connection)); - mem += tmp; - inuse += connections.inuse; - send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Users: inuse: %d(%d)", - users.inuse, tmp = users.inuse * sizeof(struct User)); - mem += tmp; - inuse += users.inuse; - send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Servs: inuse: %d(%d)", - servs.inuse, tmp = servs.inuse * sizeof(struct Server)); - mem += tmp; - inuse += servs.inuse; - send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Links: inuse: %d(%d)", - links.inuse, tmp = links.inuse * sizeof(struct SLink)); - mem += tmp; - inuse += links.inuse; - send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Confs: inuse: %d(%d)", - GlobalConfCount, tmp = GlobalConfCount * sizeof(struct ConfItem)); - mem += tmp; - inuse += GlobalConfCount; - send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Totals: inuse %d %d", - inuse, mem); -} + memset(&total, 0, sizeof(total)); + + clients.mem = clients.inuse * sizeof(struct Client); + send_liststats(cptr, &clients, "Clients", &total); + + connections.mem = connections.inuse * sizeof(struct Connection); + send_liststats(cptr, &connections, "Connections", &total); -#endif + servs.mem = servs.inuse * sizeof(struct Server); + send_liststats(cptr, &servs, "Servers", &total); + + links.mem = links.inuse * sizeof(struct SLink); + send_liststats(cptr, &links, "Links", &total); + + confs.alloc = GlobalConfCount; + confs.mem = confs.alloc * sizeof(GlobalConfCount); + for (confs.inuse = 0, conf = GlobalConfList; conf; conf = conf->next) + confs.inuse++; + send_liststats(cptr, &confs, "Confs", &total); + + send_liststats(cptr, &total, "Totals", NULL); +} Index: ircd-ircdev/ircd/m_burst.c diff -u ircd-ircdev/ircd/m_burst.c:1.11 ircd-ircdev/ircd/m_burst.c:1.12 --- ircd-ircdev/ircd/m_burst.c:1.11 Thu May 26 03:34:13 2005 +++ ircd-ircdev/ircd/m_burst.c Wed Jun 22 00:54:29 2005 @@ -19,7 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: m_burst.c,v 1.11 2005/05/26 10:34:13 zolty Exp $ + * $Id: m_burst.c,v 1.12 2005/06/22 07:54:29 zolty Exp $ * */ @@ -397,8 +397,11 @@ newban = make_ban(ban); /* create new ban */ - DupString(newban->who, + strcpy(newban->who, cli_name(feature_bool(FEAT_HIS_BANWHO) ? &me : sptr)); + /* Original Unet, TODO-ZOLTAN + strcpy(newban->who, "*"); + */ newban->when = TStime(); newban->flags = BAN_BURSTED; /* set flags */ @@ -632,9 +635,11 @@ /* remove ban from channel */ if (lp->flags & (BAN_OVERLAPPED | BAN_BURST_WIPEOUT)) { + char *bandup; + + DupString(bandup, lp->banstr); modebuf_mode_string(mbuf, MODE_DEL | MODE_BAN, - lp->banstr, 1); /* let it free banstr */ - lp->banstr = NULL; /* do not free this string */ + bandup, 1); /* let it free banstr */ *lp_p = lp->next; /* clip out of list */ free_ban(lp); continue; Index: ircd-ircdev/ircd/m_clearmode.c diff -u ircd-ircdev/ircd/m_clearmode.c:1.8 ircd-ircdev/ircd/m_clearmode.c:1.9 --- ircd-ircdev/ircd/m_clearmode.c:1.8 Mon Mar 21 10:39:08 2005 +++ ircd-ircdev/ircd/m_clearmode.c Wed Jun 22 00:54:29 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: m_clearmode.c,v 1.8 2005/03/21 18:39:08 zolty Exp $ + * $Id: m_clearmode.c,v 1.9 2005/06/22 07:54:29 zolty Exp $ * */ @@ -175,12 +175,13 @@ */ if (del_mode & MODE_BAN) { for (link = chptr->banlist; link; link = next) { + char *bandup; + next = link->next; + DupString(bandup, link->banstr); modebuf_mode_string(&mbuf, MODE_DEL | MODE_BAN, /* delete ban */ - link->banstr, 1); - link->banstr = NULL; /* modebuf_mode_string() gave ownership of - * banstr to mbuf */ + bandup, 1); free_ban(link); } Index: ircd-ircdev/ircd/m_dbq.c diff -u ircd-ircdev/ircd/m_dbq.c:1.4 ircd-ircdev/ircd/m_dbq.c:1.5 --- ircd-ircdev/ircd/m_dbq.c:1.4 Mon May 16 03:17:27 2005 +++ ircd-ircdev/ircd/m_dbq.c Wed Jun 22 00:54:29 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Handlers for DBQ command. - * @version $Id: m_dbq.c,v 1.4 2005/05/16 10:17:27 zolty Exp $ + * @version $Id: m_dbq.c,v 1.5 2005/06/22 07:54:29 zolty Exp $ */ #include "config.h" @@ -108,7 +108,8 @@ } } - + sendwallto_group_butone(&me, WALL_WALLOPS, 0, + "Remote DBQ %c %s From %#C", table, key, sptr); log_write(LS_DDB, L_INFO, 0, "Remote DBQ %c %s From %#C", table, key, sptr); if (!ddb_table_is_resident(table)) @@ -197,6 +198,8 @@ } } + sendwallto_group_butone(&me, WALL_WALLOPS, 0, + "DBQ %c %s From %#C", table, key, sptr); log_write(LS_DDB, L_INFO, 0, "DBQ %c %s From %#C", table, key, cptr); if (!ddb_table_is_resident(table)) Index: ircd-ircdev/ircd/m_endburst.c diff -u ircd-ircdev/ircd/m_endburst.c:1.5 ircd-ircdev/ircd/m_endburst.c:1.6 --- ircd-ircdev/ircd/m_endburst.c:1.5 Mon Jan 10 04:23:02 2005 +++ ircd-ircdev/ircd/m_endburst.c Wed Jun 22 00:54:29 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: m_endburst.c,v 1.5 2005/01/10 12:23:02 zolty Exp $ + * $Id: m_endburst.c,v 1.6 2005/06/22 07:54:29 zolty Exp $ * */ @@ -126,16 +126,17 @@ for (chan = GlobalChannelList; chan; chan = next_chan) { next_chan = chan->next; - if (!chan->members) { /* empty channel */ - if ((chan->mode.mode & MODE_BURSTADDED)) - sub1_from_channel(chan); /* New empty channel, schedule it for removal. */ - /* FIX-ZOLTAN Añadido */ - else - sendto_opmask_butone(0, SNO_OLDSNO, "Empty channel %H not added by " - "BURST!", chan); + if (!chan->members && (chan->mode.mode & MODE_BURSTADDED)) { + /* Newly empty channel, schedule it for removal. */ + chan->mode.mode &= ~MODE_BURSTADDED; + sub1_from_channel(chan); + } else { + chan->mode.mode &= ~MODE_BURSTADDED; +#if !defined(UNDERNET) && !defined(DDB) + sendto_opmask_butone(0, SNO_OLDSNO, "Empty channel %H not added by " + "BURST!", chan); +#endif } - - chan->mode.mode &= ~MODE_BURSTADDED; } return 0; Index: ircd-ircdev/ircd/m_invite.c diff -u ircd-ircdev/ircd/m_invite.c:1.11 ircd-ircdev/ircd/m_invite.c:1.12 --- ircd-ircdev/ircd/m_invite.c:1.11 Sat May 7 15:23:40 2005 +++ ircd-ircdev/ircd/m_invite.c Wed Jun 22 00:54:29 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: m_invite.c,v 1.11 2005/05/07 22:23:40 zolty Exp $ + * $Id: m_invite.c,v 1.12 2005/06/22 07:54:29 zolty Exp $ * */ @@ -147,7 +147,7 @@ return 0; if (!(chptr = FindChannel(parv[2]))) { - send_reply(sptr, ERR_NOTONCHANNEL, parv[2]); + send_reply(sptr, ERR_NOSUCHCHANNEL, parv[2]); return 0; } Index: ircd-ircdev/ircd/m_server.c diff -u ircd-ircdev/ircd/m_server.c:1.8 ircd-ircdev/ircd/m_server.c:1.9 --- ircd-ircdev/ircd/m_server.c:1.8 Sat Apr 2 11:47:35 2005 +++ ircd-ircdev/ircd/m_server.c Wed Jun 22 00:54:29 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Handlers for the SERVER command. - * @version $Id: m_server.c,v 1.8 2005/04/02 19:47:35 zolty Exp $ + * @version $Id: m_server.c,v 1.9 2005/06/22 07:54:29 zolty Exp $ */ #include "config.h" @@ -588,7 +588,7 @@ log_write(LS_NETWORK, L_NOTICE, LOG_NOSNOTICE, "Received unauthorized " "connection from %C [%s]", cptr, ircd_ntoa(&cli_ip(cptr))); - return exit_client(cptr, cptr, &me, "No C:line"); + return exit_client(cptr, cptr, &me, "No Connect block"); } host = cli_name(cptr); Index: ircd-ircdev/ircd/m_topic.c diff -u ircd-ircdev/ircd/m_topic.c:1.7 ircd-ircdev/ircd/m_topic.c:1.8 --- ircd-ircdev/ircd/m_topic.c:1.7 Mon Jan 10 04:23:03 2005 +++ ircd-ircdev/ircd/m_topic.c Wed Jun 22 00:54:30 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: m_topic.c,v 1.7 2005/01/10 12:23:03 zolty Exp $ + * $Id: m_topic.c,v 1.8 2005/06/22 07:54:30 zolty Exp $ * */ @@ -110,7 +110,12 @@ { /* allow off-channel services to set the topic of any channel */ } +#if defined(DDB) || defined(SERVICES) + else if ((chptr->mode.mode & MODE_TOPICLIMIT) && + !(is_chan_owner(sptr, chptr) || is_chan_op(sptr, chptr))) +#else else if ((chptr->mode.mode & MODE_TOPICLIMIT) && !is_chan_op(sptr, chptr)) +#endif { /* if +t and not @'d, return an error and ignore the topic */ send_reply(sptr, ERR_CHANOPRIVSNEEDED, chptr->chname); Index: ircd-ircdev/ircd/match.c diff -u ircd-ircdev/ircd/match.c:1.9 ircd-ircdev/ircd/match.c:1.10 --- ircd-ircdev/ircd/match.c:1.9 Fri Apr 22 09:22:13 2005 +++ ircd-ircdev/ircd/match.c Wed Jun 22 00:54:30 2005 @@ -22,7 +22,7 @@ */ /** @file * @brief Functions to match strings against IRC mask strings. - * @version $Id: match.c,v 1.9 2005/04/22 16:22:13 zolty Exp $ + * @version $Id: match.c,v 1.10 2005/06/22 07:54:30 zolty Exp $ */ #include "config.h" @@ -194,59 +194,56 @@ { const char *m = mask, *n = name; const char *m_tmp = mask, *n_tmp = name; - int wild = 0; - - for (;;) - { - if (*m == '*') { - while (*m == '*') /* clean up any additional wildcards */ - m++; - - m_tmp = m; - n_tmp = n; - wild = 1; - } - if (*m == '\\') /* next wildcard is disregarded */ - m++; - - if (!*m) { - if (!*n) - return 0; /* match */ - - for (m--; (m > mask) && (*m == '?'); m--); - ; - - if (*m == '*' && (m > mask)) - return 0; /* match */ - - if (!wild) - return 1; - - m = m_tmp; - n = ++n_tmp; - } - else if (!*n) { - while (*m == '*') /* clean up any additional wildcards */ - m++; + int star_p; - return (*m != 0); - } - if (ToLower(*m) != ToLower(*n) && *m != '?') { - if (!wild) - return 1; /* failure! */ - - m = m_tmp; - n = ++n_tmp; + for (;;) switch (*m) { + case '\0': + if (!*n) + return 0; + backtrack: + if (m_tmp == mask) + return 1; + m = m_tmp; + n = ++n_tmp; + break; + case '\\': + m++; + /* allow escaping to force capitalization */ + if (*m++ != *n++) + return 1; + break; + case '*': case '?': + for (star_p = 0; ; m++) { + if (*m == '*') + star_p = 1; + else if (*m == '?') { + if (!*n++) + goto backtrack; + } else break; } - else { - if (*m) - m++; - if (*n) - n++; + if (star_p) { + if (!*m) + return 0; + else if (*m == '\\') { + m_tmp = ++m; + if (!*m) + return 1; + for (n_tmp = n; *n && *n != *m; n++) ; + } else { + m_tmp = m; + for (n_tmp = n; *n && ToLower(*n) != ToLower(*m); n++) ; + } } + /* and fall through */ + default: + if (!*n) + return *m != '\0'; + if (ToLower(*m) != ToLower(*n)) + goto backtrack; + m++; + n++; + break; } - - return 1; /* no match! */ } /* @@ -889,7 +886,7 @@ if (mask[0] == '.' || mask[0] == '/') return 0; for (p = mask; *p; ++p) - if (*p != '*' && *p != '?' && *p != '.' && *p != '/') + if (*p != '*' && *p != '.' && *p != '/') { if (!IsDigit(*p)) return 0; Index: ircd-ircdev/ircd/s_bsd.c diff -u ircd-ircdev/ircd/s_bsd.c:1.14 ircd-ircdev/ircd/s_bsd.c:1.15 --- ircd-ircdev/ircd/s_bsd.c:1.14 Mon May 16 03:17:27 2005 +++ ircd-ircdev/ircd/s_bsd.c Wed Jun 22 00:54:30 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Functions that now (or in the past) relied on BSD APIs. - * @version $Id: s_bsd.c,v 1.14 2005/05/16 10:17:27 zolty Exp $ + * @version $Id: s_bsd.c,v 1.15 2005/06/22 07:54:30 zolty Exp $ */ #include "config.h" @@ -793,10 +793,10 @@ if (!find_conf_byhost(cli_confs(cptr), aconf->host, CONF_SERVER)) { sendto_opmask_butone(0, SNO_OLDSNO, "Host %s is not enabled for " - "connecting: no C-line", aconf->name); + "connecting: no Connect block", aconf->name); if (by && IsUser(by) && !MyUser(by)) { sendcmdto_one(&me, CMD_NOTICE, by, "%C :Connect to host %s failed: no " - "C-line", by, aconf->name); + "Connect block", by, aconf->name); } det_confs_butmask(cptr, 0); free_client(cptr); Index: ircd-ircdev/ircd/s_conf.c diff -u ircd-ircdev/ircd/s_conf.c:1.17 ircd-ircdev/ircd/s_conf.c:1.18 --- ircd-ircdev/ircd/s_conf.c:1.17 Mon May 23 01:58:37 2005 +++ ircd-ircdev/ircd/s_conf.c Wed Jun 22 00:54:30 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief ircd configuration file driver - * @version $Id: s_conf.c,v 1.17 2005/05/23 08:58:37 zolty Exp $ + * @version $Id: s_conf.c,v 1.18 2005/06/22 07:54:30 zolty Exp $ */ #include "config.h" @@ -133,9 +133,7 @@ aconf = (struct ConfItem*) MyMalloc(sizeof(struct ConfItem)); assert(0 != aconf); -#ifdef DEBUGMODE ++GlobalConfCount; -#endif memset(aconf, 0, sizeof(struct ConfItem)); aconf->status = type; aconf->next = GlobalConfList; @@ -163,9 +161,7 @@ MyFree(aconf->name); MyFree(aconf->hub_limit); MyFree(aconf); -#ifdef DEBUGMODE --GlobalConfCount; -#endif } /** Disassociate configuration from the client. @@ -1170,7 +1166,8 @@ if (IsConnecting(cptr) || IsHandshake(cptr)) { c_conf = find_conf_byname(lp, cli_name(cptr), CONF_SERVER); if (!c_conf) { - sendto_opmask_butone(0, SNO_OLDSNO, "Connect Error: lost C:line for %s", + sendto_opmask_butone(0, SNO_OLDSNO, + "Connect Error: lost Connect block for %s", cli_name(cptr)); det_confs_butmask(cptr, 0); return -1; Index: ircd-ircdev/ircd/s_debug.c diff -u ircd-ircdev/ircd/s_debug.c:1.9 ircd-ircdev/ircd/s_debug.c:1.10 --- ircd-ircdev/ircd/s_debug.c:1.9 Wed Mar 23 10:34:52 2005 +++ ircd-ircdev/ircd/s_debug.c Wed Jun 22 00:54:30 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Debug support for the ircd. - * @version $Id: s_debug.c,v 1.9 2005/03/23 18:34:52 zolty Exp $ + * @version $Id: s_debug.c,v 1.10 2005/06/22 07:54:30 zolty Exp $ */ #include "config.h" @@ -29,6 +29,7 @@ #include "channel.h" #include "class.h" #include "client.h" +#include "ddb.h" #include "gline.h" #include "hash.h" #include "ircd_alloc.h" @@ -39,6 +40,7 @@ #include "ircd.h" #include "jupe.h" #include "list.h" +#include "listener.h" #include "motd.h" #include "msgq.h" #include "numeric.h" @@ -47,6 +49,7 @@ #include "s_bsd.h" #include "s_conf.h" #include "s_stats.h" +#include "s_user.h" #include "send.h" #include "struct.h" #include "sys.h" @@ -218,7 +221,6 @@ struct Client *acptr; struct SLink *link; struct Ban *ban; -/* struct Watch *watch; */ struct Channel *chptr; struct ConfItem *aconf; const struct ConnectionClass* cltmp; @@ -229,12 +231,12 @@ cn = 0, /* connections */ ch = 0, /* channels */ lcc = 0, /* local client conf links */ - us = 0, /* user structs */ chi = 0, /* channel invites */ chb = 0, /* channel bans */ wwu = 0, /* whowas users */ cl = 0, /* classes */ co = 0, /* conf lines */ + listeners = 0, /* listeners */ memberships = 0; /* channel memberships */ int usi = 0, /* users invited */ @@ -247,9 +249,17 @@ chbm = 0, /* memory used by channel bans */ cm = 0, /* memory used by clients */ cnm = 0, /* memory used by connections */ + us = 0, /* user structs */ + usm = 0, /* memory used by user structs */ awm = 0, /* memo... [truncated message content] |