• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ IsOper函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IsOper函数的典型用法代码示例。如果您正苦于以下问题:C++ IsOper函数的具体用法?C++ IsOper怎么用?C++ IsOper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了IsOper函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: do_trace

static
void do_trace(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
{
    int i;
    struct Client *acptr;
    struct Client *acptr2;
    const struct ConnectionClass* cl;
    char* tname;
    int doall;
    int *link_s;
    int *link_u;
    int cnt = 0;
    int wilds;
    int dow;

    if (parc < 2 || BadPtr(parv[1]))
    {
        /* just "TRACE" without parameters. Must be from local client */
        parc = 1;
        acptr = &me;
        tname = cli_name(&me);
        i = HUNTED_ISME;
    }
    else if (parc < 3 || BadPtr(parv[2]))
    {
        /* No target specified. Make one before propagating. */
        parc = 2;
        tname = parv[1];
        if ((acptr = find_match_server(parv[1])) ||
                ((acptr = FindClient(parv[1])) && !MyUser(acptr)))
        {
            if (IsUser(acptr))
                parv[2] = cli_name(cli_user(acptr)->server);
            else
                parv[2] = cli_name(acptr);
            parc = 3;
            parv[3] = 0;
            if ((i = hunt_server_cmd(sptr, CMD_TRACE, cptr, IsServer(acptr),
                                     "%s :%C", 2, parc, parv)) == HUNTED_NOSUCH)
                return;
        }
        else
            i = HUNTED_ISME;
    } else {
        /* Got "TRACE <tname> :<target>" */
        parc = 3;
        if (MyUser(sptr) || Protocol(cptr) < 10)
            acptr = find_match_server(parv[2]);
        else
            acptr = FindNServer(parv[2]);
        if ((i = hunt_server_cmd(sptr, CMD_TRACE, cptr, 0, "%s :%C", 2, parc,
                                 parv)) == HUNTED_NOSUCH)
            return;
        tname = parv[1];
    }

    if (i == HUNTED_PASS) {
        if (!acptr)
            acptr = next_client(GlobalClientList, tname);
        else
            acptr = cli_from(acptr);
        send_reply(sptr, RPL_TRACELINK,
                   version, debugmode, tname,
                   acptr ? cli_name(cli_from(acptr)) : "<No_match>");
        return;
    }

    doall = (parv[1] && (parc > 1)) ? !match(tname, cli_name(&me)) : 1;
    wilds = !parv[1] || strchr(tname, '*') || strchr(tname, '?');
    dow = wilds || doall;

    /* Don't give (long) remote listings to lusers */
    if (dow && !MyConnect(sptr) && !IsAnOper(sptr)) {
        send_reply(sptr, RPL_TRACEEND);
        return;
    }

    link_s = MyCalloc(2 * maxconnections, sizeof(link_s[0]));
    link_u = link_s + maxconnections;

    if (doall) {
        for (acptr = GlobalClientList; acptr; acptr = cli_next(acptr)) {
            if (IsUser(acptr))
                link_u[cli_fd(cli_from(acptr))]++;
            else if (IsServer(acptr))
                link_s[cli_fd(cli_from(acptr))]++;
        }
    }

    /* report all direct connections */

    for (i = 0; i <= HighestFd; i++) {
        const char *conClass;

        if (!(acptr = LocalClientArray[i])) /* Local Connection? */
            continue;
        if (IsInvisible(acptr) && dow && !(MyConnect(sptr) && IsOper(sptr)) &&
                !IsAnOper(acptr) && (acptr != sptr))
            continue;
        if (!doall && wilds && match(tname, cli_name(acptr)))
//.........这里部分代码省略.........
开发者ID:jast,项目名称:ircu-now,代码行数:101,代码来源:m_trace.c


示例2: m_challenge

/*
 * m_challenge - generate RSA challenge for wouldbe oper
 * parv[1] = operator to challenge for, or +response
 *
 */
static int
m_challenge(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	struct oper_conf *oper_p;
	char *challenge = NULL; /* to placate gcc */
	char chal_line[CHALLENGE_WIDTH];
	unsigned char *b_response;
	size_t cnt;
	int len = 0;

	/* if theyre an oper, reprint oper motd and ignore */
	if(IsOper(source_p))
	{
		sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name);
		send_oper_motd(source_p);
		return 0;
	}

	if(*parv[1] == '+')
	{
		/* Ignore it if we aren't expecting this... -A1kmm */
		if(!source_p->localClient->challenge)
			return 0;

		if((rb_current_time() - source_p->localClient->chal_time) > CHALLENGE_EXPIRES)
		{
			sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name, source_p->name);
			ilog(L_FOPER, "EXPIRED CHALLENGE (%s) by (%s!%[email protected]%s) (%s)",
			     source_p->localClient->opername, source_p->name,
			     source_p->username, source_p->host, source_p->sockhost);

			if(ConfigFileEntry.failed_oper_notice)
				sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
						     "Expired CHALLENGE attempt by %s (%[email protected]%s)",
						     source_p->name, source_p->username,
						     source_p->host);
			cleanup_challenge(source_p);
			return 0;
		}

		parv[1]++;
		b_response = rb_base64_decode((const unsigned char *)parv[1], strlen(parv[1]), &len);

		if(len != SHA_DIGEST_LENGTH ||
		   memcmp(source_p->localClient->challenge, b_response, SHA_DIGEST_LENGTH))
		{
			sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name, source_p->name);
			ilog(L_FOPER, "FAILED CHALLENGE (%s) by (%s!%[email protected]%s) (%s)",
			     source_p->localClient->opername, source_p->name,
			     source_p->username, source_p->host, source_p->sockhost);

			if(ConfigFileEntry.failed_oper_notice)
				sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
						     "Failed CHALLENGE attempt by %s (%[email protected]%s)",
						     source_p->name, source_p->username,
						     source_p->host);

			rb_free(b_response);
			cleanup_challenge(source_p);
			return 0;
		}

		rb_free(b_response);

		oper_p = find_oper_conf(source_p->username, source_p->orighost,
					source_p->sockhost,
					source_p->localClient->opername);

		if(oper_p == NULL)
		{
			sendto_one_numeric(source_p, ERR_NOOPERHOST, form_str(ERR_NOOPERHOST));
			ilog(L_FOPER, "FAILED OPER (%s) by (%s!%[email protected]%s) (%s)",
			     source_p->localClient->opername, source_p->name,
			     source_p->username, source_p->host,
			     source_p->sockhost);

			if(ConfigFileEntry.failed_oper_notice)
				sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
						     "Failed CHALLENGE attempt - host mismatch by %s (%[email protected]%s)",
						     source_p->name, source_p->username,
						     source_p->host);
			return 0;
		}

		cleanup_challenge(source_p);

		oper_up(source_p, oper_p);

		ilog(L_OPERED, "OPER %s by %s!%[email protected]%s (%s)",
		     source_p->localClient->opername, source_p->name,
		     source_p->username, source_p->host, source_p->sockhost);
		return 0;
	}

	cleanup_challenge(source_p);
//.........这里部分代码省略.........
开发者ID:AbstractBeliefs,项目名称:charybdis,代码行数:101,代码来源:m_challenge.c


示例3: m_displaymsg

static int
m_displaymsg(struct Client *source_p, const char *channel, int underline, int action, const char *nick, const char *text)
{
    struct Channel *chptr;
    struct membership *msptr;
    char nick2[NICKLEN+1];
    char nick3[NICKLEN+1];
    char text2[BUFSIZE];

    if((chptr = find_channel(channel)) == NULL) {
        sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), channel);
        return 0;
    }

    if(!(msptr = find_channel_membership(chptr, source_p))) {
        sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
                           form_str(ERR_NOTONCHANNEL), chptr->chname);
        return 0;
    }

    if(!(chptr->mode.mode & chmode_flags['N'])) {
        sendto_one_numeric(source_p, 573, "%s :Roleplay commands are not enabled on this channel.", chptr->chname);
        return 0;
    }

    if(!can_send(chptr, source_p, msptr)) {
        sendto_one_numeric(source_p, 573, "%s :Cannot send to channel.", chptr->chname);
        return 0;
    }

    /* enforce flood stuff on roleplay commands */
    if(flood_attack_channel(0, source_p, chptr, chptr->chname))
        return 0;

    /* enforce target change on roleplay commands */
    if(!is_chanop_voiced(msptr) && !IsOper(source_p) && !add_channel_target(source_p, chptr)) {
        sendto_one(source_p, form_str(ERR_TARGCHANGE),
                   me.name, source_p->name, chptr->chname);
        return 0;
    }

    rb_strlcpy(nick3, nick, sizeof(nick3));

    if(underline)
        snprintf(nick2, sizeof(nick2), "\x1F%s\x1F", strip_unprintable(nick3));
    else
        snprintf(nick2, sizeof(nick2), "%s", strip_unprintable(nick3));

    /* don't allow nicks to be empty after stripping
     * this prevents nastiness like fake factions, etc. */
    if(EmptyString(nick3)) {
        sendto_one_numeric(source_p, 573, "%s :No visible non-stripped characters in nick.", chptr->chname);
        return 0;
    }

    if(action)
        snprintf(text2, sizeof(text2), "\1ACTION %s\1", text);
    else
        snprintf(text2, sizeof(text2), "%s", text);

    sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%[email protected] PRIVMSG %s :%s (%s)", nick2, source_p->name, channel, text2, source_p->name);
    sendto_match_servs(source_p, "*", CAP_ENCAP, NOCAPS, "ENCAP * ROLEPLAY %s %s :%s",
                       channel, nick2, text2);
    return 0;
}
开发者ID:CustomIRCd,项目名称:elemental-ircd,代码行数:65,代码来源:m_roleplay.c


示例4: m_kick


//.........这里部分代码省略.........
		 *     go through. Thats quite legit, but lets weird things like
		 *     KICKS by users who appear not to be chanopped happen,
		 *     or even neater, they appear not to be on the channel.
		 *     This fits every definition of a desync, doesn't it? ;-)
		 *     So I will allow the KICK, otherwise, things are MUCH worse.
		 *     But I will warn it as a possible desync.
		 *
		 *     -Dianora
		 */
	}

	if((p = strchr(parv[2], ',')))
		*p = '\0';

	msptr = find_channel_membership(chptr, who);

	if(msptr != NULL)
	{
		if(MyClient(source_p) && IsService(who))
		{
			sendto_one(source_p, form_str(ERR_ISCHANSERVICE),
				   me.name, source_p->name, who->name, chptr->chname);
			return 0;
		}

		if(MyClient(source_p) && chptr->mode.mode & MODE_NOKICK)
		{
			sendto_one_numeric(source_p, ERR_NOKICK,
					form_str(ERR_NOKICK),
					chptr->chname);
			return 0;
		}

		if (MyClient(source_p) && chptr->mode.mode & MODE_NOOPERKICK && IsOper(who))
		{
			sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
					"Overriding KICK from %s on %s in %s (channel is +M)",
					source_p->name, who->name, chptr->chname);
			sendto_one_numeric(source_p, ERR_ISCHANSERVICE,
					"%s %s :Cannot kick IRC operators from that channel.",
					who->name, chptr->chname);
			return 0;
		}

		if(MyClient(source_p))
		{
			hook_data_channel_approval hookdata;

			hookdata.client = source_p;
			hookdata.chptr = chptr;
			hookdata.target = who;
			hookdata.approved = 1;

			call_hook(h_can_kick, &hookdata);

			if (!hookdata.approved)
				return 0;
		}

		comment = LOCAL_COPY((EmptyString(parv[3])) ? who->name : parv[3]);
		if(strlen(comment) > (size_t) REASONLEN)
			comment[REASONLEN] = '\0';

		if(is_override)
		{
			sendto_wallops_flags(UMODE_WALLOP, &me,
开发者ID:DrRenX,项目名称:shadowircd-ac,代码行数:67,代码来源:m_kick.c


示例5: m_topic

/*
 * m_topic
 *      parv[1] = channel name
 *	parv[2] = new topic, if setting topic
 */
static int
m_topic(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	struct Channel *chptr = NULL;
	struct membership *msptr;
	char *p = NULL;
	const char *name;
	int operspy = 0;

	if((p = strchr(parv[1], ',')))
		*p = '\0';

	name = parv[1];

	if(IsOperSpy(source_p) && parv[1][0] == '!')
	{
		name++;
		operspy = 1;

		if(EmptyString(name))
		{
			sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
					me.name, source_p->name, "TOPIC");
			return 0;
		}
	}

	if(MyClient(source_p) && !IsFloodDone(source_p))
		flood_endgrace(source_p);

	chptr = find_channel(name);

	if(chptr == NULL)
	{
		sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
				form_str(ERR_NOSUCHCHANNEL), name);
		return 0;
	}

	/* setting topic */
	if(parc > 2)
	{
		msptr = find_channel_membership(chptr, source_p);

		if(msptr == NULL)
		{
			sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
					form_str(ERR_NOTONCHANNEL), name);
			return 0;
		}

		if(MyClient(source_p) && !is_chanop_voiced(msptr) &&
				!IsOper(source_p) &&
				!add_channel_target(source_p, chptr))
		{
			sendto_one(source_p, form_str(ERR_TARGCHANGE),
				   me.name, source_p->name, chptr->chname);
			return 0;
		}

		if(((chptr->mode.mode & MODE_TOPICLIMIT) == 0 ||
					get_channel_access(source_p, chptr, msptr, MODE_ADD, NULL) >= CHFL_CHANOP) &&
				(!MyClient(source_p) ||
				 can_send(chptr, source_p, msptr)))
		{
			char topic[TOPICLEN + 1];
			char topic_info[USERHOST_REPLYLEN];
			rb_strlcpy(topic, parv[2], sizeof(topic));
			rb_sprintf(topic_info, "%s!%[email protected]%s",
					source_p->name, source_p->username, source_p->host);

			if (ConfigChannel.strip_topic_colors)
				strip_colour(topic);

			set_channel_topic(chptr, topic, topic_info, rb_current_time());

			sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
					":%s TOPIC %s :%s",
					use_id(source_p), chptr->chname,
					chptr->topic == NULL ? "" : chptr->topic);
			sendto_channel_local(ALL_MEMBERS,
					chptr, ":%s!%[email protected]%s TOPIC %s :%s",
					source_p->name, source_p->username,
					source_p->host, chptr->chname,
					chptr->topic == NULL ? "" : chptr->topic);
		}
		else
			sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
					get_id(&me, source_p),
					get_id(source_p, source_p), name);
	}
	else if(MyClient(source_p))
	{
		if(operspy)
			report_operspy(source_p, "TOPIC", chptr->chname);
//.........这里部分代码省略.........
开发者ID:ntchambers,项目名称:charybdis,代码行数:101,代码来源:m_topic.c


示例6: m_cmessage

static int
m_cmessage(int p_or_n, const char *command,
		struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	struct Client *target_p;
	struct Channel *chptr;
	struct membership *msptr;

	if(!IsFloodDone(source_p))
		flood_endgrace(source_p);

	if((target_p = find_named_person(parv[1])) == NULL)
	{
		if(p_or_n != NOTICE)
			sendto_one_numeric(source_p, ERR_NOSUCHNICK,
					form_str(ERR_NOSUCHNICK), parv[1]);
		return 0;
	}

	if((chptr = find_channel(parv[2])) == NULL)
	{
		if(p_or_n != NOTICE)
			sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
					form_str(ERR_NOSUCHCHANNEL), parv[2]);
		return 0;
	}

	if((msptr = find_channel_membership(chptr, source_p)) == NULL)
	{
		if(p_or_n != NOTICE)
			sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
					form_str(ERR_NOTONCHANNEL),
					chptr->chname);
		return 0;
	}

	if(!is_chanop_voiced(msptr))
	{
		if(p_or_n != NOTICE)
			sendto_one(source_p, form_str(ERR_VOICENEEDED),
				me.name, source_p->name, chptr->chname);
		return 0;
	}

	if(!IsMember(target_p, chptr))
	{
		if(p_or_n != NOTICE)
			sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
					form_str(ERR_USERNOTINCHANNEL),
					target_p->name, chptr->chname);
		return 0;
	}

	if(MyClient(target_p) && (IsSetCallerId(target_p) || (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0])) &&
	   !accept_message(source_p, target_p) && !IsOper(source_p))
	{
		if (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0])
		{
			if (p_or_n != NOTICE)
				sendto_one_numeric(source_p, ERR_NONONREG,
						form_str(ERR_NONONREG),
						target_p->name);
			return 0;
		}
		if(p_or_n != NOTICE)
			sendto_one_numeric(source_p, ERR_TARGUMODEG,
					form_str(ERR_TARGUMODEG), target_p->name);

		if((target_p->localClient->last_caller_id_time +
		    ConfigFileEntry.caller_id_wait) < rb_current_time())
		{
			if(p_or_n != NOTICE)
				sendto_one_numeric(source_p, RPL_TARGNOTIFY,
						form_str(RPL_TARGNOTIFY),
						target_p->name);

			sendto_one(target_p, form_str(RPL_UMODEGMSG),
				me.name, target_p->name, source_p->name,
				source_p->username, source_p->host);

			target_p->localClient->last_caller_id_time = rb_current_time();
		}

		return 0;
	}

	if(p_or_n != NOTICE)
		source_p->localClient->last = rb_current_time();

	sendto_anywhere(target_p, source_p, command, ":%s", parv[3]);
	return 0;
}
开发者ID:dwfreed,项目名称:charybdis,代码行数:92,代码来源:m_cmessage.c


