mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 18:22:50 +01:00
Automated merge with ssh://hg.atheme.org//hg/charybdis
This commit is contained in:
commit
31478ab689
26 changed files with 75 additions and 418 deletions
2
NEWS
2
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
@ -407,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 */
|
||||
|
@ -456,7 +449,6 @@ struct ListClient
|
|||
|
||||
#define CLICAP_MULTI_PREFIX 0x0001
|
||||
#define CLICAP_SASL 0x0002
|
||||
#define CLICAP_PRESENCE 0x0004
|
||||
|
||||
/*
|
||||
* flags macros.
|
||||
|
@ -599,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);
|
||||
|
||||
|
@ -614,8 +606,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 */
|
||||
|
|
|
@ -111,13 +111,6 @@
|
|||
#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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 *,
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -78,21 +78,29 @@ 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]);
|
||||
|
||||
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), parv[1]);
|
||||
":%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));
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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]))
|
||||
|
|
|
@ -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 <nenolod@dereferenced.org>
|
||||
*
|
||||
* 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;
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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)",
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
72
src/client.c
72
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);
|
||||
|
@ -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));
|
||||
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
136
src/send.c
136
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;
|
||||
}
|
||||
}
|
||||
|
@ -760,69 +757,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 +811,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
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue