Example #1
0
	/*
	 ** NICK - new
	 **	  source  = NULL
	 **	  parv[0] = nickname
	 **	  parv[1] = hopcount
	 **	  parv[2] = timestamp
	 **	  parv[3] = modes
	 **	  parv[4] = username
	 **	  parv[5] = hostname
	 **	  parv[6] = server
	 **	  parv[7] = servicestamp
	 **	  parv[8] = IP
	 **	  parv[9] = info
	 ** NICK - change
	 **	  source  = oldnick
	 **	  parv[0] = new nickname
	 **	  parv[1] = hopcount
	 */
	bool OnNick(const Anope::string &source, const std::vector<Anope::string> &params)
	{
		if (params.size() != 2)
		{
			/* Currently bahamut has no ipv6 support */
			sockaddrs ip;
			ip.ntop(AF_INET, params[8].c_str());

			User *user = do_nick(source, params[0], params[4], params[5], params[6], params[9], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, ip.addr(), "", "", params[3]);
			if (user && nickserv)
			{
				NickAlias *na;
				if (user->timestamp == convertTo<time_t>(params[7]) && (na = findnick(user->nick)))
				{
					user->Login(na->nc);
					if (!Config->NoNicknameOwnership && na->nc->HasFlag(NI_UNCONFIRMED) == false)
						user->SetMode(findbot(Config->NickServ), UMODE_REGISTERED);
				}
				else
					nickserv->Validate(user);
			}
		}
		else
			do_nick(source, params[0], "", "", "", "", Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0, "", "", "", "");

		return true;
	}
