示例#1
0
int find_invex(aChannel *chptr, aClient *sptr)
{
	/* This routine is basically a copy-paste of is_banned_with_nick, with modifications, for invex */
	Ban *inv;
	char *s;
	static char realhost[NICKLEN + USERLEN + HOSTLEN + 24];
	static char cloakhost[NICKLEN + USERLEN + HOSTLEN + 24];
	static char virthost[NICKLEN + USERLEN + HOSTLEN + 24];
	static char     nuip[NICKLEN + USERLEN + HOSTLEN + 24];
	Extban *extban;

	if (!IsPerson(sptr) || !chptr->invexlist)
		return 0;

	ban_realhost = realhost;
	ban_ip = ban_virthost = ban_cloakhost = NULL;

	if (GetIP(sptr))
	{
		make_nick_user_host_r(nuip, sptr->name, sptr->user->username, GetIP(sptr));
		ban_ip = nuip;
	}
	
	if (*sptr->user->cloakedhost)
	{
		make_nick_user_host_r(cloakhost, sptr->name, sptr->user->username, sptr->user->cloakedhost);
		ban_cloakhost = cloakhost;
	}

	if (IsSetHost(sptr) && strcmp(sptr->user->realhost, sptr->user->virthost))
	{
		make_nick_user_host_r(virthost, sptr->name, sptr->user->username, sptr->user->virthost);
		ban_virthost = virthost;
	}


	make_nick_user_host_r(realhost, sptr->name, sptr->user->username, sptr->user->realhost);

	for (inv = chptr->invexlist; inv; inv = inv->next)
		if (ban_check_mask(sptr, chptr, inv->banstr, BANCHK_JOIN, 0))
			return 1;

	return 0;
}
示例#2
0
/** is_banned_with_nick - Check if a user is banned on a channel.
 * @param sptr   Client to check (can be remote client)
 * @param chptr  Channel to check
 * @param type   Type of ban to check for (BANCHK_*)
 * @param nick   Nick of the user
 * @returns      A pointer to the ban struct if banned, otherwise NULL.
 */
Ban *is_banned_with_nick(aClient *sptr, aChannel *chptr, int type, char *nick)
{
	Ban *tmp, *tmp2;
	char *s;
	static char realhost[NICKLEN + USERLEN + HOSTLEN + 24];
	static char cloakhost[NICKLEN + USERLEN + HOSTLEN + 24];
	static char virthost[NICKLEN + USERLEN + HOSTLEN + 24];
	static char     nuip[NICKLEN + USERLEN + HOSTLEN + 24];
	int dovirt = 0, mine = 0;
	Extban *extban;

	if (!IsPerson(sptr) || !chptr->banlist)
		return NULL;

	ban_realhost = realhost;
	ban_ip = ban_virthost = ban_cloakhost = NULL;
	
	if (MyConnect(sptr))
	{
		mine = 1;
		make_nick_user_host_r(nuip, nick, sptr->user->username, GetIP(sptr));
		ban_ip = nuip;
		make_nick_user_host_r(cloakhost, nick, sptr->user->username, sptr->user->cloakedhost);
		ban_cloakhost = cloakhost;
	}

	if (IsSetHost(sptr) && strcmp(sptr->user->realhost, sptr->user->virthost))
	{
		dovirt = 1;
		make_nick_user_host_r(virthost, nick, sptr->user->username, sptr->user->virthost);
		ban_virthost = virthost;
	}


	make_nick_user_host_r(realhost, nick, sptr->user->username, sptr->user->realhost);

/* We now check +b first, if a +b is found we then see if there is a +e.
 * If a +e was found we return NULL, if not, we return the ban.
 */
	for (tmp = chptr->banlist; tmp; tmp = tmp->next)
	{
		if (*tmp->banstr == '~')
		{
			extban = findmod_by_bantype(tmp->banstr[1]);
			if (!extban)
				continue;
			if (!extban->is_banned(sptr, chptr, tmp->banstr, type))
				continue;
		} else {
			if ((match(tmp->banstr, realhost) == 0) ||
			    (dovirt && (match(tmp->banstr, virthost) == 0)) ||
			    (mine && (match(tmp->banstr, nuip) == 0)) ||
			    (mine && (match(tmp->banstr, cloakhost) == 0)) )
			{
				/* matches.. do nothing */
			} else
				continue;
		}

		/* Ban found, now check for +e */
		for (tmp2 = chptr->exlist; tmp2; tmp2 = tmp2->next)
		{
			if (*tmp2->banstr == '~')
			{
				extban = findmod_by_bantype(tmp2->banstr[1]);
				if (!extban)
					continue;
				if (extban->is_banned(sptr, chptr, tmp2->banstr, type))
					return NULL;
			} else {
				if ((match(tmp2->banstr, realhost) == 0) ||
					(dovirt && (match(tmp2->banstr, virthost) == 0)) ||
					(mine && (match(tmp2->banstr, nuip) == 0)) ||
					(mine && (match(tmp2->banstr, cloakhost) == 0)) )
					return NULL;
			}
		}
		break; /* ban found and not on except */
	}

	return (tmp);
}
示例#3
0
/** is_banned_with_nick - Check if a user is banned on a channel.
 * @param sptr   Client to check (can be remote client)
 * @param chptr  Channel to check
 * @param type   Type of ban to check for (BANCHK_*)
 * @param nick   Nick of the user
 * @returns      A pointer to the ban struct if banned, otherwise NULL.
 */
