//------------------------------------------------------------------------
//------------------------------------------------------------------------
//-------------------------------------------------------------------------
void CPlayerFeature::DualSOCOM(CActor *pActor)
{
	if(pActor && !pActor->IsPlayer())
	{
		IInventory *pInventory=GetActorInventory(pActor);
		if (pInventory)
		{
			if (IsServer())
			{
					m_pItemSystem->GiveItem(pActor, "SOCOM", false, false,false);
					//m_pItemSystem->SetActorItem(pActor,"SOCOM",true);
			}
		}
	}
}
示例#2
0
/** Forwards a numeric message from a remote server.
 * @param numeric Value of numeric message.
 * @param nnn If non-zero, treat parv[1] as a numnick; else as a client name.
 * @param cptr Client that originated the numeric.
 * @param sptr Peer that sent us the numeric.
 * @param parc Count of valid arguments in \a parv.
 * @param parv Argument list.
 * @return Zero (always).
 */
int do_numeric(int numeric, int nnn, struct Client *cptr, struct Client *sptr,
    int parc, char *parv[])
{
  struct Client *acptr = 0;
  struct Channel *achptr = 0;
  char num[4];

  /* Avoid trash, we need it to come from a server and have a target  */
  if ((parc < 2) || !IsServer(sptr))
    return 0;

  /* Who should receive this message ? Will we do something with it ?
     Note that we use findUser functions, so the target can't be neither
     a server, nor a channel (?) nor a list of targets (?) .. u2.10
     should never generate numeric replies to non-users anyway
     Ahem... it can be a channel actually, csc bots use it :\ --Nem */

  if (IsChannelName(parv[1]))
    achptr = FindChannel(parv[1]);
  else
    acptr = (nnn) ? (findNUser(parv[1])) : (FindUser(parv[1]));

  if (((!acptr) || (cli_from(acptr) == cptr)) && !achptr)
    return 0;

  /* Remap low number numerics, not that I understand WHY.. --Nemesi  */
  /* numerics below 100 talk about the current 'connection', you're not
   * connected to a remote server so it doesn't make sense to send them
   * remotely - but the information they contain may be useful, so we
   * remap them up.  Weird, but true.  -- Isomer */
  if (numeric < 100)
    numeric += 100;

  ircd_snprintf(0, num, sizeof(num), "%03d", numeric);

  /* Since 2.10.10.pl14 we rewrite numerics from remote servers to appear to
   * come from the local server
   */
  if (acptr)
    sendcmdto_one((feature_bool(FEAT_HIS_REWRITE) && !IsOper(acptr)) ?
                    &me : sptr,
                  num, num, acptr, "%C %s", acptr, parv[2]);
  else
    sendcmdto_channel_butone(feature_bool(FEAT_HIS_REWRITE) ? &me : sptr,
                             num, num, achptr, cptr, SKIP_DEAF | SKIP_BURST,
                             '\0', "%H %s", achptr, parv[2]);
  return 0;
}
示例#3
0
/*
 * Heavily modified from the ircu m_motd by codemastr
 * Also svsmotd support added
 */
DLLFUNC CMD_FUNC(m_rules)
{
	ConfigItem_tld *ptr;
	aMotd *temp;
	char userhost[USERLEN + HOSTLEN + 6];
	if (IsServer(sptr))
		return 0;
		
	if (hunt_server_token(cptr, sptr, MSG_RULES, TOK_RULES, ":%s", 1, parc,
	    parv) != HUNTED_ISME)
		return 0;
#ifndef TLINE_Remote
	if (!MyConnect(sptr))
	{
		temp = rules;
		goto playrules;
	}
#endif
	strlcpy(userhost,make_user_host(cptr->user->username, cptr->user->realhost), sizeof userhost);
	ptr = Find_tld(sptr, userhost);

	if (ptr)
	{
		temp = ptr->rules;

	}
	else
		temp = rules;

      playrules:
	if (temp == NULL)
	{
		sendto_one(sptr, err_str(ERR_NORULES), me.name, parv[0]);
		return 0;

	}

	sendto_one(sptr, rpl_str(RPL_RULESSTART), me.name, parv[0], me.name);

	while (temp)
	{
		sendto_one(sptr, rpl_str(RPL_RULES), me.name, parv[0],
		    temp->line);
		temp = temp->next;
	}
	sendto_one(sptr, rpl_str(RPL_ENDOFRULES), me.name, parv[0]);
	return 0;
}
示例#4
0
文件: send.c 项目: evilnet/nefarious2
/** Send a (prefixed) command to all channels that \a from is on.
 * @param[in] from Client originating the command.
 * @param[in] cmd Long name of command.
 * @param[in] tok Short name of command.
 * @param[in] one Client direction to skip (or NULL).
 * @param[in] pattern Format string for command arguments.
 */