Example #2
0
/*
 do_nick(const char *source, char *nick, char *username, char *host,
              char *server, char *realname, time_t ts, uint32 svid,
              uint32 ip, char *vhost, char *uid, int hopcount, char *modes)
*/
int denora_event_nick(char *source, int ac, char **av)
{
	User *user;
	char *ipchar = NULL;

	if (denora->protocoldebug)
	{
		protocol_debug(source, ac, av);
	}
	if (ac != 2)
	{
		ipchar = host_resolve(av[5]);
		user = do_nick(source, av[0], av[4], av[5], av[7], av[9],
		               strtoul(av[2], NULL, 10),
		               strtoul(av[8], NULL, 0), ipchar, av[6], NULL,
		               strtoul(av[1], NULL, 0), av[3], NULL);
		free(ipchar);
	}
	else
	{
		do_nick(source, av[0], NULL, NULL, NULL, NULL,
		        strtoul(av[1], NULL, 10), 0, NULL, NULL, NULL, 0, NULL,
		        NULL);
	}
	return MOD_CONT;
}
Example #3
0
int denora_event_nick(char *source, int ac, char **av)
{
    User *user;

    if (denora->protocoldebug) {
        protocol_debug(source, ac, av);
    }

    if (ac != 1) {
        if (ac == 8) {
            user = do_nick("", av[1],   /* nick */
                           av[4],       /* username */
                           av[2],       /* realhost */
                           source,      /* server */
                           av[7],       /* realname */
                           strtoul(av[0], NULL, 10),
                           0, inspircd_nickip(av[6]), av[3], NULL, 1,
                           av[5], NULL);
        }
    } else {
        do_nick(source, av[0], NULL, NULL, NULL, NULL,
                0, 0, NULL, NULL, NULL, 0, NULL, NULL);
    }

    return MOD_CONT;
}
Example #4
0
static void m_nick( char *origin, char **argv, int argc, int srv )
{
	if( !srv )
	{
		if( ircd_srv.protocol & PROTOCOL_NICKv2 )
		{
			if( ircd_srv.protocol & PROTOCOL_NICKIP )
			{
				char ip[25];

				ircsnprintf( ip, 25, "%d", ntohl( decode_ip( argv[9] ) ) );
				do_nick( argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], 
					ip, argv[6], argv[7], argv[8], argv[10], NULL, NULL );
			}
			else
			{
				do_nick( argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], 
					NULL, argv[6], argv[7], argv[8], argv[9], NULL, NULL );
			}
		}
		else
		{
			do_nick( argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], 
				NULL, argv[6], NULL, NULL, argv[9], NULL, NULL );
		}
	}
	else
	{
		do_nickchange( origin, argv[0], NULL );
	}
}
Example #5
0
/*
 do_nick(const char *source, char *nick, char *username, char *host,
              char *server, char *realname, time_t ts, uint32 svid,
              uint32 ip, char *vhost, char *uid, int hopcount, char *modes, char *account)
  NICK Trystan 1 1148214497 +aiow tslee is.my.vhost plexus3.nomadirc.net 0 c-67-186-230-12.hsd1.ut.comcast.net :Dreams are answers to questions not yet asked
       0       1 2           3    4     5           6                    7 8                                    9
  666 UID asdasd 1 1234817435 +ix Nesstest 566C206.B53EDE66.1DF57482.IP 66.63.160.250 666AAAAAD 0 66.63.160.250 :JasonX
          0      1 2           3  4        5                            6             7         8 9              10

[Feb 19 04:24:22.531142 2009] debug: Received: :57CAAEV6D NICK Miu :1235017456
[Feb 19 04:24:22.536789 2009] Source 57CAAEV6D
[Feb 19 04:24:22.537026 2009] av[0] = Miu
[Feb 19 04:24:22.537233 2009] av[1] = 1235017456
[Feb 19 04:24:22.537422 2009] Unknown NICK formatted message please report the following
*/
int denora_event_nick(char *source, int ac, char **av)
{
	Server *s;
	User *user;
	char *temp;
	char *ipchar = NULL;

	if (denora->protocoldebug)
	{
		protocol_debug(source, ac, av);
	}
	temp = sstrdup(source);

	if (UseTS6 && ac == 11)
	{
		s = server_find(source);
		/* Source is always the server */
		*source = '\0';
		user = do_nick(source, av[0], av[4], av[9], s->name, av[10],
		               strtoul(av[2], NULL, 10), 0, av[6], av[5],
		               av[7], strtoul(av[1], NULL, 10), av[3], NULL);
		if (user)
		{
			denora_set_umode(user, 1, &av[3]);
		}
	}
	else if (ac == 10)
	{
		ipchar = host_resolve(av[8]);
		user = do_nick(source, av[0], av[4], av[8], av[6], av[9],
		               strtoul(av[2], NULL, 10),
		               strtoul(av[7], NULL, 0), ipchar, av[5], NULL,
		               strtoul(av[1], NULL, 0), av[3], NULL);
		free(ipchar);
	}
	else if (ac == 2)
	{
		do_nick(source, av[0], NULL, NULL, NULL, NULL,
		        strtoul(av[1], NULL, 10), 0, NULL, NULL, NULL, 0,
		        NULL, NULL);
	}
	else
	{
		alog(LOG_DEBUG,
		     "Unknown NICK formatted message please report the following");
		protocol_debug(temp, ac, av);
	}
	free(temp);
	return MOD_CONT;
}
Example #6
0
int denora_event_svsnick(char *source, int ac, char **av)
{
    do_nick(av[0], av[1], NULL, NULL, NULL,
            NULL, strtoul(av[2], NULL, 10), 0, NULL, NULL, NULL, 0, NULL,
            NULL);
    return MOD_CONT;
}
Example #7
0
int xanadu_event_nick(char *source, int ac, char **av)
{
    User *user;

    if (ac != 2) {
        user = do_nick(source, av[0], av[4], av[5], av[6], av[9],
                       strtoul(av[2], NULL, 10), strtoul(av[7], NULL, 0),
                       strtoul(av[8], NULL, 0), "*", NULL);
        if (user) {
            xanadu_set_umode(user, 1, &av[3]);
        }
    } else {
        do_nick(source, av[0], NULL, NULL, NULL, NULL,
                strtoul(av[1], NULL, 10), 0, 0, NULL, NULL);
    }
    return MOD_CONT;
}
Example #8
0
static void m_nick( char *origin, char **argv, int argc, int srv )
{
	if( !srv )
		do_nick( argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], 
			NULL, NULL, NULL, NULL, argv[7], NULL, NULL );
	else
		do_nickchange( origin, argv[0], NULL );
}
Example #9
0
int denora_event_nick(char *source, int ac, char **av)
{
    User *user;
    char *ptr;
    char buf[BUFSIZE];
    char *ptr2 = buf;

    if (denora->protocoldebug)
        protocol_debug(source, ac, av);

    if (ac != 1) {
        if (ac == 8) {
            int svid = 0;
            int ts = strtoul(av[0], NULL, 10);
            if (strchr(av[5], 'r') != NULL)
                svid = ts;

            /* Here we should check if av[5] contains +o, and if so remove it,
             * as this will be handled by OPERTYPE */
            ptr = av[5];
            while (ptr && *ptr) {
                if (*ptr != 'o') {
                    /* not o, add it to the clean list */
                    *ptr2 = *ptr;
                    ptr2++;
                }
                /* increment original */
                ptr++;
            }
            *ptr2 = '\0';
            av[5] = (!strcmp(buf, "++")) ? NULL : buf;

            user = do_nick("", av[1],   /* nick */
                           av[4],       /* username */
                           av[2],       /* realhost */
                           source,      /* server */
                           av[7],       /* realname */
                           ts, svid, av[6], av[3], NULL, 1, av[5], NULL);
        }
    } else {
        do_nick(source, av[0], NULL, NULL, NULL, NULL,
                0, 0, NULL, NULL, NULL, 0, NULL, NULL);
    }

    return MOD_CONT;
}
Example #10
0
int denora_event_svsnick(char *source, int ac, char **av)
{
    if (denora->protocoldebug) {
        protocol_debug(source, ac, av);
    }
    do_nick(av[0], av[1], NULL, NULL, NULL, NULL,
            time(NULL), 0, NULL, NULL, NULL, 0, NULL, NULL);
    return MOD_CONT;
}
Example #11
0
int denora_event_nick(char *source, int ac, char **av)
{
    User *user;
    char *ipchar = NULL;

    if (denora->protocoldebug) {
        protocol_debug(source, ac, av);
    }

    if (ac != 2) {
        if (ac == 7) {
            /*
               <codemastr> that was a bug that is now fixed in 3.2.1
               <codemastr> in  some instances it would use the non-nickv2 format
               <codemastr> it's sent when a nick collision occurs
               - so we have to leave it around for now -TSL
             */
            ipchar = host_resolve(av[4]);
            do_nick(source, av[0], av[3], av[4], av[5], av[6],
                    strtoul(av[2], NULL, 10), 0, 0, NULL, NULL, 0, NULL,
                    NULL);
            free(ipchar);
        } else {
            ipchar = host_resolve(av[4]);
            user = do_nick(source, av[0], av[3], av[4], av[5], av[9],
                           strtoul(av[2], NULL, 10), strtoul(av[6], NULL,
                                                             0), 0, av[8],
                           NULL, strtoul(av[1], NULL, 10), av[7], NULL);
            free(ipchar);
        }
    } else {
        do_nick(source, av[0], NULL, NULL, NULL, NULL,
                strtoul(av[1], NULL, 10), 0, NULL, NULL, NULL, 0, NULL,
                NULL);
    }
    return MOD_CONT;
}
Example #12
0
static void m_nick( char *origin, char **argv, int argc, int srv )
{
	if( argc > 2 ) {
		char IPAddress[32];
		const char *modes;
		const char *modeptr;
		const char *account = NULL;
		const char *sethost = NULL;
		int param;

		modes = ( argv[5][0] == '+' ) ? argv[5]: NULL;
		if( modes ) {
			param = 6;
			for( modeptr = modes; *modeptr; ++modeptr ) {
				switch( *modeptr ) {
				case 'r':
					account = argv[param++];
					break;
				case 'h':
					sethost = argv[param++];
					break;
				default:
					break;
				} /* switch( *modeptr ) */
			} /* for( ) */
		} /* if( modes ) */

		ircsnprintf( IPAddress, 32, "%du", base64toIP( argv[argc-3]) );

		/*       nick,    hopcount, TS,     user,    host, */       
		do_nick( argv[0], argv[1], argv[2], argv[3], argv[4], 
			/* server, ip, servicestamp, modes, */
			base64_to_server( origin ), IPAddress, NULL, modes,
			/* vhost, realname, numeric, smodes */ 
			NULL, argv[argc-1], argv[argc-2], NULL );
	} else {
		do_nickchange( base64_to_nick( origin ), argv[0], argv[1] );
	}
}
Example #13
0
int denora_event_encap(char *source, int ac, char **av)
{
	char *newav[3];

	if (denora->protocoldebug)
	{
		protocol_debug(source, ac, av);
	}
	if (!stricmp(av[1], "CHGNAME"))
	{
		change_user_realname(av[2], av[3]);
	}
	if (!stricmp(av[1], "CHGHOST"))
	{
		change_user_host(av[2], av[3]);
	}
	if (!stricmp(av[1], "CHGIDENT"))
	{
		change_user_username(av[2], av[3]);
	}
	if (!stricmp(av[1], "XLINE"))
	{
		sql_do_xline(av[3], av[5]);
	}
	if (!stricmp(av[1], "SVSNICK"))
	{
		do_nick(av[2], av[3], NULL, NULL, NULL, NULL,
		        time(NULL), 0, NULL, NULL, NULL, 0, NULL, NULL);
	}
	if (!stricmp(av[1], "SVSMODE"))
	{
		newav[0] = av[2];
		newav[1] = av[4];
		newav[2] = av[3];
		denora_event_svsmode(source, 3, newav);
	}
	return MOD_CONT;
}
Example #14
0
int denora_event_sanick(char *source, int ac, char **av)
{
    do_nick(av[0], av[1], NULL, NULL, NULL,
            NULL, (int) time(NULL), 0, NULL, NULL, NULL, 0, NULL, NULL);
    return MOD_CONT;
}
Example #15
0
int denora_event_nick(char *source, int ac, char **av)
{
    User *user;
    Server *s;
    char *temp;
    char *ipchar;

    if (denora->protocoldebug)
        protocol_debug(source, ac, av);

    /* do_nick(const char *source, char *nick, char *username, char *host,
       char *server, char *realname, time_t ts, uint32 svid,
       uint32 ip, char *vhost, char *uid, int hopcount, char *modes) */

    temp = sstrdup(source);

    if (ac != 2) {
        char *realname, *ip, *nick;
        char *ident, *host, *modes, *modes2;
        const char *uid = "";
        const char *account = "";
        const char *timestamp = "";
        char hhostbuf[255];
        int ishidden = 0, isaccount = 0;

        s = server_find(source);
        *source = '\0';

        realname = sstrdup(av[ac - 1]);
        uid = sstrdup(av[ac - 2]);
        ip = sstrdup(av[ac - 3]);
        nick = sstrdup(av[0]);
        ident = sstrdup(av[3]);
        host = sstrdup(av[4]);
        modes = sstrdup(av[5]);
        modes2 = sstrdup(av[5]);
        timestamp = sstrdup(av[2]);

        if (strpbrk(av[5], "+")) {
            while (*modes) {
                switch (*modes) {
                case 'r':
                    isaccount = 1;
                    account = sstrdup(av[6]);
                    break;
                case 'x':
                    ishidden = 1;
                    break;
                default:
                    break;
                }
                modes++;
            }
            modes = sstrdup(modes2);
        } else
            modes = NULL;

        ipchar = asuka_nickip(ip);

        if (isaccount && ishidden) {
            ircsnprintf(hhostbuf, sizeof(av[6]) + sizeof(hhostbuf) + 2,
                        "%s%s%s", HiddenPrefix, av[6], HiddenSuffix);
        }

        user = do_nick(source, nick, ident, host, (s ? s->name : temp),
                       realname, strtoul(timestamp, NULL, 10), 0, ipchar,
                       (ishidden
                        && isaccount) ? hhostbuf : NULL, (char *) uid,
                       strtoul(av[1], NULL, 10), modes, (char *) account);

        free(ipchar);
    } else {
        user = find_byuid(source);
        do_nick((user ? user->nick : source), av[0], NULL, NULL, NULL,
                NULL, strtoul(av[1], NULL, 10), 0, NULL, NULL, NULL, 0,
                NULL, NULL);
    }
    free(temp);
    return MOD_CONT;
}
Example #16
0
int denora_event_nick(char *source, int ac, char **av)
{
    User *user;
    Server *s;
    char *temp;
    char *ipchar;

    if (denora->protocoldebug) {
        protocol_debug(source, ac, av);
    }

    temp = sstrdup(source);

    if (ac != 2) {
        char *realname, *ip, *nick;
        char *ident, *host, *modes, *modes2;
        const char *uid = "";
        const char *account = "";
        char *fakehost = NULL;
        char *sethost = NULL;
        char *hiddenhost = NULL;
        char *hiddenip = NULL;
        const char *timestamp = "";
        char hhostbuf[255] = "";
        int ishidden = 0, isaccount = 0;

        s = server_find(source);
        *source = '\0';

        realname = sstrdup(av[ac - 1]);
        uid = sstrdup(av[ac - 2]);
        ip = sstrdup(av[ac - 3]);
        nick = sstrdup(av[0]);
        ident = sstrdup(av[3]);
        host = sstrdup(av[4]);
        modes = sstrdup(av[5]);
        modes2 = sstrdup(av[5]);

        if (strpbrk(av[5], "+")) {
            int cnt = 6;
            int c = 1;
            char *uaccount = sstrdup("");
            char *acc = NULL;

            while (*modes) {
                switch (*modes) {
                case 'r':
                    isaccount = 1;
                    uaccount = av[cnt++];
                    for (acc = strtok(uaccount, ":");
                         acc; acc = strtok(NULL, ":")) {
                        if (c == 1)
                            account = sstrdup(acc);
                        else if (c == 2)
                            timestamp = sstrdup(acc);
                        c++;
                    }
                    c = 1;
                    break;
                case 'h':
                    sethost = sstrdup(av[cnt++]);
                    break;
                case 'f':
                    fakehost = sstrdup(av[cnt++]);
                    break;
                case 'c':
                    hiddenip = sstrdup(av[cnt++]);
                    break;
                case 'C':
                    hiddenhost = sstrdup(av[cnt++]);
                    break;
                case 'x':
                    ishidden = 1;
                    break;
                default:
                    break;
                }
                modes++;
            }
            modes = sstrdup(modes2);
        } else
            modes = NULL;

        /* do_nick(const char *source, char *nick, char *username, char *host,
           char *server, char *realname, time_t ts, uint32 svid,
           uint32 ip, char *vhost, char *uid, int hopcount, char *modes, char *account) */

        ipchar = nefarious_nickip(ip);

        if (ishidden) {
        	if (hiddenhost) {
        		ircsnprintf(hhostbuf, sizeof(hhostbuf) + 3, "%s", hiddenhost);
        	} else if (isaccount) {
                ircsnprintf(hhostbuf,
                            sizeof(account) + sizeof(hhostbuf) + 2,
                            "%s%s%s", HiddenPrefix, account, HiddenSuffix);
            }
        }

        user = do_nick(source, nick, ident, host, (s ? s->name : temp),
                       realname, strtoul(av[2], NULL, 10), 0, ipchar,
                       hhostbuf, (char *) uid, strtoul(av[1], NULL, 10),
                       modes, (char *) account);

        if (user) {
            if (fakehost || sethost) {
                const char *vhost = "";
                if (sethost) {
                    int h = 1;
                    char *uh = NULL;
                    const char *vident = "";
                    for (uh = strtok(sethost, "@");
                         uh; uh = strtok(NULL, "@")) {
                        if (h == 1)
                            vident = uh;
                        else if (h == 2)
                            vhost = uh;
                        h++;
                    }
                    h = 1;
                    change_user_username(user->nick, (char *) vident);
                }
                change_user_host(user->nick,
                                 sethost ? (char *) vhost : fakehost);
                /* set host as ip */
            }
        }
        free(ipchar);
    } else {
        /* Nick change */
        user = find_byuid(source);
        do_nick((user ? user->nick : source), av[0], NULL, NULL, NULL,
                NULL, strtoul(av[1], NULL, 10), 0, NULL, NULL, NULL, 0,
                NULL, NULL);
    }
    free(temp);
    return MOD_CONT;
}