Exemple #1
0
char *ban_get_mask(IRC_CHANNEL_REC *channel, const char *nick)
{
	NICK_REC *rec;
	char *str, *user, *host;

	g_return_val_if_fail(IS_IRC_CHANNEL(channel), NULL);
	g_return_val_if_fail(nick != NULL, NULL);

	rec = nicklist_find(CHANNEL(channel), nick);
	if (rec == NULL || rec->host == NULL) return NULL;

	str = irc_get_mask(nick, rec->host, bantype);

	/* there's a limit of 10 characters in user mask. so, banning
	   someone with user mask of 10 characters gives us "*1234567890",
	   which is one too much.. so, replace the 10th character with '*' */
	user = strchr(str, '!');
	if (user == NULL) return str;

	host = strchr(++user, '@');
	if (host == NULL) return str;

	if ((int) (host-user) > 10) {
		/* too long user mask */
		user[9] = '*';
		g_memmove(user+10, host, strlen(host)+1);
	}
	return str;
}
Exemple #2
0
static void botcmd_ident(const char *data, IRC_SERVER_REC *server,
			 const char *nick, const char *address)
{
	USER_REC *user;
	char *mask;

	g_return_if_fail(data != NULL);

	user = botuser_find(nick, address);
	if (user != NULL) {
		/* Already know this host */
		return;
	}

	user = botuser_find(nick, NULL);
	if (user == NULL || !botuser_verify_password(user, data)) {
		/* failed password */
		return;
	}

	/* add the new mask */
	mask = irc_get_mask(nick, address, IRC_MASK_USER | IRC_MASK_DOMAIN);
	botcmd_user_add_mask(user, mask);

	irc_send_cmdv(server, "NOTICE %s :Added new mask %s", nick, mask);
	g_free(mask);
}
Exemple #3
0
char *ban_get_mask(IRC_CHANNEL_REC *channel, const char *nick, int ban_type)
{
	NICK_REC *rec;
	char *str, *user, *host;
        int size;

	g_return_val_if_fail(IS_IRC_CHANNEL(channel), NULL);
	g_return_val_if_fail(nick != NULL, NULL);

	rec = nicklist_find(CHANNEL(channel), nick);
	if (rec == NULL) return NULL;
	if (rec->host == NULL) {
		g_warning("channel %s is not synced, using nick ban for %s", channel->name, nick);
		return g_strdup_printf("%s!*@*", nick);
	}

	if (ban_type <= 0)
		ban_type = default_ban_type;

	str = irc_get_mask(nick, rec->host, ban_type);

	/* there's a limit of 10 characters in user mask. so, banning
	   someone with user mask of 10 characters gives us "*1234567890",
	   which is one too much.. so, remove the first character after "*"
           so we'll get "*234567890" */
	user = strchr(str, '!');
	if (user == NULL) return str;

	host = strchr(++user, '@');
	if (host == NULL) return str;

        size = (int) (host-user);
	if (size >= 10) {
		/* too long user mask */
		g_memmove(user+1, user+(size-9), strlen(user+(size-9))+1);
	}
	return str;
}