#include "class.h"
#include "client.h"
#include "ircd.h"
+#include "ircd_policy.h"
#include "ircd_snprintf.h"
#include "ircd_string.h"
#include "list.h"
#include "match.h"
#include "msg.h"
#include "numnicks.h"
+#include "parse.h"
#include "s_bsd.h"
#include "s_debug.h"
#include "s_misc.h"
#include "s_user.h"
-#include "sprintf_irc.h"
#include "struct.h"
#include "sys.h"
if ((len = deliver_it(to, &(cli_sendQ(to))))) {
msgq_delete(&(cli_sendQ(to)), len);
cli_lastsq(to) = MsgQLength(&(cli_sendQ(to))) / 1024;
- if (IsBlocked(to))
+ if (IsBlocked(to)) {
+ update_write(to);
return;
+ }
}
else {
if (IsDead(to)) {
/* Ok, sendq is now empty... */
client_drop_sendq(cli_connect(to));
+ update_write(to);
}
void send_buffer(struct Client* to, struct MsgBuf* buf, int prio)
msgq_add(&(cli_sendQ(to)), buf, prio);
client_add_sendq(cli_connect(to), &send_queues);
+ update_write(to);
/*
* Update statistics. The following is slightly incorrect
* addition -- Armin, 8jun90 (gruner@informatik.tu-muenchen.de)
*/
-static int match_it(struct Client *one, const char *mask, int what)
+static int match_it(struct Client *from, struct Client *one, const char *mask, int what)
{
switch (what)
{
case MATCH_HOST:
- return (match(mask, cli_user(one)->host) == 0);
+ return (match(mask, cli_user(one)->host) == 0 ||
+ (HasHiddenHost(one) && match(mask, cli_user(one)->realhost) == 0));
case MATCH_SERVER:
default:
return (match(mask, cli_name(cli_user(one)->server)) == 0);
void sendcmdto_one(struct Client *from, const char *cmd, const char *tok,
struct Client *to, const char *pattern, ...)
{
- va_list vl;
+ struct VarData vd;
+ struct MsgBuf *mb;
- va_start(vl, pattern);
- vsendcmdto_one(from, cmd, tok, to, pattern, vl);
- va_end(vl);
+ to = cli_from(to);
+
+ vd.vd_format = pattern; /* set up the struct VarData for %v */
+ va_start(vd.vd_args, pattern);
+
+ mb = msgq_make(to, "%:#C %s %v", from, IsServer(to) || IsMe(to) ? tok : cmd,
+ &vd);
+
+ va_end(vd.vd_args);
+
+ send_buffer(to, mb, 0);
+
+ msgq_clean(mb);
}
-void vsendcmdto_one(struct Client *from, const char *cmd, const char *tok,
- struct Client *to, const char *pattern, va_list vl)
+/*
+ * Send a (prefixed) command to a single client in the priority queue;
+ * select which of <cmd> <tok> to use depending on if to is a server
+ *or not. <from> is the originator of the command.
+ */
+void sendcmdto_prio_one(struct Client *from, const char *cmd, const char *tok,
+ struct Client *to, const char *pattern, ...)
{
struct VarData vd;
struct MsgBuf *mb;
to = cli_from(to);
vd.vd_format = pattern; /* set up the struct VarData for %v */
- vd.vd_args = vl;
+ va_start(vd.vd_args, pattern);
mb = msgq_make(to, "%:#C %s %v", from, IsServer(to) || IsMe(to) ? tok : cmd,
&vd);
- send_buffer(to, mb, 0);
+ va_end(vd.vd_args);
+
+ send_buffer(to, mb, 1);
msgq_clean(mb);
}
* Send a (prefix) command originating from <from> to all channels
* <from> is locally on. <from> must be a user. <tok> is ignored in
* this function.
+ *
+ * Update: don't send to 'one', if any. --Vampire
*/
/* XXX sentalong_marker used XXX
*
* message to, and then a final loop through the connected servers
* to delete the flag. -Kev
*/
-void sendcmdto_common_channels(struct Client *from, const char *cmd,
- const char *tok, const char *pattern, ...)
+void sendcmdto_common_channels_butone(struct Client *from, const char *cmd,
+ const char *tok, struct Client *one,
+ const char *pattern, ...)
{
struct VarData vd;
struct MsgBuf *mb;
/*
* loop through from's channels, and the members on their channels
*/
- for (chan = cli_user(from)->channel; chan; chan = chan->next_channel)
+ for (chan = cli_user(from)->channel; chan; chan = chan->next_channel) {
+ if (IsZombie(chan))
+ continue;
for (member = chan->channel->members; member;
member = member->next_member)
if (MyConnect(member->user) && -1 < cli_fd(cli_from(member->user)) &&
+ member->user != one &&
sentalong[cli_fd(cli_from(member->user))] != sentalong_marker) {
sentalong[cli_fd(cli_from(member->user))] = sentalong_marker;
send_buffer(member->user, mb, 0);
}
+ }
- if (MyConnect(from))
+ if (MyConnect(from) && from != one)
send_buffer(from, mb, 0);
msgq_clean(mb);
/*
* Send a (prefixed) command to all local users on the channel specified
* by <to>; <tok> is ignored by this function
+ *
+ * Update: don't send to 'one', if any. --Vampire
*/
-void sendcmdto_channel_butserv(struct Client *from, const char *cmd,
- const char *tok, struct Channel *to,
- const char *pattern, ...)
+void sendcmdto_channel_butserv_butone(struct Client *from, const char *cmd,
+ const char *tok, struct Channel *to,
+ struct Client *one, const char *pattern,
+ ...)
{
struct VarData vd;
struct MsgBuf *mb;
/* send the buffer to each local channel member */
for (member = to->members; member; member = member->next_member) {
- if (MyConnect(member->user) && !IsZombie(member))
+ if (MyConnect(member->user) && member->user != one && !IsZombie(member))
send_buffer(member->user, mb, 0);
}
* Send a (prefixed) command to all users except <one> that have
* <flag> set.
*/
-void sendcmdto_flag_butone(struct Client *from, const char *cmd,
- const char *tok, struct Client *one,
- unsigned int flag, const char *pattern, ...)
+void sendwallto_group_butone(struct Client *from, int type, struct Client *one,
+ const char *pattern, ...)
{
struct VarData vd;
struct Client *cptr;
struct MsgBuf *mb;
struct DLink *lp;
- unsigned int oper_fl = 0;
+ char *prefix=NULL;
+ char *tok=NULL;
int i;
- if (flag & FLAGS_OPER) {
- flag &= ~FLAGS_OPER;
- oper_fl++;
- }
-
vd.vd_format = pattern;
/* Build buffer to send to users */
va_start(vd.vd_args, pattern);
- mb = msgq_make(0, "%:#C " MSG_WALLOPS " %v", from, &vd);
+ switch (type) {
+ case WALL_DESYNCH:
+ prefix="";
+ tok=TOK_DESYNCH;
+ break;
+ case WALL_WALLOPS:
+ prefix="* ";
+ tok=TOK_WALLOPS;
+ break;
+ case WALL_WALLUSERS:
+ prefix="$ ";
+ tok=TOK_WALLUSERS;
+ break;
+ default:
+ assert(0);
+ }
+ mb = msgq_make(0, "%:#C " MSG_WALLOPS " :%s%v", from, prefix,&vd);
va_end(vd.vd_args);
/* send buffer along! */
for (i = 0; i <= HighestFd; i++) {
- if (!(cptr = LocalClientArray[i]) || !(cli_flags(cptr) & flag) ||
- (oper_fl && !IsAnOper(cptr)) || cli_fd(cli_from(cptr)) < 0)
+ if (!(cptr = LocalClientArray[i]) ||
+ (cli_fd(cli_from(cptr)) < 0) ||
+ (type == WALL_DESYNCH && !(cli_flags(cptr) & FLAGS_DEBUG)) ||
+#ifdef HEAD_IN_SAND_WALLOPS
+ (type == WALL_WALLOPS && (!(cli_flags(cptr) & FLAGS_WALLOP) ||
+ !IsAnOper(cptr))) ||
+#else
+ (type == WALL_WALLOPS && !(cli_flags(cptr) & FLAGS_WALLOP)) ||
+#endif
+ (type == WALL_WALLUSERS && !(cli_flags(cptr) & FLAGS_WALLOP)))
continue; /* skip it */
send_buffer(cptr, mb, 1);
}
/* Build buffer to send to servers */
va_start(vd.vd_args, pattern);
- mb = msgq_make(&me, "%C %s %v", from, tok, &vd);
+ mb = msgq_make(&me, "%C %s :%v", from, tok, &vd);
va_end(vd.vd_args);
/* send buffer along! */
for (lp = cli_serv(&me)->down; lp; lp = lp->next) {
if (one && lp->value.cptr == cli_from(one))
continue;
- send_buffer(lp->value.cptr, mb, 0);
+ send_buffer(lp->value.cptr, mb, 1);
}
msgq_clean(mb);
/* send buffer along */
sentalong_marker++;
for (cptr = GlobalClientList; cptr; cptr = cli_next(cptr)) {
- if (cli_from(cptr) == one || IsServer(cptr) || IsMe(cptr) ||
- !match_it(cptr, to, who) || cli_fd(cli_from(cptr)) < 0 ||
+ if (!IsRegistered(cptr) || cli_from(cptr) == one || IsServer(cptr) ||
+ IsMe(cptr) || !match_it(from, cptr, to, who) || cli_fd(cli_from(cptr)) < 0 ||
sentalong[cli_fd(cli_from(cptr))] == sentalong_marker)
continue; /* skip it */
sentalong[cli_fd(cli_from(cptr))] = sentalong_marker;
va_end(vl);
}
+/*
+ * Send a server notice to all users subscribing to the indicated <mask>
+ * except for <one> - Ratelimited 1 / 30sec
+ */
+void sendto_opmask_butone_ratelimited(struct Client *one, unsigned int mask,
+ time_t *rate, const char *pattern, ...)
+{
+ va_list vl;
+
+ if ((CurrentTime - *rate) < 30)
+ return;
+ else
+ *rate = CurrentTime;
+
+ va_start(vl, pattern);
+ vsendto_opmask_butone(one, mask, pattern, vl);
+ va_end(vl);
+
+}
+
+
/*
* Same as above, except called with a variable argument list
*/