/* 66AAA D AxC5i :defender.beirut.com!Defender (reason) */ int denora_event_kill(char *source, int ac, char **av) { User *u, *k; if (denora->protocoldebug) protocol_debug(source, ac, av); if (ac != 2) return MOD_CONT; u = find_byuid(source); k = find_byuid(av[0]); m_kill((u ? u->nick : source), (k ? k->nick : av[0]), av[1]); return MOD_CONT; }
/* ABAAA M #ircops +v ABAAB */ int denora_event_mode(char *source, int ac, char **av) { User *u; Server *s; char *sender; if (denora->protocoldebug) protocol_debug(source, ac, av); if (ac < 2) return MOD_CONT; u = find_byuid(source); if (!u) { sender = source; } else { sender = u->nick; } if (*av[0] == '#' || *av[0] == '&') { do_cmode(source, ac, av); } else { s = server_find(source); if (s) sender = av[0]; do_umode(sender, ac, av); } return MOD_CONT; }
/* ABAAB Q :Quit */ int denora_event_quit(char *source, int ac, char **av) { char *killer = NULL; char *msg = NULL; User *u; if (denora->protocoldebug) { protocol_debug(source, ac, av); } if (ac != 1) return MOD_CONT; if (asuka_parse_lkill(av[0]) == 0) { do_quit(source, ac, av); } else { killer = asuka_lkill_killer(av[0]); msg = asuka_lkill_msg(av[0]); u = find_byuid(source); if (killer) m_kill(killer, (u ? u->nick : source), msg); else m_kill((u ? u->nick : source), (u ? u->nick : source), msg); } return MOD_CONT; }
/* ABAAC AC ANAC] R :Trystan */ int denora_event_account(char *source, int ac, char **av) { Server *s; User *u; if (denora->protocoldebug) protocol_debug(source, ac, av); if ((ac < 2) || !source || !(s = server_find(source))) return MOD_CONT; u = find_byuid(av[0]); if (!u) return MOD_CONT; if (!strcmp(av[1], "R")) /* Set */ do_p10account(u, av[2], 0); else if (!strcmp(av[1], "M")) /* Rename */ do_p10account(u, av[2], 2); else if (!strcmp(av[1], "U")) /* Remove */ do_p10account(u, NULL, 1); else do_p10account(u, av[1], 0); /* For backward compatability */ return MOD_CONT; }
/* 97H KILL 69CAABOR8 :geo.rizon.net!geo.rizon.net!GeoServ!GeoServ (4 joins/parts in #DontJoinItsATrap within 6 seconds.) */ int denora_event_kill(char *source, int ac, char **av) { User *u = NULL; if (denora->protocoldebug) { protocol_debug(source, ac, av); } if (ac != 2) return MOD_CONT; u = find_byuid(av[0]); m_kill(source, u ? u->nick : av[0], av[1]); return MOD_CONT; }
/* ABAAB J #ircops 1098031328 */ int denora_event_join(char *source, int ac, char **av) { User *u; if (denora->protocoldebug) protocol_debug(source, ac, av); if (ac != 2) return MOD_CONT; u = find_byuid(source); do_join((u ? u->nick : source), ac, av); return MOD_CONT; }
/* ABAAA P ADAAB :help */ int denora_event_privmsg(char *source, int ac, char **av) { User *u; Uid *id; if (denora->protocoldebug) { protocol_debug(source, ac, av); } u = find_byuid(source); id = find_nickuid(av[0]); if (ac != 2 || *av[0] == '$' || strlen(source) == 2) return MOD_CONT; m_privmsg((u ? u->nick : source), (id ? id->nick : av[0]), av[1]); return MOD_CONT; }
/* ABAAA M #ircops +v ABAAB */ int denora_event_mode(char *source, int ac, char **av) { User *u; User *v; Server *s; char *sender; char hhostbuf[255]; if (denora->protocoldebug) protocol_debug(source, ac, av); if (ac < 2) return MOD_CONT; u = find_byuid(source); if (!u) { sender = source; } else { sender = u->nick; } if (*av[0] == '#' || *av[0] == '&') { do_cmode(source, ac, av); } else { s = server_find(source); if (s) sender = av[0]; do_umode(sender, ac, av); if (strcmp(av[1], "x") != -1) { v = user_find(av[0]); if (v->account) { ircsnprintf(hhostbuf, sizeof(v->account) + sizeof(hhostbuf) + 2, "%s%s%s", HiddenPrefix, v->account, HiddenSuffix); change_user_host(v->nick, hhostbuf); } } } return MOD_CONT; }
int do_on_join(int argc, char **argv) { User *u; Channel *c = NULL; int status; char *tmp; if (!AutoOwner) return MOD_CONT; if (argc != 3) return MOD_CONT; if (stricmp(argv[0], EVENT_STOP)) return MOD_CONT; if (UseTS6 && ircd->ts6) { u = find_byuid(argv[1]); if (!u) u = finduser(argv[1]); } else u = finduser(argv[1]); c = findchan(argv[2]); if (!c || !c->ci) return MOD_CONT; /* chan not registered */ if (!u || !nick_identified(u)) return MOD_CONT; /* user not found/identified */ status = chan_get_user_status(c, u); if ((get_access_level(c->ci, u->na) >= AutoOwnerLevel) && (!is_founder(u,c->ci))) { if (!(status & CUS_OWNER)) { tmp = stripModePrefix(ircd->ownerset); xanadu_cmd_mode(whosends(c->ci), c->name, "+%s %s", tmp, u->nick); if (tmp) free(tmp); chan_set_user_status(c, u, CUS_OWNER); } } return MOD_CONT; }
int denora_event_privmsg(char *source, int ac, char **av) { User *u = NULL; Uid *ud = NULL; if (denora->protocoldebug) { protocol_debug(source, ac, av); } if (ac != 2) { return MOD_CONT; } if (UseTS6) { u = find_byuid(source); ud = find_nickuid(av[0]); } m_privmsg((UseTS6 ? (u ? u->nick : source) : source), (UseTS6 ? (ud ? ud->nick : av[0]) : av[0]), av[1]); return MOD_CONT; }
/** * Adds a new user to anopes internal userlist. * * If the SVID passed is 2, the user will not be marked registered or requested to ID. * This is an addition to accomodate IRCds where we cannot determine this based on the NICK * or UID command. Some IRCd's keep +r on when changing nicks and do not use SVID (ex. InspIRCd 1.2). * Instead we get a METADATA command containing the accountname the user was last identified to. * Since this is received after the user is introduced to us we should not yet mark the user * as identified or ask him to identify. We will mark him as recognized for the time being and let * him keep his +r if he has it. * It is the responsibility of the protocol module to make sure that this is either invalidated, * or changed to identified. ~ Viper **/ User *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) { User *user = NULL; char *tmp = NULL; NickAlias *old_na; /* Old nick rec */ int nc_changed = 1; /* Did nick core change? */ int status = 0; /* Status to apply */ char mask[USERMAX + HOSTMAX + 2]; char *logrealname; char *oldnick; if (!*source) { char ipbuf[16]; struct in_addr addr; if (ircd->nickvhost) { if (vhost) { if (!strcmp(vhost, "*")) { vhost = NULL; if (debug) alog("debug: new user�with no vhost in NICK command: %s", nick); } } } /* This is a new user; create a User structure for it. */ if (debug) alog("debug: new user: %s", nick); if (ircd->nickip) { addr.s_addr = htonl(ip); ntoa(addr, ipbuf, sizeof(ipbuf)); } if (LogUsers) { /** * Ugly swap routine for Flop's bug :) **/ if (realname) { tmp = strchr(realname, '%'); while (tmp) { *tmp = '-'; tmp = strchr(realname, '%'); } } logrealname = normalizeBuffer(realname); /** * End of ugly swap **/ if (ircd->nickvhost) { if (ircd->nickip) { alog("LOGUSERS: %s (%s@%s => %s) (%s) [%s] connected to the network (%s).", nick, username, host, (vhost ? vhost : "none"), logrealname, ipbuf, server); } else { alog("LOGUSERS: %s (%s@%s => %s) (%s) connected to the network (%s).", nick, username, host, (vhost ? vhost : "none"), logrealname, server); } } else { if (ircd->nickip) { alog("LOGUSERS: %s (%s@%s) (%s) [%s] connected to the network (%s).", nick, username, host, logrealname, ipbuf, server); } else { alog("LOGUSERS: %s (%s@%s) (%s) connected to the network (%s).", nick, username, host, logrealname, server); } } Anope_Free(logrealname); } /* We used to ignore the ~ which a lot of ircd's use to indicate no * identd response. That caused channel bans to break, so now we * just take what the server gives us. People are still encouraged * to read the RFCs and stop doing anything to usernames depending * on the result of an identd lookup. */ /* First check for AKILLs. */ /* DONT just return null if its an akill match anymore - yes its more efficent to, however, now that ircd's are * starting to use things like E/F lines, we cant be 100% sure the client will be removed from the network :/ * as such, create a user_struct, and if the client is removed, we'll delete it again when the QUIT notice * comes in from the ircd. **/ if (check_akill(nick, username, host, vhost, ipbuf)) { /* return NULL; */ } /** * DefCon AKILL system, if we want to akill all connecting user's here's where to do it * then force check_akill again on them... **/ /* don't akill on netmerges -Certus */ /* don't akill clients introduced by ulines. -Viper */ if (is_sync(findserver(servlist, server)) && checkDefCon(DEFCON_AKILL_NEW_CLIENTS) && !is_ulined(server)) { strncpy(mask, "*@", 3); strncat(mask, host, HOSTMAX); alog("DEFCON: adding akill for %s", mask); add_akill(NULL, mask, s_OperServ, time(NULL) + dotime(DefConAKILL), DefConAkillReason ? DefConAkillReason : "DEFCON AKILL"); if (check_akill(nick, username, host, vhost, ipbuf)) { /* return NULL; */ } } /* SGLINE */ if (ircd->sgline) { if (check_sgline(nick, realname)) return NULL; } /* SQLINE */ if (ircd->sqline) { if (check_sqline(nick, 0)) return NULL; } /* SZLINE */ if (ircd->szline && ircd->nickip) { if (check_szline(nick, ipbuf)) return NULL; } /* Now check for session limits */ if (LimitSessions && !is_ulined(server) && !add_session(nick, host, ipbuf)) return NULL; /* Allocate User structure and fill it in. */ user = new_user(nick); user->username = sstrdup(username); user->host = sstrdup(host); user->server = findserver(servlist, server); user->realname = sstrdup(realname); user->timestamp = ts; user->my_signon = time(NULL); user->chost = vhost ? sstrdup(vhost) : sstrdup(host); user->vhost = vhost ? sstrdup(vhost) : sstrdup(host); if (uid) { user->uid = sstrdup(uid); /* p10/ts6 stuff */ } else { user->uid = NULL; } user->vident = sstrdup(username); /* We now store the user's ip in the user_ struct, * because we will use it in serveral places -- DrStein */ if (ircd->nickip) { user->hostip = sstrdup(ipbuf); } else { user->hostip = NULL; } if (svid == 0) { display_news(user, NEWS_LOGON); display_news(user, NEWS_RANDOM); } if (svid == 2 && user->na) { /* We do not yet know if the user should be identified or not. * mark him as recognized for now. * It s up to the protocol module to make sure this either becomes ID'd or * is invalidated. ~ Viper */ if (debug) alog("debug: Marking %s as recognized..", user->nick); user->svid = 1; user->na->status |= NS_RECOGNIZED; nc_changed = 0; } else if (svid == ts && user->na) { /* Timestamp and svid match, and nick is registered; automagically identify the nick */ user->svid = svid; user->na->status |= NS_IDENTIFIED; check_memos(user); nc_changed = 0; /* Start nick tracking if available */ if (NSNickTracking) nsStartNickTracking(user); } else if (svid != 1) { /* Resets the svid because it doesn't match */ user->svid = 1; anope_cmd_svid_umode(user->nick, user->timestamp); } else { user->svid = 1; } send_event(EVENT_NEWNICK, 1, nick); } else { /* An old user changing nicks. */ if (UseTS6 && ircd->ts6) user = find_byuid(source); if (!user) user = finduser(source); if (!user) { alog("user: NICK from nonexistent nick %s", source); return NULL; } user->isSuperAdmin = 0; /* Dont let people nick change and stay SuperAdmins */ if (debug) alog("debug: %s changes nick to %s", source, nick); if (LogUsers) { logrealname = normalizeBuffer(user->realname); if (ircd->vhost) { alog("LOGUSERS: %s (%s@%s => %s) (%s) changed nick to %s (%s).", user->nick, user->username, user->host, (user->vhost ? user->vhost : "(none)"), logrealname, nick, user->server->name); } else { alog("LOGUSERS: %s (%s@%s) (%s) changed nick to %s (%s).", user->nick, user->username, user->host, logrealname, nick, user->server->name); } if (logrealname) { free(logrealname); } } user->timestamp = ts; if (stricmp(nick, user->nick) == 0) { /* No need to redo things */ change_user_nick(user, nick); nc_changed = 0; } else { /* Update this only if nicks aren't the same */ user->my_signon = time(NULL); old_na = user->na; if (old_na) { if (nick_recognized(user)) user->na->last_seen = time(NULL); status = old_na->status & NS_TRANSGROUP; cancel_user(user); } oldnick = sstrdup(user->nick); change_user_nick(user, nick); if ((old_na ? old_na->nc : NULL) == (user->na ? user->na->nc : NULL)) nc_changed = 0; if (!nc_changed && (user->na)) user->na->status |= status; else { anope_cmd_nc_change(user); } send_event(EVENT_CHANGE_NICK, 2, nick, oldnick); free(oldnick); } if (ircd->sqline) { if (!is_oper(user) && check_sqline(user->nick, 1)) return NULL; } } /* if (!*source) */ /* Check for nick tracking to bypass identification */ if (NSNickTracking && nsCheckNickTracking(user)) { user->na->status |= NS_IDENTIFIED; nc_changed = 0; } if (nc_changed || !nick_recognized(user)) { if (validate_user(user)) check_memos(user); } else { if (nick_identified(user)) { char tsbuf[16]; user->na->last_seen = time(NULL); if (user->na->last_usermask) free(user->na->last_usermask); user->na->last_usermask = smalloc(strlen(common_get_vident(user)) + strlen(common_get_vhost(user)) + 2); sprintf(user->na->last_usermask, "%s@%s", common_get_vident(user), common_get_vhost(user)); snprintf(tsbuf, sizeof(tsbuf), "%lu", (unsigned long int) user->timestamp); anope_cmd_svid_umode2(user, tsbuf); alog("%s: %s!%s@%s automatically identified for nick %s", s_NickServ, user->nick, user->username, user->host, user->nick); } } /* Bahamut sets -r on every nick changes, so we must test it even if nc_changed == 0 */ if (ircd->check_nick_id) { if (nick_identified(user)) { char tsbuf[16]; snprintf(tsbuf, sizeof(tsbuf), "%lu", (unsigned long int) user->timestamp); anope_cmd_svid_umode3(user, tsbuf); } } return user; }
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; }
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; }