static int eb_extended(const char *data, struct Client *client_p,
                       struct Channel *chptr, long mode_type)
{
    char buf[BUFSIZE];
    int ret;

    (void)chptr;

    if (data == NULL)
        return EXTBAN_INVALID;

    rb_snprintf(buf, BUFSIZE, "%s!%s@%s#%s",
                client_p->name, client_p->username, client_p->host, client_p->info);

    ret = match(data, buf) ? EXTBAN_MATCH : EXTBAN_NOMATCH;

    if (ret == EXTBAN_NOMATCH && IsDynSpoof(client_p)) {
        rb_snprintf(buf, BUFSIZE, "%s!%s@%s#%s",
                    client_p->name, client_p->username, client_p->orighost, client_p->info);

        ret = match(data, buf) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
    }

    return ret;
}
示例#2
0
void add_history(struct Client *client_p, int online)
{
	struct Whowas *who = &WHOWAS[whowas_next];

	s_assert(NULL != client_p);

	if(client_p == NULL)
		return;

	if(who->hashv != -1)
	{
		if(who->online)
			del_whowas_from_clist(&(who->online->whowas), who);
		del_whowas_from_list(&WHOWASHASH[who->hashv], who);
	}
	who->hashv = hash_whowas_name(client_p->name);
	who->logoff = rb_current_time();
	/*
	 * NOTE: strcpy ok here, the sizes in the client struct MUST
	 * match the sizes in the whowas struct
	 */
	rb_strlcpy(who->name, client_p->name, sizeof(who->name));
	strcpy(who->username, client_p->username);
	strcpy(who->hostname, client_p->host);
	strcpy(who->realname, client_p->info);
	strcpy(who->suser, client_p->user->suser);
	strcpy(who->sockhost, client_p->sockhost);
	who->flags = (IsIPSpoof(client_p) ? WHOWAS_IP_SPOOFING : 0) |
		(IsDynSpoof(client_p) ? WHOWAS_DYNSPOOF : 0);

	who->servername = scache_get_name(client_p->servptr->serv->nameinfo);

	if(online)
	{
		who->online = client_p;
		add_whowas_to_clist(&(client_p->whowas), who);
	}
	else
		who->online = NULL;
	add_whowas_to_list(&WHOWASHASH[who->hashv], who);
	whowas_next++;
	if(whowas_next == NICKNAMEHISTORYLENGTH)
		whowas_next = 0;
}
static void
check_umode_change(void *vdata)
{
	hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
	struct Client *source_p = data->client;

	if (!MyClient(source_p))
		return;

	/* didn't change +h umode, we don't need to do anything */
	if (!((data->oldumodes ^ source_p->umodes) & user_modes['h']))
		return;

	if (source_p->umodes & user_modes['h'])
	{
		if (IsIPSpoof(source_p) || source_p->localClient->mangledhost == NULL || (IsDynSpoof(source_p) && strcmp(source_p->host, source_p->localClient->mangledhost)))
		{
			source_p->umodes &= ~user_modes['h'];
			return;
		}
		if (strcmp(source_p->host, source_p->localClient->mangledhost))
		{
			strlcpy(source_p->host, source_p->localClient->mangledhost, HOSTLEN);
			distribute_hostchange(source_p);
		}
		else /* not really nice, but we need to send this numeric here */
			sendto_one_numeric(source_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
				source_p->host);
	}
	else if (!(source_p->umodes & user_modes['h']))
	{
		if (source_p->localClient->mangledhost != NULL &&
				!strcmp(source_p->host, source_p->localClient->mangledhost))
		{
			strlcpy(source_p->host, source_p->orighost, HOSTLEN);
			distribute_hostchange(source_p);
		}
	}
}
示例#4
0
static int
eb_hostmask(const char *banstr, struct Client *client_p, struct Channel *chptr, long mode_type)
{
    char src_host[NICKLEN + USERLEN + HOSTLEN + 6];
    char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6];
    char src_althost[NICKLEN + USERLEN + HOSTLEN + 6];
    char src_ip4host[NICKLEN + USERLEN + HOSTLEN + 6];
    struct sockaddr_in ip4;
    char *s = src_host, *s2 = src_iphost, *s3 = NULL, *s4 = NULL;

    sprintf(src_host, "%s!%s@%s", client_p->name, client_p->username, client_p->host);
    sprintf(src_iphost, "%s!%s@%s", client_p->name, client_p->username, client_p->sockhost);

    /* handle hostmangling if necessary */
    if (client_p->localClient->mangledhost != NULL)
    {
        if (!strcmp(client_p->host, client_p->localClient->mangledhost))
            sprintf(src_althost, "%s!%s@%s", client_p->name, client_p->username, client_p->orighost);
        else if (!IsDynSpoof(client_p))
            sprintf(src_althost, "%s!%s@%s", client_p->name, client_p->username, client_p->localClient->mangledhost);

        s3 = src_althost;
    }

#ifdef RB_IPV6
    /* handle Teredo if necessary */
    if (client_p->localClient->ip.ss_family == AF_INET6 && ipv4_from_ipv6((const struct sockaddr_in6 *) &client_p->localClient->ip, &ip4))
    {
        sprintf(src_ip4host, "%s!%s@", client_p->name, client_p->username);
        s4 = src_ip4host + strlen(src_ip4host);
        rb_inet_ntop_sock((struct sockaddr *)&ip4,
                          s4, src_ip4host + sizeof src_ip4host - s4);
        s4 = src_ip4host;
    }
#endif

    return match(banstr, s) || match(banstr, s2) || (s3 != NULL && match(banstr, s3)) || (s4 != NULL && match(banstr, s4)) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
}
static void
check_new_user(void *vdata)
{
	struct Client *source_p = (void *)vdata;

	if (IsIPSpoof(source_p))
	{
		source_p->umodes &= ~user_modes['h'];
		return;
	}
	source_p->localClient->mangledhost = MyMalloc(HOSTLEN);
	if (!irccmp(source_p->orighost, source_p->sockhost))
		do_host_cloak(source_p->orighost, source_p->localClient->mangledhost, 1);
	else
		do_host_cloak(source_p->orighost, source_p->localClient->mangledhost, 0);
	if (IsDynSpoof(source_p))
		source_p->umodes &= ~user_modes['h'];
	if (source_p->umodes & user_modes['h'])
	{
		strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host));
		if (irccmp(source_p->host, source_p->orighost))
			SetDynSpoof(source_p);
	}
}