Ban *is_banned_with_nick(aClient *sptr, aChannel *chptr, int type, char *nick)
{
	Ban *tmp, *tmp2;
	char *s;
	static char realhost[NICKLEN + USERLEN + HOSTLEN + 24];
	static char cloakhost[NICKLEN + USERLEN + HOSTLEN + 24];
	static char virthost[NICKLEN + USERLEN + HOSTLEN + 24];
	static char     nuip[NICKLEN + USERLEN + HOSTLEN + 24];
	Extban *extban;

	if (!IsPerson(sptr) || !chptr->banlist)
		return NULL;

	ban_realhost = realhost;
	ban_ip = ban_virthost = ban_cloakhost = NULL;

	/* Might it be possible in the future to include the possiblity for SupportNICKIP(sptr->from), SupportCLK(sptr->from)? -- aquanight */
	/* Nope, because servers not directly connected to the server in question have no idea about the capabilities at all.
	 * However, there's no need for a MyConnect() requirement, just check if GetIP() is non-NULL and
	 * if sptr->user->cloakedhost contains anything... -- Syzop
	 */
	if (GetIP(sptr))
	{
		make_nick_user_host_r(nuip, nick, sptr->user->username, GetIP(sptr));
		ban_ip = nuip;
	}
	
	if (*sptr->user->cloakedhost)
	{
		make_nick_user_host_r(cloakhost, nick, sptr->user->username, sptr->user->cloakedhost);
		ban_cloakhost = cloakhost;
	}

	if (IsSetHost(sptr) && strcmp(sptr->user->realhost, sptr->user->virthost))
	{
		make_nick_user_host_r(virthost, nick, sptr->user->username, sptr->user->virthost);
		ban_virthost = virthost;
	}


	make_nick_user_host_r(realhost, nick, sptr->user->username, sptr->user->realhost);

	/* We now check +b first, if a +b is found we then see if there is a +e.
	 * If a +e was found we return NULL, if not, we return the ban.
	 */
	for (tmp = chptr->banlist; tmp; tmp = tmp->next)
	{
		if (!ban_check_mask(sptr, chptr, tmp->banstr, type, 0))
			continue;

		/* Ban found, now check for +e */
		for (tmp2 = chptr->exlist; tmp2; tmp2 = tmp2->next)
		{
			if (ban_check_mask(sptr, chptr, tmp2->banstr, type, 0))
				return NULL; /* except matched */
		}
		break; /* ban found and not on except */
	}

	return (tmp);
}