void sendcmdto_common_channels_capab_butone(struct Client *from, const char *cmd,
                                      const char *tok, struct Client *one,
                                      int withcap, int skipcap,
                                      const char *pattern, ...)
{
  struct VarData vd;
  struct MsgBuf *mb;
  struct Membership *chan;
  struct Membership *member;

  assert(0 != from);
  assert(0 != cli_from(from));
  assert(0 != pattern);
  assert(!IsServer(from) && !IsMe(from));

  vd.vd_format = pattern; /* set up the struct VarData for %v */

  va_start(vd.vd_args, pattern);

  /* build the buffer */
  mb = msgq_make(0, "%:#C %s %v", from, cmd, &vd);
  va_end(vd.vd_args);

  bump_sentalong(from);
  /*
   * loop through from's channels, and the members on their channels
   */
  for (chan = cli_user(from)->channel; chan; chan = chan->next_channel) {
    if (IsZombie(chan) || IsDelayedJoin(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
          && cli_sentalong(member->user) != sentalong_marker
          && ((withcap == CAP_NONE) || CapActive(member->user, withcap))
          && ((skipcap == CAP_NONE) || !CapActive(member->user, skipcap))) {
        cli_sentalong(member->user) = sentalong_marker;
        send_buffer(member->user, mb, 0);
      }
  }

  if (MyConnect(from) && from != one)
    send_buffer(from, mb, 0);

  msgq_clean(mb);
}
示例#5
0
/*
 * m_sxline() - add info ban line
 *
 *	parv[0] = sender prefix
 *	parv[1] =  info banned mask
 */
int	m_sxline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
  {
    aConfItem *aconf;
    char *reason = NULL;
    char *mask;
    int len;

	if (!IsService(sptr) && !IsServer(cptr))
	  {
		sendto_one(sptr, form_str(ERR_NOPRIVILEGES), me.name, parv[0]);
		return 0;
	  }	  
		
	if(parc<3)
	  {
		sendto_one(sptr, form_str(ERR_NEEDMOREPARAMS),
      	  me.name, parv[0], "SXLINE");
        return 0;
	  }
      
    len=atoi(parv[1]);
    mask = parv[2];
    
    if ((strlen(mask) > len) && (mask[len])==':')
      {
        mask[len] = '\0';
        reason = mask+len+1;
      } 
    else
      { /* Bogus */
        return 0;
      }
    
    if (!find_sxline(mask)) /* sxline does not exist */
	  {

		aconf = make_conf();
		DupString(aconf->name, mask);
		DupString(aconf->passwd, reason);
	    aconf->next = sxlines;
		sxlines = aconf;		

        sendto_serv_butone(cptr, ":%s SXLINE %d :%s:%s", sptr->name, len,
                       aconf->name,aconf->passwd);
	  }

	return 0;
  }
示例#6
0
文件: jupe.c 项目: Niichan/snircd
/** Deactivate a jupe.
 * @param[in] cptr Local client that sent us the jupe.
 * @param[in] sptr Originator of the jupe.
 * @param[in] jupe Jupe to deactivate.
 * @param[in] lastmod New timestamp for last modification of the jupe.
 * @param[in] flags Flags to set on the jupe.
 * @return Zero.
 */
int
jupe_deactivate(struct Client *cptr, struct Client *sptr, struct Jupe *jupe,
		time_t lastmod, unsigned int flags)
{
  unsigned int saveflags = 0;

  assert(0 != jupe);

  saveflags = jupe->ju_flags;

  if (!JupeIsLocal(jupe)) {
    if (flags & JUPE_LOCAL)
      jupe->ju_flags |= JUPE_LDEACT;
    else {
      jupe->ju_flags &= ~JUPE_ACTIVE;

      if (jupe->ju_lastmod >= lastmod) /* force lastmod to increase */
	jupe->ju_lastmod++;
      else
	jupe->ju_lastmod = lastmod;
    }

    if ((saveflags & JUPE_ACTMASK) != JUPE_ACTIVE)
      return 0; /* was inactive to begin with */
  }

  /* Inform ops and log it */
  sendto_opmask_butone(0, SNO_NETWORK, "%s %s JUPE for %s, expiring at %Tu: "
		       "%s",
                       (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
                         cli_name(sptr) :
                         cli_name((cli_user(sptr))->server),
		       JupeIsLocal(jupe) ? "removing local" : "deactivating",
		       jupe->ju_server, jupe->ju_expire + TSoffset,
		       jupe->ju_reason);

  log_write(LS_JUPE, L_INFO, LOG_NOSNOTICE,
	    "%#C %s JUPE for %s, expiring at %Tu: %s", sptr,
	    JupeIsLocal(jupe) ? "removing local" : "deactivating",
	    jupe->ju_server, jupe->ju_expire + TSoffset, jupe->ju_reason);

  if (JupeIsLocal(jupe))
    jupe_free(jupe);
  else if (!(flags & JUPE_LOCAL)) /* don't propagate local changes */
    propagate_jupe(cptr, sptr, jupe);

  return 0;
}
示例#7
0
int  is_chan_op(aClient *cptr, aChannel *chptr)
{
	Membership *lp;
/* chanop/halfop ? */
	if (IsServer(cptr))
		return 1;
	if (chptr)
		if ((lp = find_membership_link(cptr->user->channel, chptr)))
#ifdef PREFIX_AQ
			return ((lp->flags & (CHFL_CHANOP|CHFL_CHANPROT|CHFL_CHANOWNER)));
#else
			return ((lp->flags & CHFL_CHANOP));
#endif

	return 0;
}
示例#8
0
aClient *find_match_server(char *mask)
{
	aClient *acptr;

	if (BadPtr(mask))
		return NULL;
	for (acptr = client, collapse(mask); acptr; acptr = acptr->next)
	{
		if (!IsServer(acptr) && !IsMe(acptr))
			continue;
		if (!match(mask, acptr->name))
			break;
		continue;
	}
	return acptr;
}
示例#9
0
/*
 * get_client_class
 *
 * inputs	- pointer to client struct
 * output	- pointer to name of class
 * side effects - NONE
 */
const char *
get_client_class(struct Client *target_p)
{
	const char *retc = "unknown";

	if(target_p == NULL || IsMe(target_p))
		return retc;

	if(IsServer(target_p))
	{
		struct server_conf *server_p = target_p->localClient->att_sconf;
		return server_p->class_name;
	}

	return get_class_name(target_p->localClient->att_conf);;
}
示例#10
0
/*! \brief EOB command handler
 *
 * \param source_p Pointer to allocated Client struct from which the message
 *                 originally comes from.  This can be a local or remote client.
 * \param parc     Integer holding the number of supplied arguments.
 * \param parv     Argument vector where parv[0] .. parv[parc-1] are non-NULL
 *                 pointers.
 * \note Valid arguments for this command are:
 *      - parv[0] = command
 */
static int
ms_eob(struct Client *source_p, int parc, char *parv[])
{
  assert(IsServer(source_p));

  if (MyConnect(source_p))
    sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
                         "End of burst from %s (%u seconds)",
                         source_p->name,
                         (unsigned int)(CurrentTime - source_p->connection->firsttime));

  server_eob(source_p);

  sendto_server(source_p, 0, 0, ":%s EOB", source_p->id);
  return 0;
}
示例#11
0
//------------------------------------------------------------------------
void CGunTurret::OnDestroyed()
{
	CWeapon::OnDestroyed();

	if(m_fm2)
	{
		if(m_fm2->IsFiring())
			m_fm2->StopFire();
	}

	StopSound(m_lightSound);
	m_lightSound = INVALID_SOUNDID;

	if(IsServer())
		GetGameObject()->ChangedNetworkState(ASPECT_STATEBITS);
}
示例#12
0
static int crule_directcon(int numargs, void *crulearg[])
{
  int i;
  struct Client *acptr;

  /* adapted from m_trace and exit_one_client */
  for (i = 0; i <= HighestFd; i++)
  {
    if (!(acptr = LocalClientArray[i]) || !IsServer(acptr))
      continue;
    if (match((char *)crulearg[0], cli_name(acptr)))
      continue;
    return (1);
  }
  return (0);
}
示例#13
0
static int
ms_pong(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
    struct Client *target_p;
    const char *destination;

    destination = parv[2];
    source_p->flags &= ~FLAGS_PINGSENT;

    /* Now attempt to route the PONG, comstud pointed out routable PING
     * is used for SPING.  routable PING should also probably be left in
     *        -Dianora
     * That being the case, we will route, but only for registered clients (a
     * case can be made to allow them only from servers). -Shadowfax
     */
    if(!EmptyString(destination) && !match(destination, me.name) &&
            irccmp(destination, me.id))
    {
        if((target_p = find_client(destination)) ||
                (target_p = find_server(NULL, destination)))
            sendto_one(target_p, ":%s PONG %s %s",
                       get_id(source_p, target_p), parv[1],
                       get_id(target_p, target_p));
        else
        {
            if(!IsDigit(*destination))
                sendto_one_numeric(source_p, ERR_NOSUCHSERVER,
                                   form_str(ERR_NOSUCHSERVER), destination);
            return 0;
        }
    }

    /* destination is us, emulate EOB */
    if(IsServer(source_p) && !HasSentEob(source_p))
    {
        if(MyConnect(source_p))
            sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                   "End of burst (emulated) from %s (%d seconds)",
                                   source_p->name,
                                   (signed int) (CurrentTime - source_p->localClient->firsttime));
        SetEob(source_p);
        eob_count++;
        call_hook(h_server_eob, source_p);
    }

    return 0;
}
示例#14
0
文件: m_squit.c 项目: DamnIO/DamnIRCd
/*
 *  mo_squit (oper)
 *
 *    parv[0] = sender prefix
 *    parv[1] = server name
 *    parv[2] = comment (optional)
 *
 */
