From 456e5b3d641ed7bb69fbe3aec4873f89e9eee668 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sat, 5 Dec 2009 20:48:02 +0100 Subject: [PATCH 1/7] Fix crashes when there are no alias blocks in the conf. --- src/newconf.c | 3 --- src/s_conf.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/newconf.c b/src/newconf.c index 2d0b63dd9..12893dd0d 100644 --- a/src/newconf.c +++ b/src/newconf.c @@ -1722,9 +1722,6 @@ conf_end_alias(struct TopConf *tc) return -1; } - if (!alias_dict) - alias_dict = irc_dictionary_create(strcasecmp); - irc_dictionary_add(alias_dict, yy_alias->name, yy_alias); return 0; diff --git a/src/s_conf.c b/src/s_conf.c index 7acb57343..47d803465 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -834,6 +834,9 @@ set_default_conf(void) ConfigFileEntry.throttle_duration = 60; ServerInfo.default_max_clients = MAXCONNECTIONS; + + if (!alias_dict) + alias_dict = irc_dictionary_create(strcasecmp); } #undef YES From c127b45b83ee6e7f53b57cd81340cb668fbeabb4 Mon Sep 17 00:00:00 2001 From: Stephen Bennett Date: Tue, 8 Dec 2009 19:22:55 +0000 Subject: [PATCH 2/7] Revert all presence-related changes --- include/client.h | 13 +--- include/ircd_defs.h | 11 +-- include/numeric.h | 5 -- include/send.h | 2 - include/stdinc.h | 1 - modules/Makefile.in | 1 - modules/core/m_message.c | 5 +- modules/m_away.c | 18 +++-- modules/m_cap.c | 3 +- modules/m_invite.c | 5 +- modules/m_presence.c | 141 --------------------------------------- modules/m_stats.c | 14 +++- modules/m_userhost.c | 4 +- modules/m_who.c | 2 +- modules/m_whois.c | 18 +---- src/client.c | 68 ++++--------------- src/messages.tab | 8 +-- src/s_serv.c | 6 +- src/send.c | 129 ----------------------------------- 19 files changed, 58 insertions(+), 396 deletions(-) delete mode 100644 modules/m_presence.c diff --git a/include/client.h b/include/client.h index 26809f3d8..178a9a37a 100644 --- a/include/client.h +++ b/include/client.h @@ -92,10 +92,10 @@ struct User { rb_dlink_list channel; /* chain of channel pointer blocks */ rb_dlink_list invited; /* chain of invite pointer blocks */ + char *away; /* pointer to away message */ int refcnt; /* Number of times this block is referenced */ char suser[NICKLEN+1]; - struct Dictionary *metadata; }; struct Server @@ -119,12 +119,6 @@ struct ZipStats double out_ratio; }; -struct MetadataEntry -{ - char key[METADATAKEYLEN]; - char value[METADATAVALUELEN]; -}; - struct Client { rb_dlink_node node; @@ -456,7 +450,6 @@ struct ListClient #define CLICAP_MULTI_PREFIX 0x0001 #define CLICAP_SASL 0x0002 -#define CLICAP_PRESENCE 0x0004 /* * flags macros. @@ -614,8 +607,4 @@ extern char *generate_uid(void); void allocate_away(struct Client *); void free_away(struct Client *); -const char *get_metadata(struct Client *, const char *); -void set_metadata(struct Client *, const char *, const char *); -void delete_metadata(struct Client *, const char *); - #endif /* INCLUDED_client_h */ diff --git a/include/ircd_defs.h b/include/ircd_defs.h index cb26b953d..686cea487 100644 --- a/include/ircd_defs.h +++ b/include/ircd_defs.h @@ -111,18 +111,13 @@ #define BANREASONLEN 390 /* kline/dline */ #define AWAYLEN TOPICLEN #define KILLLEN 200 /* with Killed (nick ()) added this should fit in quit */ -#define METADATAKEYLEN 31 -/* :012345678901234567890123456789012345678901234567890123456789123 792 * 012345678901234567890123456789 012345678901234567890123456789 : - * takes at most 137 bytes - * :123456789 ENCAP * PRESENCE 012345678901234567890123456789 : - * takes at most 63 bytes - * */ -#define METADATAVALUELEN 300 /* 23+1 for \0 */ #define KEYLEN 24 #define BUFSIZE 512 /* WARNING: *DONT* CHANGE THIS!!!! */ -#define OPERNICKLEN (NICKLEN*2) /* Length of OPERNICKs. */ +#define MAXRECIPIENTS 20 +#define MAXBANLENGTH 1024 +#define OPERNICKLEN NICKLEN*2 /* Length of OPERNICKs. */ #define USERHOST_REPLYLEN (NICKLEN+HOSTLEN+USERLEN+5) #define MAX_DATE_STRING 32 /* maximum string length for a date string */ diff --git a/include/numeric.h b/include/numeric.h index 8ff4d96dc..6b449e48d 100644 --- a/include/numeric.h +++ b/include/numeric.h @@ -359,11 +359,6 @@ extern const char *form_str(int); #define RPL_SCANMATCHED 750 #define RPL_SCANUMODES 751 -#define RPL_METADATASET 790 -#define RPL_METADATAREM 791 -#define RPL_METADATACHG 792 -#define RPL_WHOISMETADATA 793 - #define RPL_LOGGEDIN 900 #define RPL_LOGGEDOUT 901 #define ERR_NICKLOCKED 902 diff --git a/include/send.h b/include/send.h index 6c55bb5f2..9e5c16b6f 100644 --- a/include/send.h +++ b/include/send.h @@ -64,9 +64,7 @@ extern void sendto_channel_opmod(struct Client *one, struct Client *source_p, extern void sendto_channel_local(int type, struct Channel *, const char *, ...) AFP(3, 4); extern void sendto_channel_local_butone(struct Client *, int type, struct Channel *, const char *, ...) AFP(4, 5); extern void sendto_common_channels_local(struct Client *, const char *, ...) AFP(2, 3); -extern void sendto_common_channels_local_with_capability(struct Client *, int, const char *, ...) AFP(3, 4); extern void sendto_common_channels_local_butone(struct Client *, const char *, ...) AFP(2, 3); -extern void sendto_common_channels_local_with_capability_butone(struct Client *, int, const char *, ...) AFP(3, 4); extern void sendto_match_butone(struct Client *, struct Client *, diff --git a/include/stdinc.h b/include/stdinc.h index 30331e9e9..8efe33be7 100644 --- a/include/stdinc.h +++ b/include/stdinc.h @@ -26,7 +26,6 @@ #include "ratbox_lib.h" #include "config.h" /* Gotta pull in the autoconf stuff */ #include "ircd_defs.h" /* Needed for some reasons here -- dwr */ -#include "irc_dictionary.h" /* AIX requires this to be the first thing in the file. */ #ifdef __GNUC__ diff --git a/modules/Makefile.in b/modules/Makefile.in index 1d5426715..f1807cf58 100644 --- a/modules/Makefile.in +++ b/modules/Makefile.in @@ -83,7 +83,6 @@ TSRCS = \ m_ping.c \ m_pong.c \ m_post.c \ - m_presence.c \ m_privs.c \ m_rehash.c \ m_restart.c \ diff --git a/modules/core/m_message.c b/modules/core/m_message.c index 62db04d78..c89325038 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -744,7 +744,6 @@ static void msg_client(int p_or_n, const char *command, struct Client *source_p, struct Client *target_p, const char *text) { - const char *awaymsg; int do_floodcount = 0; if(MyClient(source_p)) @@ -789,9 +788,9 @@ msg_client(int p_or_n, const char *command, return; } - if(MyConnect(source_p) && (p_or_n != NOTICE) && target_p->user && (awaymsg = get_metadata(target_p, "away")) != NULL) + if(MyConnect(source_p) && (p_or_n != NOTICE) && target_p->user && target_p->user->away) sendto_one_numeric(source_p, RPL_AWAY, form_str(RPL_AWAY), - target_p->name, awaymsg); + target_p->name, target_p->user->away); if(MyClient(target_p)) { diff --git a/modules/m_away.c b/modules/m_away.c index d8eb87640..02b510d8e 100644 --- a/modules/m_away.c +++ b/modules/m_away.c @@ -78,22 +78,30 @@ m_away(struct Client *client_p, struct Client *source_p, int parc, const char *p if(parc < 2 || EmptyString(parv[1])) { /* Marking as not away */ - if(get_metadata(source_p, "away") != NULL) + if(source_p->user->away != NULL) { /* we now send this only if they were away before --is */ sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s AWAY", use_id(source_p)); - delete_metadata(source_p, "away"); + free_away(source_p); } if(MyConnect(source_p)) sendto_one_numeric(source_p, RPL_UNAWAY, form_str(RPL_UNAWAY)); return 0; } - set_metadata(source_p, "away", parv[1]); - sendto_server(client_p, NULL, CAP_TS6, NOCAPS, - ":%s AWAY :%s", use_id(source_p), parv[1]); + + if(source_p->user->away == NULL) + { + allocate_away(source_p); + rb_strlcpy(source_p->user->away, parv[1], AWAYLEN); + sendto_server(client_p, NULL, CAP_TS6, NOCAPS, + ":%s AWAY :%s", use_id(source_p), source_p->user->away); + } else { + rb_strlcpy(source_p->user->away, parv[1], AWAYLEN); + } + if(MyConnect(source_p)) sendto_one_numeric(source_p, RPL_NOWAWAY, form_str(RPL_NOWAWAY)); diff --git a/modules/m_cap.c b/modules/m_cap.c index f394caeb1..9fa94d37c 100644 --- a/modules/m_cap.c +++ b/modules/m_cap.c @@ -69,8 +69,7 @@ static struct clicap int namelen; } clicap_list[] = { _CLICAP("multi-prefix", CLICAP_MULTI_PREFIX, 0, 0), - _CLICAP("sasl", CLICAP_SASL, 0, 0), - _CLICAP("presence", CLICAP_PRESENCE, 0, 0) + _CLICAP("sasl", CLICAP_SASL, 0, 0) }; #define CLICAP_LIST_LEN (sizeof(clicap_list) / sizeof(struct clicap)) diff --git a/modules/m_invite.c b/modules/m_invite.c index cf475f934..cff1f83b8 100644 --- a/modules/m_invite.c +++ b/modules/m_invite.c @@ -58,7 +58,6 @@ static void add_invite(struct Channel *, struct Client *); static int m_invite(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { - const char *awaymsg; struct Client *target_p; struct Channel *chptr; struct membership *msptr; @@ -166,9 +165,9 @@ m_invite(struct Client *client_p, struct Client *source_p, int parc, const char sendto_one(source_p, form_str(RPL_INVITING), me.name, source_p->name, target_p->name, parv[2]); - if((awaymsg = get_metadata(target_p, "away")) != NULL) + if(target_p->user->away) sendto_one_numeric(source_p, RPL_AWAY, form_str(RPL_AWAY), - target_p->name, awaymsg); + target_p->name, target_p->user->away); } /* invite timestamp */ else if(parc > 3 && !EmptyString(parv[3])) diff --git a/modules/m_presence.c b/modules/m_presence.c deleted file mode 100644 index 41c5e8ade..000000000 --- a/modules/m_presence.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * charybdis: an advanced ircd. - * m_presence.c: IRC presence protocol implementation - * - * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center - * Copyright (C) 1996-2002 Hybrid Development Team - * Copyright (C) 2002-2005 ircd-ratbox development team - * Copyright (c) 2009 William Pitcock - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * 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_away.c 3370 2007-04-03 10:15:39Z nenolod $ - */ - -#include "stdinc.h" -#include "client.h" -#include "match.h" -#include "ircd.h" -#include "numeric.h" -#include "send.h" -#include "msg.h" -#include "parse.h" -#include "modules.h" -#include "s_conf.h" -#include "s_serv.h" -#include "packet.h" - -static int m_presence(struct Client *, struct Client *, int, const char **); -static int me_presence(struct Client *, struct Client *, int, const char **); - -struct Message presence_msgtab = { - "PRESENCE", 0, 0, 0, MFLG_SLOW, - {mg_unreg, {m_presence, 2}, {m_presence, 2}, mg_ignore, {me_presence, 2}, {m_presence, 2}} -}; - -mapi_clist_av1 presence_clist[] = { &presence_msgtab, NULL }; -DECLARE_MODULE_AV1(presence, NULL, NULL, presence_clist, NULL, NULL, "$Revision$"); - -/* -** m_presence -** parv[1] = key -** parv[2] = setting -*/ -static int -m_presence(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) -{ - const char *val; - - if(MyClient(source_p) && !IsFloodDone(source_p)) - flood_endgrace(source_p); - - if(!IsClient(source_p)) - return 0; - - if (!irccmp(parv[1], "away")) - { - sendto_one_notice(source_p, ":Please use /AWAY to change your away status"); - return 0; - } - - if((parc < 3 || EmptyString(parv[2])) && !EmptyString(parv[1])) - { - if ((val = get_metadata(source_p, parv[1])) != NULL) - { - delete_metadata(source_p, parv[1]); - - sendto_server(client_p, NULL, CAP_TS6, NOCAPS, - ":%s ENCAP * PRESENCE %s", use_id(source_p), parv[1]); - } - if (MyConnect(source_p)) - sendto_one_numeric(source_p, RPL_METADATAREM, form_str(RPL_METADATAREM), parv[1]); - return 0; - } - - if (strlen(parv[1]) >= METADATAKEYLEN) - { - sendto_one_notice(source_p, ":Metadata key too long"); - return 0; - } - - if ((val = get_metadata(source_p, parv[1])) != NULL) - { - if (!strcmp(parv[2], val)) - return 0; - } - - set_metadata(source_p, parv[1], parv[2]); - sendto_server(client_p, NULL, CAP_TS6, NOCAPS, - ":%s ENCAP * PRESENCE %s :%s", use_id(source_p), parv[1], parv[2]); - - if(MyConnect(source_p)) - sendto_one_numeric(source_p, RPL_METADATASET, form_str(RPL_METADATASET), parv[1]); - - return 0; -} - -/* -** me_presence -** parv[1] = key -** parv[2] = setting -*/ -static int -me_presence(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) -{ - const char *val; - - if(!IsClient(source_p)) - return 0; - - if((parc < 3 || EmptyString(parv[2])) && !EmptyString(parv[1])) - { - delete_metadata(source_p, parv[1]); - return 0; - } - - if (strlen(parv[1]) >= METADATAKEYLEN) - return 0; - - if ((val = get_metadata(source_p, parv[1])) != NULL) - { - if (!strcmp(parv[2], val)) - return 0; - } - - set_metadata(source_p, parv[1], parv[2]); - - return 0; -} diff --git a/modules/m_stats.c b/modules/m_stats.c index 12adc9c3f..29e7c7ed7 100644 --- a/modules/m_stats.c +++ b/modules/m_stats.c @@ -704,7 +704,7 @@ stats_operedup (struct Client *source_p) if(IsOperInvis(target_p) && !IsOper(source_p)) continue; - if(get_metadata(target_p, "away")) + if(target_p->user->away) continue; count++; @@ -1137,6 +1137,7 @@ stats_memory (struct Client *source_p) int conf_count = 0; /* conf lines */ int users_invited_count = 0; /* users invited */ int user_channels = 0; /* users in channels */ + int aways_counted = 0; size_t number_servers_cached; /* number of servers cached by scache */ size_t channel_memory = 0; @@ -1145,6 +1146,7 @@ stats_memory (struct Client *source_p) size_t channel_invex_memory = 0; size_t channel_quiet_memory = 0; + size_t away_memory = 0; /* memory used by aways */ size_t ww = 0; /* whowas array count */ size_t wwm = 0; /* whowas array memory used */ size_t conf_memory = 0; /* memory used by conf lines */ @@ -1179,6 +1181,11 @@ stats_memory (struct Client *source_p) users_counted++; users_invited_count += rb_dlink_list_length(&target_p->user->invited); user_channels += rb_dlink_list_length(&target_p->user->channel); + if(target_p->user->away) + { + aways_counted++; + away_memory += (strlen(target_p->user->away) + 1); + } } } @@ -1239,9 +1246,10 @@ stats_memory (struct Client *source_p) (unsigned long) users_invited_count * sizeof(rb_dlink_node)); sendto_one_numeric(source_p, RPL_STATSDEBUG, - "z :User channels %u(%lu)", + "z :User channels %u(%lu) Aways %u(%d)", user_channels, - (unsigned long) user_channels * sizeof(rb_dlink_node)); + (unsigned long) user_channels * sizeof(rb_dlink_node), + aways_counted, (int) away_memory); sendto_one_numeric(source_p, RPL_STATSDEBUG, "z :Attached confs %u(%lu)", diff --git a/modules/m_userhost.c b/modules/m_userhost.c index 766334caf..108974e74 100644 --- a/modules/m_userhost.c +++ b/modules/m_userhost.c @@ -84,7 +84,7 @@ m_userhost(struct Client *client_p, struct Client *source_p, int parc, const cha rl = rb_sprintf(response, "%s%s=%c%s@%s ", target_p->name, IsOper(target_p) ? "*" : "", - (get_metadata(target_p, "away") != NULL) ? '-' : '+', + (target_p->user->away) ? '-' : '+', target_p->username, target_p->sockhost); } @@ -93,7 +93,7 @@ m_userhost(struct Client *client_p, struct Client *source_p, int parc, const cha rl = rb_sprintf(response, "%s%s=%c%s@%s ", target_p->name, IsOper(target_p) ? "*" : "", - (get_metadata(target_p, "away") != NULL) ? '-' : '+', + (target_p->user->away) ? '-' : '+', target_p->username, target_p->host); } diff --git a/modules/m_who.c b/modules/m_who.c index 834ab7544..b8ffc873d 100644 --- a/modules/m_who.c +++ b/modules/m_who.c @@ -467,7 +467,7 @@ do_who(struct Client *source_p, struct Client *target_p, struct membership *mspt const char *q; rb_sprintf(status, "%c%s%s", - (get_metadata(target_p, "away") != NULL) ? 'G' : 'H', IsOper(target_p) ? "*" : "", msptr ? find_channel_status(msptr, fmt->fields || IsCapable(source_p, CLICAP_MULTI_PREFIX)) : ""); + target_p->user->away ? 'G' : 'H', IsOper(target_p) ? "*" : "", msptr ? find_channel_status(msptr, fmt->fields || IsCapable(source_p, CLICAP_MULTI_PREFIX)) : ""); if (fmt->fields == 0) sendto_one(source_p, form_str(RPL_WHOREPLY), me.name, diff --git a/modules/m_whois.c b/modules/m_whois.c index 950dbfad6..ca8dc2384 100644 --- a/modules/m_whois.c +++ b/modules/m_whois.c @@ -228,7 +228,6 @@ do_whois(struct Client *client_p, struct Client *source_p, int parc, const char static void single_whois(struct Client *source_p, struct Client *target_p, int operspy) { - const char *awaymsg; char buf[BUFSIZE]; rb_dlink_node *ptr; struct membership *msptr; @@ -240,8 +239,6 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy) hook_data_client hdata; int visible; int extra_space = 0; - struct DictionaryIter iter; - struct MetadataEntry *md; if(target_p->user == NULL) { @@ -307,9 +304,9 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy) target_p->name, target_p->servptr->name, target_p->servptr->info); - if((awaymsg = get_metadata(target_p, "away")) != NULL) + if(target_p->user->away) sendto_one_numeric(source_p, RPL_AWAY, form_str(RPL_AWAY), - target_p->name, awaymsg); + target_p->name, target_p->user->away); if(IsOper(target_p)) { @@ -369,17 +366,6 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy) } } - DICTIONARY_FOREACH(md, &iter, target_p->user->metadata) - { - /* XXX: hack around "away" for legacy clients. --nenolod */ - if (!irccmp(md->key, "away")) - continue; - - sendto_one_numeric(source_p, RPL_WHOISMETADATA, - form_str(RPL_WHOISMETADATA), - target_p->name, md->key, md->value); - } - hdata.client = source_p; hdata.target = target_p; diff --git a/src/client.c b/src/client.c index a395ec81c..7aa5b9416 100644 --- a/src/client.c +++ b/src/client.c @@ -76,7 +76,7 @@ static rb_bh *client_heap = NULL; static rb_bh *lclient_heap = NULL; static rb_bh *pclient_heap = NULL; static rb_bh *user_heap = NULL; -static rb_bh *metadata_heap = NULL; +static rb_bh *away_heap = NULL; static char current_uid[IDLEN]; struct Dictionary *nd_dict = NULL; @@ -120,7 +120,7 @@ init_client(void) lclient_heap = rb_bh_create(sizeof(struct LocalUser), LCLIENT_HEAP_SIZE, "lclient_heap"); pclient_heap = rb_bh_create(sizeof(struct PreClient), PCLIENT_HEAP_SIZE, "pclient_heap"); user_heap = rb_bh_create(sizeof(struct User), USER_HEAP_SIZE, "user_heap"); - metadata_heap = rb_bh_create(sizeof(struct MetadataEntry), USER_HEAP_SIZE, "metadata_heap"); + away_heap = rb_bh_create(AWAYLEN, AWAY_HEAP_SIZE, "away_heap"); rb_event_addish("check_pings", check_pings, NULL, 30); rb_event_addish("free_exited_clients", &free_exited_clients, NULL, 4); @@ -1657,10 +1657,8 @@ make_user(struct Client *client_p) { user = (struct User *) rb_bh_alloc(user_heap); user->refcnt = 1; - user->metadata = irc_dictionary_create(irccmp); client_p->user = user; } - return user; } @@ -1697,8 +1695,12 @@ make_server(struct Client *client_p) void free_user(struct User *user, struct Client *client_p) { + free_away(client_p); + if(--user->refcnt <= 0) { + if(user->away) + rb_free((char *) user->away); /* * sanity check */ @@ -1725,63 +1727,21 @@ free_user(struct User *user, struct Client *client_p) } } -const char * -get_metadata(struct Client *client_p, const char *key) +void +allocate_away(struct Client *client_p) { - struct MetadataEntry *md; - - if (client_p->user != NULL) - { - md = irc_dictionary_retrieve(client_p->user->metadata, key); - if (md == NULL) - return NULL; - - return md->value; - } - - return NULL; + if(client_p->user->away == NULL) + client_p->user->away = rb_bh_alloc(away_heap); } -void -set_metadata(struct Client *client_p, const char *key, const char *value) -{ - struct MetadataEntry *md; - - if(client_p->user != NULL) - { - md = irc_dictionary_retrieve(client_p->user->metadata, key); - if (md == NULL) - { - md = rb_bh_alloc(metadata_heap); - rb_strlcpy(md->key, key, sizeof md->key); - irc_dictionary_add(client_p->user->metadata, md->key, md); - } - else if (!strcmp(md->key, key) && !strcmp(md->value, value)) - return; - else - rb_strlcpy(md->key, key, sizeof md->key); - - rb_strlcpy(md->value, value, sizeof md->value); - } - - sendto_common_channels_local_with_capability(client_p, CLICAP_PRESENCE, form_str(RPL_METADATACHG), me.name, client_p->name, key, value); -} void -delete_metadata(struct Client *client_p, const char *key) +free_away(struct Client *client_p) { - struct MetadataEntry *md; - - if(client_p->user != NULL) - { - md = irc_dictionary_delete(client_p->user->metadata, key); - if (md == NULL) - return; - - rb_bh_free(metadata_heap, md); + if(client_p->user != NULL && client_p->user->away != NULL) { + rb_bh_free(away_heap, client_p->user->away); + client_p->user->away = NULL; } - - sendto_common_channels_local_with_capability(client_p, CLICAP_PRESENCE, form_str(RPL_METADATACHG), me.name, client_p->name, key, ""); } void diff --git a/src/messages.tab b/src/messages.tab index 4c2a02675..cad5720ab 100644 --- a/src/messages.tab +++ b/src/messages.tab @@ -811,10 +811,10 @@ static const char * replies[] = { /* 787 */ NULL, /* 788 */ NULL, /* 789 */ NULL, -/* 790 RPL_METADATASET */ "%s :Metadata set", -/* 791 RPL_METADATAREM */ "%s :Metadata removed", -/* 792 RPL_METADATACHG */ ":%s 792 * %s %s :%s", -/* 793 RPL_WHOISMETADATA */ "%s %s :%s", +/* 790 */ NULL, +/* 791 */ NULL, +/* 792 */ NULL, +/* 793 */ NULL, /* 794 */ NULL, /* 795 */ NULL, /* 796 */ NULL, diff --git a/src/s_serv.c b/src/s_serv.c index 88fecddc9..10c0fab05 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -474,8 +474,6 @@ burst_TS6(struct Client *client_p) RB_DLINK_FOREACH(ptr, global_client_list.head) { - const char *awaymsg = NULL; - target_p = ptr->data; if(!IsPerson(target_p)) @@ -518,10 +516,10 @@ burst_TS6(struct Client *client_p) use_id(target_p), target_p->user->suser); } - if(ConfigFileEntry.burst_away && (awaymsg = get_metadata(target_p, "away")) != NULL) + if(ConfigFileEntry.burst_away && !EmptyString(target_p->user->away)) sendto_one(client_p, ":%s AWAY :%s", use_id(target_p), - awaymsg); + target_p->user->away); hclientinfo.target = target_p; call_hook(h_burst_client, &hclientinfo); diff --git a/src/send.c b/src/send.c index 57e9df84e..4c04daf32 100644 --- a/src/send.c +++ b/src/send.c @@ -760,69 +760,6 @@ sendto_common_channels_local(struct Client *user, const char *pattern, ...) rb_linebuf_donebuf(&linebuf); } -/* - * sendto_common_channels_local_with_capability() - * - * inputs - pointer to client - * - capability - * - pattern to send - * output - NONE - * side effects - Sends a message to all people on local server who are - * in same channel with user. - * used by m_nick.c and exit_one_client. - */ -void -sendto_common_channels_local_with_capability(struct Client *user, int capability, const char *pattern, ...) -{ - va_list args; - rb_dlink_node *ptr; - rb_dlink_node *next_ptr; - rb_dlink_node *uptr; - rb_dlink_node *next_uptr; - struct Channel *chptr; - struct Client *target_p; - struct membership *msptr; - struct membership *mscptr; - buf_head_t linebuf; - - rb_linebuf_newbuf(&linebuf); - va_start(args, pattern); - rb_linebuf_putmsg(&linebuf, pattern, &args, NULL); - va_end(args); - - ++current_serial; - - RB_DLINK_FOREACH_SAFE(ptr, next_ptr, user->user->channel.head) - { - mscptr = ptr->data; - chptr = mscptr->chptr; - - RB_DLINK_FOREACH_SAFE(uptr, next_uptr, chptr->locmembers.head) - { - msptr = uptr->data; - target_p = msptr->client_p; - - if(!IsCapable(target_p, capability)) - continue; - - if(IsIOError(target_p) || - target_p->serial == current_serial) - continue; - - target_p->serial = current_serial; - send_linebuf(target_p, &linebuf); - } - } - - /* this can happen when the user isnt in any channels, but we still - * need to send them the data, ie a nick change - */ - if(MyConnect(user) && (user->serial != current_serial) && IsCapable(user, capability)) - send_linebuf(user, &linebuf); - - rb_linebuf_donebuf(&linebuf); -} - /* * sendto_common_channels_local_butone() * @@ -877,72 +814,6 @@ sendto_common_channels_local_butone(struct Client *user, const char *pattern, .. rb_linebuf_donebuf(&linebuf); } -/* - * sendto_common_channels_local_with_capability_butone() - * - * inputs - pointer to client - * - capability - * - pattern to send - * output - NONE - * side effects - Sends a message to all people on local server who are - * in same channel with user, except the user themselves. - * used by m_nick.c and exit_one_client. - */ -void -sendto_common_channels_local_with_capability_butone(struct Client *user, int capability, const char *pattern, ...) -{ - va_list args; - rb_dlink_node *ptr; - rb_dlink_node *next_ptr; - rb_dlink_node *uptr; - rb_dlink_node *next_uptr; - struct Channel *chptr; - struct Client *target_p; - struct membership *msptr; - struct membership *mscptr; - buf_head_t linebuf; - - rb_linebuf_newbuf(&linebuf); - va_start(args, pattern); - rb_linebuf_putmsg(&linebuf, pattern, &args, NULL); - va_end(args); - - ++current_serial; - /* Skip them -- jilles */ - user->serial = current_serial; - - RB_DLINK_FOREACH_SAFE(ptr, next_ptr, user->user->channel.head) - { - mscptr = ptr->data; - chptr = mscptr->chptr; - - RB_DLINK_FOREACH_SAFE(uptr, next_uptr, chptr->locmembers.head) - { - msptr = uptr->data; - target_p = msptr->client_p; - - if(!IsCapable(target_p, capability)) - continue; - - if(IsIOError(target_p) || - target_p->serial == current_serial) - continue; - - target_p->serial = current_serial; - send_linebuf(target_p, &linebuf); - } - } - - /* this can happen when the user isnt in any channels, but we still - * need to send them the data, ie a nick change - */ - if(MyConnect(user) && (user->serial != current_serial) && IsCapable(user, capability)) - send_linebuf(user, &linebuf); - - rb_linebuf_donebuf(&linebuf); -} - - /* sendto_match_butone() * * inputs - server not to send to, source, mask, type of mask, va_args From 01a7f6d4f9cf5e22ed748cce6cd9101413d0cdba Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Wed, 3 Jun 2009 23:18:07 +0200 Subject: [PATCH 3/7] Remove two obsolete constants. --- include/ircd_defs.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/ircd_defs.h b/include/ircd_defs.h index 686cea487..071c92f0f 100644 --- a/include/ircd_defs.h +++ b/include/ircd_defs.h @@ -115,9 +115,7 @@ /* 23+1 for \0 */ #define KEYLEN 24 #define BUFSIZE 512 /* WARNING: *DONT* CHANGE THIS!!!! */ -#define MAXRECIPIENTS 20 -#define MAXBANLENGTH 1024 -#define OPERNICKLEN NICKLEN*2 /* Length of OPERNICKs. */ +#define OPERNICKLEN (NICKLEN*2) /* Length of OPERNICKs. */ #define USERHOST_REPLYLEN (NICKLEN+HOSTLEN+USERLEN+5) #define MAX_DATE_STRING 32 /* maximum string length for a date string */ From cef7a7bc4e31470d933581dcd0d59056180007e0 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Mon, 21 Dec 2009 16:58:25 +0100 Subject: [PATCH 4/7] Remove FLAGS_SENDQEX, fix sendq exceeded snotes for servers. from ircd-ratbox --- include/client.h | 3 +-- src/client.c | 4 ++-- src/send.c | 7 ++----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/include/client.h b/include/client.h index 178a9a37a..13bd09665 100644 --- a/include/client.h +++ b/include/client.h @@ -401,7 +401,6 @@ struct ListClient #define FLAGS_GOTID 0x0080 /* successful ident lookup achieved */ #define FLAGS_FLOODDONE 0x0100 /* flood grace period over / reported */ #define FLAGS_NORMALEX 0x0400 /* Client exited normally */ -#define FLAGS_SENDQEX 0x0800 /* Sendq exceeded */ #define FLAGS_MARK 0x10000 /* marked client */ #define FLAGS_HIDDEN 0x20000 /* hidden server */ #define FLAGS_EOB 0x40000 /* EOB */ @@ -592,7 +591,7 @@ extern client_t *next_client(struct Client *, const char *); #define accept_message(s, t) ((s) == (t) || (rb_dlinkFind((s), &((t)->localClient->allow_list)))) extern void del_all_accepts(struct Client *client_p); -extern void dead_link(struct Client *client_p); +extern void dead_link(struct Client *client_p, int sendqex); extern int show_ip(struct Client *source_p, struct Client *target_p); extern int show_ip_conf(struct ConfItem *aconf, struct Client *target_p); diff --git a/src/client.c b/src/client.c index 7aa5b9416..47ba0a450 100644 --- a/src/client.c +++ b/src/client.c @@ -1105,7 +1105,7 @@ exit_aborted_clients(void *unused) * */ void -dead_link(struct Client *client_p) +dead_link(struct Client *client_p, int sendqex) { struct abort_client *abt; @@ -1115,7 +1115,7 @@ dead_link(struct Client *client_p) abt = (struct abort_client *) rb_malloc(sizeof(struct abort_client)); - if(client_p->flags & FLAGS_SENDQEX) + if(sendqex) rb_strlcpy(abt->notice, "Max SendQ exceeded", sizeof(abt->notice)); else rb_snprintf(abt->notice, sizeof(abt->notice), "Write error: %s", strerror(errno)); diff --git a/src/send.c b/src/send.c index 4c04daf32..4aebff914 100644 --- a/src/send.c +++ b/src/send.c @@ -85,10 +85,7 @@ _send_linebuf(struct Client *to, buf_head_t *linebuf) get_sendq(to)); } - if(IsClient(to)) - to->flags |= FLAGS_SENDQEX; - - dead_link(to); + dead_link(to, 1); return -1; } else @@ -200,7 +197,7 @@ send_queued(struct Client *to) if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno))) { - dead_link(to); + dead_link(to, 0); return; } } From 4b58bbb2da2f35e22d446c884bf800c72370c484 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sat, 26 Dec 2009 00:25:52 +0100 Subject: [PATCH 5/7] ts6-protocol.txt: mention meaning of capabs EX, IE, SERVICES, KNOCK. --- doc/technical/ts6-protocol.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/technical/ts6-protocol.txt b/doc/technical/ts6-protocol.txt index 664c6e0bf..d86e34c02 100644 --- a/doc/technical/ts6-protocol.txt +++ b/doc/technical/ts6-protocol.txt @@ -80,8 +80,8 @@ statuses +v (prefix +) (voice) type A +b (ban) -+e (ban exception) -+I (invite exception) ++e (ban exception) (capab: EX) ++I (invite exception) (capab: IE) type B +k (key: password required to join, <= 23 ascii chars, no : or , or whitespace) type C @@ -90,7 +90,7 @@ type D +m (moderated) +n (no external messages) +p (private: does not appear in /whois to non-members, no /knock allowed) -+r (only registered users may join) (only if a services server exists) ++r (only registered users may join) (only if a services server exists) (capab: SERVICES) +s (secret) +t (only chanops may change topic) (charybdis TS6) @@ -368,6 +368,7 @@ parameters: target server mask, duration, user mask, host mask, reason As form 1, deprecated. KNOCK +capab: KNOCK source: user parameters: channel propagation: broadcast From 22df9f8989c13ed025b4e5c0e1b21aaf65904436 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Fri, 1 Jan 2010 22:46:34 +0100 Subject: [PATCH 6/7] Update some copyright years. --- NEWS | 2 +- src/version.c.SH | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 5bfcbe67c..a58177a1f 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -This is charybdis 3.1, Copyright (c) 2005-2009 Charybdis team. +This is charybdis 3.1, Copyright (c) 2005-2010 Charybdis team. See LICENSE for licensing details (GPL v2). -- charybdis-3.1.0 diff --git a/src/version.c.SH b/src/version.c.SH index be1a6b10f..ad83e09ed 100644 --- a/src/version.c.SH +++ b/src/version.c.SH @@ -64,8 +64,8 @@ const char *infotext[] = "Based on the original code written by Jarkko Oikarinen", "Copyright 1988, 1989, 1990, 1991 University of Oulu, Computing Center", "Copyright (c) 1996-2001 Hybrid Development Team", - "Copyright (c) 2002-2008 ircd-ratbox Development Team", - "Copyright (c) 2005-2009 charybdis development team", + "Copyright (c) 2002-2009 ircd-ratbox Development Team", + "Copyright (c) 2005-2010 charybdis development team", "", "This program is free software; you can redistribute it and/or", "modify it under the terms of the GNU General Public License as", From 0b5cf476f5707194c5b582caada14fc7684d1505 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Fri, 1 Jan 2010 22:55:25 +0100 Subject: [PATCH 7/7] SCAN UMODES: default list-max to 500, like a global WHO. --- help/opers/scan | 8 ++++---- modules/m_scan.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/help/opers/scan b/help/opers/scan index 5b0f764fd..f018a6936 100644 --- a/help/opers/scan +++ b/help/opers/scan @@ -7,10 +7,10 @@ NO-LIST disables the listing of matching users and only shows the count. LIST enables the listing (default). GLOBAL extends the search to the entire network instead of local users only. LIST-MAX limits the listing of matching users to -the given amount. MASK causes only users matching the given -nick!user@host mask to be selected. Only the displayed host -is considered, not the IP address or real host behind -dynamic spoofs. +the given amount instead of the default 500. MASK causes +only users matching the given nick!user@host mask to be +selected. Only the displayed host is considered, not the +IP address or real host behind dynamic spoofs. Network searches where a listing is given are operspy commands. diff --git a/modules/m_scan.c b/modules/m_scan.c index 7f4718761..ccc1d024f 100644 --- a/modules/m_scan.c +++ b/modules/m_scan.c @@ -114,7 +114,7 @@ scan_umodes(struct Client *client_p, struct Client *source_p, int parc, int what = MODE_ADD; int mode; int list_users = YES; - int list_max = 0; + int list_max = 500; int list_count = 0, count = 0; const char *mask = NULL; const char *c;