示例7: m_nick

/*! \brief NICK command handler (called by already registered,
 *         locally connected clients)
 *
 * \param client_p Pointer to allocated Client struct with physical connection
 *                 to this server, i.e. with an open socket connected.
 * \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] = sender prefix
 *      - parv[1] = nickname
 */
static void
m_nick(struct Client *client_p, struct Client *source_p,
       int parc, char *parv[])
{
  char nick[NICKLEN];
  struct Client *target_p = NULL;

  if (parc < 2 || EmptyString(parv[1]))
  {
    sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
               me.name, source_p->name);
    return;
  }

  /* mark end of grace period, to prevent nickflooding */
  if (!IsFloodDone(source_p))
    flood_endgrace(source_p);

  /* terminate nick to NICKLEN */
  strlcpy(nick, parv[1], sizeof(nick));

  /* check the nickname is ok */
  if (!clean_nick_name(nick, 1))
  {
    sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME),
               me.name, source_p->name, nick);
    return;
  }

  if (find_matching_name_conf(NRESV_TYPE, nick,
			     NULL, NULL, 0) && !IsExemptResv(source_p) &&
     !(IsOper(source_p) && ConfigFileEntry.oper_pass_resv))
  {
    sendto_one(source_p, form_str(ERR_ERRONEUSNICKNAME),
               me.name, source_p->name, nick);
    return;
  }

  if ((target_p = find_client(nick)) == NULL)
    change_local_nick(client_p, source_p, nick);
  else if (target_p == source_p)
  {
    /*
     * If (target_p == source_p) the client is changing nicks between
     * equivalent nicknames ie: [nick] -> {nick}
     */

    /* check the nick isnt exactly the same */
    if (strcmp(target_p->name, nick))
      change_local_nick(client_p, source_p, nick);
  }
  else if (IsUnknown(target_p))
  {
    /*
     * if the client that has the nick isn't registered yet (nick but no
     * user) then drop the unregged client
     */
    exit_client(target_p, &me, "Overridden");
    change_local_nick(client_p, source_p, nick);
  }
  else
    sendto_one(source_p, form_str(ERR_NICKNAMEINUSE), me.name,
               source_p->name, nick);
}
开发者ID:mdharris,项目名称:ircd,代码行数:78,代码来源:m_nick.c


示例8: do_numeric

/*
 *
 *      parc    number of arguments ('sender' counted as one!)
 *      parv[0] pointer to 'sender' (may point to empty string) (not used)
 *      parv[1]..parv[parc-1]
 *              pointers to additional parameters, this is a NULL
 *              terminated list (parv[parc] == NULL).
 *
 * *WARNING*
 *      Numerics are mostly error reports. If there is something
 *      wrong with the message, just *DROP* it! Don't even think of
 *      sending back a neat error message -- big danger of creating
 *      a ping pong error message...
 */