int mo_squit(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
{
  const char* server;
  struct Client *acptr;
  struct Client *acptr2;
  char *comment;
      
  if (parc < 2) 
    return need_more_params(sptr, "SQUIT");

  if (parc < 3 || BadPtr(parv[2]))
    comment = cli_name(sptr);
  else
    comment = parv[2];

  server = parv[1];
  /*
   * The following allows wild cards in SQUIT. Only useful
   * when the command is issued by an oper.
   */
  for (acptr = GlobalClientList; (acptr = next_client(acptr, server));
      acptr = cli_next(acptr)) {
    if (IsServer(acptr) || IsMe(acptr))
      break;
  }
  
  /* Not found? Bugger. */
  if (!acptr || IsMe(acptr))
    return send_reply(sptr, ERR_NOSUCHSERVER, server);

  /*
   * Look for a matching server that is closer,
   * that way we won't accidentally squit two close
   * servers like davis.* and davis-r.* when typing
   * /SQUIT davis*
   */
  for (acptr2 = cli_serv(acptr)->up; acptr2 != &me;
      acptr2 = cli_serv(acptr2)->up)
    if (!match(server, cli_name(acptr2)))
      acptr = acptr2;
  
  /* Disallow local opers to squit remote servers */
  if (IsLocOp(sptr) && !MyConnect(acptr))
    return send_reply(sptr, ERR_NOPRIVILEGES);

  return exit_client(cptr, acptr, sptr, comment);
}
示例#15
0
/*
** ms_eob
**      parv[0] = sender prefix
**      parv[1] = opt. comma separated list of SIDs for which this EOB is
**                also valid
*/
static int
ms_eob(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	char *copy, *state, *id;
	struct Client *target_p;
	int act = 0;

	if(!HasSentEob(source_p))
	{
		if(MyConnect(source_p))
		{
			sendto_realops_flags(UMODE_ALL, L_ALL,
					     "End of burst from %s (%d seconds)",
					     source_p->name,
					     (signed int)(rb_current_time() -
							  source_p->localClient->firsttime));
			sendto_one(source_p, ":%s EOBACK", me.id);
		}
		act = 1;
		SetEob(source_p);
		eob_count++;
	}
	if(parc > 1 && *parv[1] != '\0')
	{
		copy = LOCAL_COPY(parv[1]);
		for(id = rb_strtok_r(copy, ",", &state); id != NULL;
				id = rb_strtok_r(NULL, ",", &state))
		{
			target_p = find_id(id);
			if(target_p != NULL && IsServer(target_p) &&
					target_p->from == client_p &&
					!HasSentEob(target_p))
			{
				SetEob(target_p);
				eob_count++;
				act = 1;
			}
		}
	}
	if(!act)
		return 0;
	sendto_server(client_p, NULL, CAP_IRCNET, NOCAPS, ":%s EOB%s%s",
			source_p->id,
			parc > 1 ? " :" : "", parc > 1 ? parv[1] : "");

	return 0;
}
示例#16
0
/*
 * m_svinfo - SVINFO message handler
 *      parv[0] = sender prefix
 *      parv[1] = TS_CURRENT for the server
 *      parv[2] = TS_MIN for the server
 *      parv[3] = server is standalone or connected to non-TS only
 *      parv[4] = server's idea of UTC time
 */
int m_svinfo(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
{
  time_t deltat;
  time_t theirtime;

  if (MyConnect(sptr) && IsUnknown(sptr))
    return exit_client(sptr, sptr, sptr, "Need SERVER before SVINFO");

  if (!IsServer(sptr) || !MyConnect(sptr) || parc < 5)
    return 0;

  if (TS_CURRENT < atoi(parv[2]) || atoi(parv[1]) < TS_MIN)
    {
      /*
       * a server with the wrong TS version connected; since we're
       * TS_ONLY we can't fall back to the non-TS protocol so
       * we drop the link  -orabidoo
       */
      sendto_ops_flag(UMODE_SERVNOTICE, "Link %s dropped, wrong TS protocol version (%s,%s)",
		      get_client_name(sptr, MASK_IP), parv[1], parv[2]);
      return exit_client(sptr, sptr, sptr, "Incompatible TS version");
    }

  /*
   * since we're here, might as well set CurrentTime while we're at it
   */
  CurrentTime = time(0);
  theirtime = atol(parv[4]);
  deltat = abs(theirtime - CurrentTime);

  if (deltat > TS_MAX_DELTA)
    {
      sendto_ops_flag(UMODE_SERVNOTICE, 
		      "Link %s dropped, excessive TS delta (my TS=%.1ld, their TS=%.1ld, delta=%.1ld)",
		      get_client_name(sptr, MASK_IP), CurrentTime, theirtime,deltat);
      return exit_client(sptr, sptr, sptr, "Excessive TS delta");
    }

  if (deltat > TS_WARN_DELTA)
    { 
      sendto_ops_flag(UMODE_SERVNOTICE, 
		      "Link %s notable TS delta (my TS=%.1ld, their TS=%.1ld, delta=%.1ld)",
		      get_client_name(sptr, MASK_IP), CurrentTime, theirtime, deltat);
    }

  return 0;
}
示例#17
0
/*
 * This is a pretty expensive routine -- it loops through all the fd's,
 * and finds the active clients (and servers and opers) and places them
 * on the "busy client" list
 */
void check_fdlists()
{
#ifdef CLIENT_SERVER
#define BUSY_CLIENT(x)	(((x)->priority < 55) || (!lifesux && ((x)->priority < 75)))
#else
#define BUSY_CLIENT(x)	(((x)->priority < 40) || (!lifesux && ((x)->priority < 60)))
#endif
#define FDLISTCHKFREQ  2

aClient *cptr;
int i, j;

   j = 0;
   for (i = highest_fd; i >= 0; i--) 
   {
      if (!(cptr = local[i]))
	 continue;
      if (IsServer(cptr) || IsListening(cptr) || IsOper(cptr)) 
      {
	 busycli_fdlist.entry[++j] = i;
	 continue;
      }
      if (cptr->receiveM == cptr->lastrecvM) 
      {
	 cptr->priority += 2;	/* lower a bit */
	 if (cptr->priority > 90)
	    cptr->priority = 90;
	 else if (BUSY_CLIENT(cptr))
	    busycli_fdlist.entry[++j] = i;
	 continue;
      }
      else 
      {
	 cptr->lastrecvM = cptr->receiveM;
	 cptr->priority -= 30;	/* active client */
	 if (cptr->priority < 0) 
	 {
	    cptr->priority = 0;
	    busycli_fdlist.entry[++j] = i;
	 }
	 else if (BUSY_CLIENT(cptr))
	    busycli_fdlist.entry[++j] = i;
      }
   }
   busycli_fdlist.last_entry = j;	/* rest of the fdlist is garbage */
/*   return (now + FDLISTCHKFREQ + (lifesux + 1)); */
}
示例#18
0
/*
 * m_svinfo - SVINFO message handler
 *      parv[0] = sender prefix
 *      parv[1] = TS_CURRENT for the server
 *      parv[2] = TS_MIN for the server
 *      parv[3] = clock ts 
 */
int m_svinfo(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
{
  aConfItem *aconf;
  time_t remote_ts = 0;
  struct Client *acptr;
  
  if (MyConnect(sptr) && IsUnknown(sptr))
    return exit_client(sptr, sptr, sptr, "Need SERVER before SVINFO");

  if (!IsServer(sptr) || !MyConnect(sptr) || parc < 3)
    return 0;
    
  if (TS_CURRENT < atoi(parv[2]) || atoi(parv[1]) < TS_MIN)
    {
      /*
       * a server with the wrong TS version connected; since we're
       * TS_ONLY we can't fall back to the non-TS protocol so
       * we drop the link  -orabidoo
       */
#ifdef HIDE_SERVERS_IPS
      sendto_realops("Link %s dropped, incompatible TS protocol version (%s,%s)",
                 get_client_name(sptr,MASK_IP), parv[1], parv[2]);
#else
      sendto_realops("Link %s dropped, incompatible TS protocol version (%s,%s)",
                 get_client_name(sptr, TRUE), parv[1], parv[2]);
#endif     
      return exit_client(sptr, sptr, sptr, "Incompatible TS version");
    }

  if(parc>3)
    {
      remote_ts = atol(parv[3]);
      if (UseIRCNTP && (remote_ts > 0)) 
        {
          if(IsService(cptr) || 
          ((aconf = find_conf_host(cptr->confs, sptr->name, CONF_HUB)) 
          	&& !(acptr = find_server(ServicesServer))))
            {
              ircntp_offset = remote_ts - time(NULL);
              sendto_realops("Adjusting IRCNTP offset to %d",
                ircntp_offset);
            }
        }
    }
    
  return 0;
}
示例#19
0
文件: send.c 项目: evilnet/nefarious2
/** Try to send a buffer to a client, queueing it if needed.
 * @param[in,out] to Client to send message to.
 * @param[in] buf Message to send.
 * @param[in] prio If non-zero, send as high priority.
 */
void send_buffer(struct Client* to, struct MsgBuf* buf, int prio)
{
  assert(0 != to);
  assert(0 != buf);

  if (cli_from(to))
    to = cli_from(to);

  if (!can_send(to))
    /*
     * This socket has already been marked as dead
     */
    return;

  if (MsgQLength(&(cli_sendQ(to))) > get_sendq(to)) {
    if (IsServer(to))
      sendto_opmask_butone(0, SNO_OLDSNO, "Max SendQ limit exceeded for %C: "
			   "%zu > %zu", to, MsgQLength(&(cli_sendQ(to))),
			   get_sendq(to));
    dead_link(to, "Max sendQ exceeded");
    return;
  }

  Debug((DEBUG_SEND, "Sending [%p] to %s", buf, cli_name(to)));

  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
   * because it counts messages even if queued, but bytes
   * only really sent. Queued bytes get updated in SendQueued.
   */
  ++(cli_sendM(to));
  ++(cli_sendM(&me));
  /*
   * This little bit is to stop the sendQ from growing too large when
   * there is no need for it to. Thus we call send_queued() every time
   * 2k has been added to the queue since the last non-fatal write.
   * Also stops us from deliberately building a large sendQ and then
   * trying to flood that link with data (possible during the net
   * relinking done by servers with a large load).
   */
  if (MsgQLength(&(cli_sendQ(to))) / 1024 > cli_lastsq(to))
    send_queued(to);
}
示例#20
0
文件: ircd_relay.c 项目: ryden/ircuRH
void server_relay_masked_notice(struct Client* sptr, const char* mask, const char* text)
{
  const char* s = mask;
  int         host_mask = 0;
  assert(0 != sptr);
  assert(0 != mask);
  assert(0 != text);

  if ('@' == *++s) {
    host_mask = 1;
    ++s;
  }
  sendcmdto_match_butone(sptr, CMD_NOTICE, s,
			 IsServer(cli_from(sptr)) ? cli_from(sptr) : 0,
			 host_mask ? MATCH_HOST : MATCH_SERVER,
			 "%s :%s", mask, text);
}
示例#21
0
void
jupe(char *name, char *reason)
{
	user_t *sptr = find_client(name);

	if (sptr && IsServer(sptr))
		squit(sptr->nick, "JUPED");
	add_linked_server(me.servname, name, reason);
	switch (me.servtype) {
		case SERV_IRCNN:
			toserv(":%s SERVER %s 2 %lu %lu P09 :%s\r\n", me.servname, name, time(NULL), time(NULL) + 1, reason);
			break;
		case SERV_HYBRD:
			toserv(":%s SERVER %s 1 :%s\r\n", me.servname, name, reason);
			break;
	}
}
示例#22
0
/// Destroys the pipe instance, freeing any resources.
CNamedPipe::~CNamedPipe () {
#ifndef _WIN32
	if (IsServer ()) {
		int file = GetFile ();
		if (file) {
			close (file);
			SetFile (0);
			if (unlink (m_pszName)) {
				LOGWARN (TEXT ("Couldn't delete pipe ") << m_pszName << TEXT (", error ") << GetLastError ());
			} else {
				LOGDEBUG (TEXT ("Deleted pipe ") << m_pszName);
			}
		}
	}
#endif
	delete m_pszName;
}
//-----------------------------------------------------------------------
void CWeapon::RequestCancelReload()
{
    CActor *pActor=GetOwnerActor();

    if (!gEnv->bServer && pActor && pActor->IsClient())
    {
        if(m_fm)
        {
            m_fm->CancelReload();
        }
        GetGameObject()->InvokeRMI(SvRequestCancelReload(), DefaultParams(), eRMI_ToServer);
    }
    else if (IsServer())
    {
        SvCancelReload();
    }
}
/*
 * ms_account - server message handler
 *
 * parv[0] = sender prefix
 * parv[1] = numeric of client to act on
 * parv[2] = account name (12 characters or less)
 */
int ms_account(struct Client* cptr, struct Client* sptr, int parc,
	       char* parv[])
{
  struct Client *acptr;
  int hidden;

  if (parc < 3)
    return need_more_params(sptr, "ACCOUNT");

  if (!IsServer(sptr))
    return protocol_violation(cptr, "ACCOUNT from non-server %s",
			      cli_name(sptr));

  if (!(acptr = findNUser(parv[1])))
    return 0; /* Ignore ACCOUNT for a user that QUIT; probably crossed */

  if (IsAccount(acptr))
    return protocol_violation(cptr, "ACCOUNT for already registered user %s "
			      "(%s -> %s)", cli_name(acptr),
			      cli_user(acptr)->account, parv[2]);

  assert(0 == cli_user(acptr)->account[0]);

  if (strlen(parv[2]) > ACCOUNTLEN) {
    return protocol_violation(cptr, "Received account (%s) longer than %d for %s; ignoring.", parv[2], ACCOUNTLEN, cli_name(acptr));
  }

  if (parc > 3) {
    cli_user(acptr)->acc_create = atoi(parv[3]);
    Debug((DEBUG_DEBUG, "Received timestamped account: account \"%s\", "
	   "timestamp %Tu", parv[2], cli_user(acptr)->acc_create));
  }

  hidden = HasHiddenHost(acptr);
  SetAccount(acptr);
  ircd_strncpy(cli_user(acptr)->account, parv[2], ACCOUNTLEN);
  if (!hidden)
    hide_hostmask(acptr);

  sendcmdto_serv_butone(sptr, CMD_ACCOUNT, cptr,
			cli_user(acptr)->acc_create ? "%C %s %Tu" : "%C %s",
			acptr, cli_user(acptr)->account,
			cli_user(acptr)->acc_create);

  return 0;
}
示例#25
0
void CAccessory::Physicalize( bool enable, bool rigid )
{
    const bool isMounted = (GetParentId() != 0);

    int profile = eIPhys_NotPhysicalized;
    if (enable && !isMounted)
        {
            profile = rigid ? eIPhys_PhysicalizedRigid : eIPhys_PhysicalizedStatic;
        }

    if (IsServer())
        {
            GetGameObject()->SetAspectProfile(eEA_Physics, profile);
        }

    m_deferPhysicalization = eIPhys_Max;
}
示例#26
0
/** Check whether any connected server matches crulearg[0].
 * @param[in] numargs Number of valid args in \a crulearg.
 * @param[in] crulearg Argument array.
 * @return Non-zero if the condition is true, zero if not.
 */
static int crule_connected(int numargs, void *crulearg[])
{
#if !defined(CR_DEBUG) && !defined(CR_CHKCONF)
  struct Client *acptr;

  /* taken from m_links */
  for (acptr = GlobalClientList; acptr; acptr = cli_next(acptr))
  {
    if (!IsServer(acptr) && !IsMe(acptr))
      continue;
    if (match((char *)crulearg[0], cli_name(acptr)))
      continue;
    return (1);
  }
#endif
  return (0);
}
示例#27
0
/* handle_command()
 *
 * inputs       - pointer to message block
 *              - pointer to client
 *              - pointer to client message is from
 *              - count of number of args
 *              - pointer to argv[] array
 * output       - -1 if error from server
 * side effects -
 */
static void
parse_handle_command(struct Message *message, struct Client *source_p,
                     unsigned int i, char *para[])
{
  if (IsServer(source_p->from))
    ++message->rcount;
  ++message->count;

  if (MyClient(source_p) && (message->flags & MFLG_ENDGRACE))
    flood_endgrace(source_p);

  /* Check right amount of parameters is passed... --is */
  if (i < message->args_min)
    sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, message->cmd);
  else
    message->handlers[source_p->from->handler](source_p, i, para);
}
示例#28
0
/* send_linebuf()
 *
 * inputs	- client to send to, linebuf to attach
 * outputs	-
 * side effects - linebuf is attached to client
 */
static int
_send_linebuf(struct Client *to, buf_head_t *linebuf)
{
    if(IsMe(to)) {
        sendto_realops_snomask(SNO_GENERAL, L_ALL, "Trying to send message to myself!");
        return 0;
    }

    if(!MyConnect(to) || IsIOError(to))
        return 0;

    if(rb_linebuf_len(&to->localClient->buf_sendq) > get_sendq(to)) {
        if(IsServer(to)) {
            sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                   "Max SendQ limit exceeded for %s: %u > %lu",
                                   to->name,
                                   rb_linebuf_len(&to->localClient->buf_sendq),
                                   get_sendq(to));

            ilog(L_SERVER, "Max SendQ limit exceeded for %s: %u > %lu",
                 log_client_name(to, SHOW_IP),
                 rb_linebuf_len(&to->localClient->buf_sendq),
                 get_sendq(to));
        }

        dead_link(to, 1);
        return -1;
    } else {
        /* just attach the linebuf to the sendq instead of
         * generating a new one
         */
        rb_linebuf_attach(&to->localClient->buf_sendq, linebuf);
    }

    /*
     ** Update statistics. The following is slightly incorrect
     ** because it counts messages even if queued, but bytes
     ** only really sent. Queued bytes get updated in SendQueued.
     */
    to->localClient->sendM += 1;
    me.localClient->sendM += 1;
    if(rb_linebuf_len(&to->localClient->buf_sendq) > 0)
        send_queued(to);
    return 0;
}
示例#29
0
static int crule_via(int numargs, void *crulearg[])
{
  struct Client *acptr;

  /* adapted from m_links */
  for (acptr = GlobalClientList; acptr; acptr = cli_next(acptr))
  {
    if (!IsServer(acptr) && !IsMe(acptr))
      continue;
    if (match((char *)crulearg[1], cli_name(acptr)))
      continue;
    if (match((char *)crulearg[0],
	      cli_name(LocalClientArray[cli_fd(cli_from(acptr))])))
      continue;
    return (1);
  }
  return (0);
}
示例#30
0
int
m_join(user_t *cptr, int parc, char **parv)
{
	channel *chan;
	char *ptr;

	if (!cptr || IsServer(cptr) || !parv[1] || !(ptr = strtok(parv[1], ",")))
		return 0;
	goto loopy;
	while ((ptr = strtok(NULL, ","))) {
loopy:		if (ptr[0] != '#')
			continue;
		if (!(chan = find_channel(ptr)))
			chan = add_channel(ptr, 0, 0);
		add_user_to_channel(cptr, chan, 0);
	}
	return 1;
}