static void
do_numeric(char numeric[], struct Client *client_p, struct Client *source_p,
           int parc, char *parv[])
{
  struct Client *target_p;
  struct Channel *chptr;
  char *t;    /* current position within the buffer */
  int i, tl;  /* current length of presently being built string in t */

  if (parc < 2 || !IsServer(source_p))
    return;

  /* Remap low number numerics. */
  if (numeric[0] == '0')
    numeric[0] = '1';

  /* Prepare the parameter portion of the message into 'buffer'.
   * (Because the buffer is twice as large as the message buffer
   * for the socket, no overflow can occur here... ...on current
   * assumptions--bets are off, if these are changed --msa)
   */
  t = buffer;
  for (i = 2; i < (parc - 1); i++)
  {
    tl = ircsprintf(t, " %s", parv[i]);
    t += tl;
  }

  ircsprintf(t," :%s", parv[parc-1]);

  if (((target_p = find_person(client_p, parv[1])) != NULL) ||
      ((target_p = find_server(parv[1])) != NULL))
  {
    if (IsMe(target_p)) 
    {
      int num;

      /*
       * We shouldn't get numerics sent to us,
       * any numerics we do get indicate a bug somewhere..
       */
      /* ugh.  this is here because of nick collisions.  when two servers
       * relink, they burst each other their nicks, then perform collides.
       * if there is a nick collision, BOTH servers will kill their own
       * nicks, and BOTH will kill the other servers nick, which wont exist,
       * because it will have been already killed by the local server.
       *
       * unfortunately, as we cant guarantee other servers will do the
       * "right thing" on a nick collision, we have to keep both kills.  
       * ergo we need to ignore ERR_NOSUCHNICK. --fl_
       */
      /* quick comment. This _was_ tried. i.e. assume the other servers
       * will do the "right thing" and kill a nick that is colliding.
       * unfortunately, it did not work. --Dianora
       */

      /* Yes, a good compiler would have optimised this, but
       * this is probably easier to read. -db
       */
      num = atoi(numeric);

      if ((num != ERR_NOSUCHNICK))
        sendto_gnotice_flags(UMODE_ALL, L_ALL, me.name, &me, NULL,
			     "*** %s(via %s) sent a %s numeric to me: %s",
			     source_p->name, client_p->name, numeric, buffer);
      return;
    }
    else if (target_p->from == client_p) 
    {
      /* This message changed direction (nick collision?)
       * ignore it.
       */
      return;
    }

    /* csircd will send out unknown umode flag for +a (admin), drop it here. */
    if ((atoi(numeric) == ERR_UMODEUNKNOWNFLAG) && MyClient(target_p))
      return;
    
    /* Fake it for server hiding, if its our client */
    if (ConfigServerHide.hide_servers &&
        MyClient(target_p) && !IsOper(target_p))
      sendto_one(target_p, ":%s %s %s%s", me.name, numeric, target_p->name, buffer);
    else
      sendto_one(target_p, ":%s %s %s%s", ID_or_name(source_p, target_p->from),
                 numeric, ID_or_name(target_p, target_p->from), buffer);
//.........这里部分代码省略.........
开发者ID:Adam-,项目名称:oftc-hybrid,代码行数:101,代码来源:parse.c


示例9: do_other_who

static void do_other_who(aClient *sptr, char *mask)
{
int oper = IsAnOper(sptr);

	/* wildcard? */
#ifndef NO_FDLIST
	if (lifesux && !IsOper(sptr) && *mask == '*' && *(mask+1) == 0)
	{
		sendto_one(sptr, err_str(ERR_HTMDISABLED), me.name,
                    sptr->name, "/WHO");
		return;
	}
#endif		
	if (strchr(mask, '*') || strchr(mask, '?'))
	{
		int i = 0;
		/* go through all users.. */
		aClient *acptr;
		who_flags |= WF_WILDCARD;

		for (acptr = client; acptr; acptr = acptr->next)
		{
		int cansee;
		char status[20];
		char *channel;
		int flg;

			if (!IsPerson(acptr))
				continue;
			if (!oper) {
				/* non-opers can only search on nick here */
				if (match(mask, acptr->name))
					continue;
			} else {
				/* opers can search on name, ident, virthost, ip and realhost.
				 * Yes, I like readable if's -- Syzop.
				 */
				if (!match(mask, acptr->name) || !match(mask, acptr->user->realhost) ||
				    !match(mask, acptr->user->username))
					goto matchok;
				if (IsHidden(acptr) && !match(mask, acptr->user->virthost))
					goto matchok;
				if (acptr->user->ip_str && !match(mask, acptr->user->ip_str))
					goto matchok;
				/* nothing matched... */
				continue;
			}
matchok:
			if ((cansee = can_see(sptr, acptr, NULL)) & WHO_CANTSEE)
				continue;
			if (WHOLIMIT && !IsAnOper(sptr) && ++i > WHOLIMIT)
			{
				sendto_one(sptr, rpl_str(ERR_WHOLIMEXCEED), me.name, sptr->name, WHOLIMIT);
				return;
			}

			channel = first_visible_channel(sptr, acptr, &flg);
			make_who_status(sptr, acptr, NULL, NULL, status, cansee);
			send_who_reply(sptr, acptr, channel, status, (flg & FVC_HIDDEN) ? "~" : "");
		}
	}
	else
	{
		/* just a single client (no wildcards detected) */
		aClient *acptr = find_client(mask, NULL);
		int cansee;
		char status[20];
		char *channel;
		int flg;

		if (!acptr)
			return;

		if ((cansee = can_see(sptr, acptr, NULL)) == WHO_CANTSEE)
			return;

		channel = first_visible_channel(sptr, acptr, &flg);
		make_who_status(sptr, acptr, NULL, NULL, status, cansee);
		send_who_reply(sptr, acptr, channel, status, (flg & FVC_HIDDEN) ? "~" : "");
	}
}
开发者ID:Adam-,项目名称:unrealircd,代码行数:81,代码来源:m_who.c


示例10: CMD_FUNC

/*
 * m_userip is based on m_userhost
 * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce
 * the need for complicated requests like WHOIS. It returns user/host
 * information only (no spurious AWAY labels or channels).
 * Re-written by Dianora 1999
 */
DLLFUNC CMD_FUNC(m_userip)
{

	char *p;		/* scratch end pointer */
	char *cn;		/* current name */
	char *ip, ipbuf[HOSTLEN+1];
	struct Client *acptr;
	char response[5][NICKLEN * 2 + CHANNELLEN + USERLEN + HOSTLEN + 30];
	int  i;			/* loop counter */

	if (!MyClient(sptr))
		return -1;
		
	if (parc < 2)
	{
		sendto_one(sptr, rpl_str(ERR_NEEDMOREPARAMS),
		    me.name, parv[0], "USERIP");
		return 0;
	}

	/* The idea is to build up the response string out of pieces
	 * none of this strlen() nonsense.
	 * 5 * (NICKLEN*2+CHANNELLEN+USERLEN+HOSTLEN+30) is still << sizeof(buf)
	 * and our ircsprintf() truncates it to fit anyway. There is
	 * no danger of an overflow here. -Dianora
	 */
	response[0][0] = response[1][0] = response[2][0] =
	    response[3][0] = response[4][0] = '\0';

	cn = parv[1];

	for (i = 0; (i < 5) && cn; i++)
	{
		if ((p = strchr(cn, ' ')))
			*p = '\0';

		if ((acptr = find_person(cn, NULL)))
		{
			if (!(ip = GetIP(acptr)))
				ip = "<unknown>";
			if (sptr != acptr && !IsOper(sptr) && IsHidden(acptr))
			{
				make_virthost(acptr, GetIP(acptr), ipbuf, 0);
				ip = ipbuf;
			}

			ircsprintf(response[i], "%s%s=%c%[email protected]%s",
			    acptr->name,
			    (IsAnOper(acptr) && (!IsHideOper(acptr) || sptr == acptr || IsAnOper(sptr)))
				? "*" : "",
			    (acptr->user->away) ? '-' : '+',
			    acptr->user->username, ip);
			/* add extra fakelag (penalty) because of all the work we need to do: 1s per entry: */
			sptr->since += 1;
		}
		if (p)
			p++;
		cn = p;
	}

	sendto_one(sptr, rpl_str(RPL_USERIP), me.name, parv[0],
	    response[0], response[1], response[2], response[3], response[4]);

	return 0;
}
开发者ID:Adam-,项目名称:unrealircd,代码行数:72,代码来源:m_userip.c


示例11: m_away

/*
** m_away
**      parv[0] = sender prefix
**      parv[1] = away message
*/
static int
m_away(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	char *away;
	char *awy2 = LOCAL_COPY(parv[1]);

	if(MyClient(source_p) && !IsFloodDone(source_p))
		flood_endgrace(source_p);

	if(!IsClient(source_p))
		return 0;

	away = source_p->user->away;

	if(parc < 2 || !*awy2)
	{
		/* Marking as not away */

		if(away)
		{
			/* 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));
			sendto_server(client_p, NULL, NOCAPS, CAP_TS6, 
				      ":%s AWAY", source_p->name);
			MyFree(away);
			source_p->user->away = NULL;
		}
		if(MyConnect(source_p))
			sendto_one(source_p, form_str(RPL_UNAWAY),
				   me.name, source_p->name);
		return 0;
	}

	/* Marking as away */

	if(MyConnect(source_p) && !IsOper(source_p) &&
	   (CurrentTime - source_p->user->last_away) < ConfigFileEntry.pace_wait)
	{
		sendto_one(source_p, form_str(RPL_LOAD2HI), 
			   me.name, source_p->name, "AWAY");
		return 0;
	}

	source_p->user->last_away = CurrentTime;

	if(strlen(awy2) > (size_t) TOPICLEN)
		awy2[TOPICLEN] = '\0';

	/* we now send this only if they weren't away already --is */
	if(!away)
	{
		sendto_server(client_p, NULL, CAP_TS6, NOCAPS, 
			      ":%s AWAY :%s", use_id(source_p), awy2);
		sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
			      ":%s AWAY :%s", source_p->name, awy2);
	}
	else
		MyFree(away);

	DupString(away, awy2);

	source_p->user->away = away;

	if(MyConnect(source_p))
		sendto_one(source_p, form_str(RPL_NOWAWAY), me.name, source_p->name);

	return 0;
}
开发者ID:Cloudxtreme,项目名称:ircd-ratbox,代码行数:74,代码来源:m_away.c


示例12: versionscan_handler

void versionscan_handler(nick* me, int type, void** args) {
  nick* sender;
  Command* cmd;
  char* cargv[50];
  int cargc;
  vspattern* v;
  char* p;

  switch (type) {
  case LU_PRIVMSG:
  case LU_SECUREMSG:
    /* nick */
    sender=args[0];
    
    if (!strncmp("\001VERSION", args[1], 8)) {
      sendnoticetouser(versionscan_nick, sender, "\001VERSION QuakeNet %s v%s.\001", VS_RNDESC, VS_VERSION);
      return;
    }
    
    cargc=splitline((char*)args[1], cargv, 50, 0);
    
    cmd=findcommandintree(versionscan_commands, cargv[0], 1);
    if (!cmd) {
      sendnoticetouser(versionscan_nick, sender, "Unknown command.");
      return;
    }
    
    if ((cmd->level & VS_AUTHED) && !IsAccount(sender)) {
      sendnoticetouser(versionscan_nick, sender, "Sorry, you need to be authed to use this command.");
      return;
    }
    
    if ((cmd->level & VS_OPER) && !IsOper(sender)) {
      sendnoticetouser(versionscan_nick, sender, "Sorry, you need to be opered to use this command.");
      return;
    }
    
    if (((cmd->level & VS_STAFF) && !IsVersionscanStaff(sender)) || 
        ((cmd->level & VS_GLINE) && !IsVersionscanGlineAccess(sender)) || 
        ((cmd->level & VS_ADMIN) && !IsVersionscanAdmin(sender))) {
      sendnoticetouser(versionscan_nick, sender, "Sorry, you do not have access to this command.");
      return;
    }
    
    if (cmd->maxparams < (cargc-1)) {
      /* We need to do some rejoining */
      rejoinline(cargv[cmd->maxparams], cargc-(cmd->maxparams));
      cargc=(cmd->maxparams)+1;
    }
    
    (cmd->handler)((void*)sender, cargc-1, &(cargv[1]));
    break;
  case LU_PRIVNOTICE:
    sender=args[0];
    
    if (strncmp("\001VERSION ", args[1], 9)) {
      break;
    }
    if ((p=strchr((char *)args[1] + 9, '\001'))) {
      *p++='\0';
    }
    if (versionscan_mode == VS_SCAN) {
      if (IsOper(sender)) {
        break;
      }
      for (v=vspatterns; v; v=v->next) {
        if (match2strings(v->pattern, (char *)args[1] + 9)) {
          v->hitcount++;
          hcount++;
          switch (v->action) {
          case VS_WARN:
            sendnoticetouser(versionscan_nick, sender, "%s", v->data);
            wcount++;
            break;
          case VS_KILL:
            killuser(versionscan_nick, sender, "%s", v->data);
            kcount++;
            break;
          case VS_GLUSER:
            glinebynick(sender, 3600, v->data, GLINE_ALWAYS_USER, "versionscan");
            gcount++;
            break;
          case VS_GLHOST:
            glinebynick(sender, 3600, v->data, 0, "versionscan");
            gcount++;
            break;
          default:
            /* oh dear, something's fucked */
            break;
          }
         break;
        }
      }
    }
    else if (versionscan_mode == VS_STAT) {
      versionscan_addstat((char *)args[1] + 9);
    }
    break;
  case LU_KILLED:
    versionscan_nick=NULL;
//.........这里部分代码省略.........
开发者ID:quakenet,项目名称:newserv,代码行数:101,代码来源:versionscan.c


示例13: m_whowas

/*
** m_whowas
**      parv[1] = nickname queried
*/
static int
m_whowas(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{	
	struct Whowas *temp;
	int cur = 0;
	int max = -1, found = 0;
	char *p;
	const char *nick;
	char tbuf[26];
	long sendq_limit;

	static time_t last_used = 0L;

	if(!IsOper(source_p))
	{
		if((last_used + ConfigFileEntry.pace_wait_simple) > rb_current_time())
		{
			sendto_one(source_p, form_str(RPL_LOAD2HI),
				   me.name, source_p->name, "WHOWAS");
			sendto_one(source_p, form_str(RPL_ENDOFWHOWAS),
				   me.name, source_p->name, parv[1]);
			return 0;
		}
		else
			last_used = rb_current_time();
	}


	if(parc > 2)
		max = atoi(parv[2]);

#if 0
	if(parc > 3)
		if(hunt_server(client_p, source_p, ":%s WHOWAS %s %s :%s", 3, parc, parv))
			return 0;
#endif

	if((p = strchr(parv[1], ',')))
		*p = '\0';

	nick = parv[1];

	sendq_limit = get_sendq(client_p) * 9 / 10;

	temp = WHOWASHASH[hash_whowas_name(nick)];
	found = 0;
	for (; temp; temp = temp->next)
	{
		if(!irccmp(nick, temp->name))
		{
			if(cur > 0 && rb_linebuf_len(&client_p->localClient->buf_sendq) > sendq_limit)
			{
				sendto_one(source_p, form_str(ERR_TOOMANYMATCHES),
					   me.name, source_p->name, "WHOWAS");
				break;
			}
			sendto_one(source_p, form_str(RPL_WHOWASUSER),
				   me.name, source_p->name, temp->name,
				   temp->username, temp->hostname, temp->realname);
			if (MyOper(source_p) && !EmptyString(temp->sockhost))
#if 0
				sendto_one(source_p, form_str(RPL_WHOWASREAL),
					   me.name, source_p->name, temp->name,
					   "<untracked>", temp->sockhost);
#else
				sendto_one_numeric(source_p, RPL_WHOISACTUALLY,
						   form_str(RPL_WHOISACTUALLY),
						   temp->name, temp->sockhost);
#endif
			if (!EmptyString(temp->suser))
				sendto_one_numeric(source_p, RPL_WHOISLOGGEDIN,
						   "%s %s :was logged in as",
						   temp->name, temp->suser);
			sendto_one_numeric(source_p, RPL_WHOISSERVER,
					   form_str(RPL_WHOISSERVER),
					   temp->name, temp->servername,
					   rb_ctime(temp->logoff, tbuf, sizeof(tbuf)));
			cur++;
			found++;
		}
		if(max > 0 && cur >= max)
			break;
	}

	if(!found)
		sendto_one(source_p, form_str(ERR_WASNOSUCHNICK), 
			   me.name, source_p->name, nick);

	sendto_one(source_p, form_str(RPL_ENDOFWHOWAS), 
		   me.name, source_p->name, parv[1]);
	return 0;
}
开发者ID:ShutterQuick,项目名称:charybdis,代码行数:96,代码来源:m_whowas.c


示例14: m_ircops

/*
** m_ircops() By Claudio
** Rewritten by HAMLET
**   Lists online IRCOps
**
*/
int m_ircops(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
{
  struct Client *acptr;
  char *status;
  char buf[BUFSIZE];
  int locals = 0, globals = 0;

  if (!IRCopsForAll && !IsPrivileged(cptr))
    {
      sendto_one(sptr, form_str(ERR_NOPRIVILEGES), me.name, parv[0]);
      return 0;
    }
	
  strcpy(buf, "========================================================================================");
  sendto_one(sptr, form_str(RPL_LISTS), me.name, parv[0], buf);
  strcpy(buf, "\2Nick                           Status                           Server\2");
  sendto_one(sptr, form_str(RPL_LISTS), me.name, parv[0], buf);
  strcpy(buf, "----------------------------------------------------------------------------------------");
  sendto_one(sptr, form_str(RPL_LISTS), me.name, parv[0], buf);
  for (acptr = GlobalClientList; acptr; acptr = acptr->next)
	{
  	  if (!IsService(acptr) && !IsStealth(acptr) &&  IsAnOper(acptr)
  	     && (!IsHideOper(acptr) || IsAnOper(sptr)) ) {
    
          if (!acptr->user) continue;

	  if (IsTechAdmin(acptr)) 
		status = "Technical Administrator";
	  else if (IsNetAdmin(acptr)) 
		status = "Network Administrator";
	  else if (IsSAdmin(acptr)) 
		status = "Services Administrator";
	  else if (IsAdmin(acptr)) 
		status = "Server Administrator";		
	  else if(IsOper(acptr))
		status = "Global IRC Operator"; 
	  else
		status = "Local IRC Operator";  	
	  

/* vlinks on /IRCops
* code by openglx
* idea to this by Midnight_Commander
*/
    if (acptr->user && acptr->user->vlink)
      {
        ircsprintf(buf, "\2%-29s\2  %-23s  %-6s  %s", acptr->name ? acptr->name : "<unknown>", status,
                              acptr->user->away ? "(AWAY)" : "", acptr->user->vlink->name);
      }
    else
      {
      ircsprintf(buf, "\2%-29s\2  %-23s  %-6s  %s", acptr->name ? acptr->name : "<unknown>", status,
                            acptr->user->away ? "(AWAY)" : "", acptr->user->server);
      }
      
/* end of the vlink support code */
                                                                                                 
          sendto_one(sptr, form_str(RPL_LISTS), me.name, parv[0], buf);
          sendto_one(sptr, form_str(RPL_LISTS), me.name, parv[0], "-");
          if (IsOper(acptr)) globals++;
          else locals++;
    	}
    }
 
  ircsprintf(buf, "Total: \2%d\2 IRCOp%s connected - \2%d\2 Globa%s, \2%d\2 Loca%s", globals+locals,
                        (globals+locals) > 1 ? "s" : "",
                        globals, globals > 1 ? "ls" : "l", locals, locals > 1 ? "ls" : "l");
  sendto_one(sptr, form_str(RPL_LISTS), me.name, parv[0], buf);
  strcpy(buf, "========================================================================================");
  sendto_one(sptr, form_str(RPL_LISTS), me.name, parv[0], buf);
  sendto_one(sptr, form_str(RPL_ENDOFLISTS), me.name, parv[0], "IRCOPS");
  return 0;
}
开发者ID:diegoagudo,项目名称:taps-ircd,代码行数:79,代码来源:m_ircops.c


示例15: msg_client


//.........这里部分代码省略.........
  		if (F && !F->ssl) {
#endif
  			sendto_one(source_p, form_str(source_p,ERR_SSLACCEPTONLY),
  				me.name, source_p->name, target_p->name);
  			return;
  			
#ifdef HAVE_LIBCRYPTO
		}
#endif
	}
  }

  if (MyConnect(source_p) && (p_or_n != NOTICE) &&
      target_p->user && target_p->user->away)
    sendto_one(source_p, form_str(source_p,RPL_AWAY), me.name,
               source_p->name, target_p->name, target_p->user->away);

  if (MyClient(target_p))
  {
    if (IsSetRegAccept(target_p) && !(source_p->svsflags & FLAGS_SVS_IDENT))
	{
	  if (p_or_n != NOTICE)
	    sendto_one(source_p, form_str(source_p,ERR_REGACCEPTONLY),
		       me.name, source_p->name, target_p->name);
	    return;
	}

	if (ConfigFileEntry.spam_wait && (p_or_n != NOTICE) &&
	((target_p->localClient->last_join_time + ConfigFileEntry.spam_wait > CurrentTime) ||
	(target_p->localClient->last_leave_time + ConfigFileEntry.spam_wait > CurrentTime)))
	{
		sendto_anywhere(source_p, target_p, 
			"NOTICE %s :*** I'm joining/leaving a chan, please try again in a few seconds.",
			source_p->name);
		return;
	}

    if (!IsServer(source_p) && IsSetCallerId(target_p))
    {
      /* Here is the anti-flood bot/spambot code -db */
      if (accept_message(source_p, target_p) || (source_p == target_p) ||
          find_z_conf((char *)source_p->user->server))
      {
        sendto_one(target_p, ":%s!%[email protected]%s %s %s :%s",
                   source_p->name,
                   source_p->username,
                   source_p->host, 
                   command, target_p->name, translate(target_p, text));
      }
      else
      {
        /* check for accept, flag recipient incoming message */
        if (p_or_n != NOTICE)
          sendto_anywhere(source_p, target_p,
                          "NOTICE %s :*** I'm in +g mode (server side ignore).",
                          source_p->name);

        if ((target_p->localClient->last_caller_id_time +
             ConfigFileEntry.caller_id_wait) < CurrentTime)
        {
          if (p_or_n != NOTICE)
            sendto_anywhere(source_p, target_p,
                            "NOTICE %s :*** I've been informed you messaged me.",
                            source_p->name);

          sendto_one(target_p,
                     ":%s NOTICE %s :*** Client %s [%[email protected]%s] is messaging you and you are +g",
                     me.name, target_p->name,
                     source_p->name, source_p->username, source_p->host);

          target_p->localClient->last_caller_id_time = CurrentTime;

        }
        /* Only so opers can watch for floods */
        (void)flood_attack_client(p_or_n, source_p, target_p);
      }
    }
    else
    {
      /* If the client is remote, we dont perform a special check for
       * flooding.. as we wouldnt block their message anyway.. this means
       * we dont give warnings.. we then check if theyre opered 
       * (to avoid flood warnings), lastly if theyre our client
       * and flooding    -- fl */
      if (!MyClient(source_p) || IsOper(source_p) ||
          (MyClient(source_p) &&
           !flood_attack_client(p_or_n, source_p, target_p)))
        sendto_anywhere(target_p, source_p, "%s %s :%s",
                        command, target_p->name, translate(target_p, text));
    }
  }
  else
    /* The target is a remote user.. same things apply  -- fl */
  if (!MyClient(source_p) || IsOper(source_p) ||
        (MyClient(source_p)
           && !flood_attack_client(p_or_n, source_p, target_p)))
    sendto_anywhere(target_p, source_p, "%s %s :%s", command, target_p->name,
                    text);
  return;
}
开发者ID:Cloudxtreme,项目名称:ircd-3,代码行数:101,代码来源:m_message.c


示例16: m_kill


//.........这里部分代码省略.........
		{
			sendto_one(sptr, err_str(ERR_KILLDENY), me.name,
			    parv[0], parv[1]);
			return 0;
		}
		/* From here on, the kill is probably going to be successful. */

		kcount++;

		if (!IsServer(sptr) && (kcount > MAXKILLS))
		{
			sendto_one(sptr,
			    ":%s %s %s :*** Too many targets, kill list was truncated. Maximum is %d.",
			    me.name, IsWebTV(sptr) ? "PRIVMSG" : & 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IsOperatorControl函数代码示例发布时间:2022-05-30
下一篇:
C++ IsOpened函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap