X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/4b2dcc0db0eef47b66068352a43312948bba7595..ec8177c5c7b355a953871d6fded9ae77cf2a4a96:/src/proto-p10.c?ds=sidebyside diff --git a/src/proto-p10.c b/src/proto-p10.c index c77124e..3074fad 100644 --- a/src/proto-p10.c +++ b/src/proto-p10.c @@ -80,6 +80,7 @@ #define CMD_PROTO "PROTO" #define CMD_QUIT "QUIT" #define CMD_REHASH "REHASH" +#define CMD_REMOVE "REMOVE" #define CMD_RESET "RESET" #define CMD_RESTART "RESTART" #define CMD_RPING "RPING" @@ -121,6 +122,7 @@ #define CMD_WHO "WHO" #define CMD_WHOIS "WHOIS" #define CMD_WHOWAS "WHOWAS" +#define CMD_ZLINE "ZLINE" /* Tokenized commands. */ #define TOK_ACCOUNT "AC" @@ -177,6 +179,7 @@ #define TOK_PROTO "PROTO" #define TOK_QUIT "Q" #define TOK_REHASH "REHASH" +#define TOK_REMOVE "RM" #define TOK_RESET "RESET" #define TOK_RESTART "RESTART" #define TOK_RPING "RI" @@ -218,6 +221,7 @@ #define TOK_WHO "H" #define TOK_WHOIS "W" #define TOK_WHOWAS "X" +#define TOK_ZLINE "ZL" /* Protocol messages; aliased to full commands or tokens depending on compile-time configuration. ircu prefers tokens WITH THE @@ -283,6 +287,7 @@ #define P10_PROTO TYPE(PROTO) #define P10_QUIT TYPE(QUIT) #define P10_REHASH TYPE(REHASH) +#define P10_REMOVE TYPE(REMOVE) #define P10_RESET TYPE(RESET) #define P10_RESTART TYPE(RESTART) #define P10_RPING TYPE(RPING) @@ -323,6 +328,7 @@ #define P10_WHO TYPE(WHO) #define P10_WHOIS TYPE(WHOIS) #define P10_WHOWAS TYPE(WHOWAS) +#define P10_ZLINE TYPE(ZLINE) #define P10_EXEMPT TYPE(EXEMPT) /* Servers claiming to have a boot or link time before PREHISTORY @@ -343,6 +349,9 @@ static const char *his_servername; static const char *his_servercomment; static int extended_accounts; +/* These correspond to 1 << X: 012345678901234567 */ +const char irc_user_mode_chars[] = "o iw dkgn I"; + static struct userNode *AddUser(struct server* uplink, const char *nick, const char *ident, const char *hostname, const char *modes, const char *numeric, const char *userinfo, time_t timestamp, const char *realip); extern int off_channel; @@ -511,7 +520,7 @@ irc_p10_pton(irc_in_addr_t *ip, const char *input) do { if (*input == '_') { unsigned int left; - for (left = (25 - strlen(input)) / 3; left; left--) + for (left = (25 - strlen(input)) / 3 - pos; left; left--) ip->in6[pos++] = 0; input++; } else { @@ -578,41 +587,9 @@ irc_user(struct userNode *user) return; irc_p10_ntop(b64ip, &user->ip); if (user->modes) { - int modelen; char modes[32]; - modelen = 0; - if (IsOper(user)) - modes[modelen++] = 'o'; - if (IsInvisible(user)) - modes[modelen++] = 'i'; - if (IsWallOp(user)) - modes[modelen++] = 'w'; - if (IsService(user)) - modes[modelen++] = 'k'; - if (IsDeaf(user)) - modes[modelen++] = 'd'; - if (IsGlobal(user)) - modes[modelen++] = 'g'; - // sethost - reed/apples - // if (IsHelperIrcu(user)) - if (IsSetHost(user)) - modes[modelen++] = 'h'; - if (IsFakeHost(user)) - modes[modelen++] = 'f'; - if (IsHiddenHost(user)) - modes[modelen++] = 'x'; - if (IsBotM(user)) - modes[modelen++] = 'B'; - if (IsHideChans(user)) - modes[modelen++] = 'n'; - if (IsHideIdle(user)) - modes[modelen++] = 'I'; - if (IsXtraOp(user)) - modes[modelen++] = 'X'; - - modes[modelen] = 0; - + irc_user_modes(user, modes, sizeof(modes)); /* we don't need to put the + in modes because it's in the format string. */ putsock("%s " P10_NICK " %s %d " FMT_TIME_T " %s %s +%s %s %s :%s", user->uplink->numeric, user->nick, user->uplink->hops+1, user->timestamp, user->ident, user->hostname, modes, b64ip, user->numeric, user->info); @@ -1068,7 +1045,7 @@ irc_svspart(struct userNode *from, struct userNode *who, struct chanNode *to) } void -irc_svsquit(struct userNode *from, struct userNode *who, char *reason) +irc_svsquit(struct userNode *from, struct userNode *who, char const *reason) { putsock("%s " P10_SVSQUIT " %s :%s", from->uplink->numeric, who->numeric, reason); } @@ -1276,7 +1253,7 @@ static CMD_FUNC(cmd_whois) else irc_numeric(from, RPL_WHOISUSER, "%s %s %s * :%s", who->nick, who->ident, who->hostname, who->info); - if (IsService(who) || (from == who)) { + if (!IsService(who) || (from == who)) { struct modeNode *mn; mlen = strlen(self->name) + strlen(from->nick) + 12 + strlen(who->nick); len = 0; @@ -1395,7 +1372,6 @@ static CMD_FUNC(cmd_eob) { struct server *sender; dict_iterator_t it; - unsigned int ii; if (!(sender = GetServerH(origin))) return 0; @@ -1416,8 +1392,7 @@ static CMD_FUNC(cmd_eob) } sender->self_burst = 0; recalc_bursts(sender); - for (ii=0; iinumeric, server->numeric , argv[3], hi->registered); @@ -1624,7 +1599,21 @@ static CMD_FUNC(cmd_account) } else if(!strcmp(argv[2],"H")) /* New enhanced (host) version of C */ { - if((hi = loc_auth(argv[5], argv[6], argv[4] ))) + if((hi = loc_auth(NULL, argv[5], argv[6], argv[4] ))) + { + /* Return a AC A */ + putsock("%s " P10_ACCOUNT " %s A %s "FMT_TIME_T, self->numeric, server->numeric , argv[3], hi->registered); + } + else + { + /* Return a AC D */ + putsock("%s " P10_ACCOUNT " %s D %s", self->numeric, server->numeric , argv[3]); + } + return 1; + } + else if(!strcmp(argv[2],"S")) + { + if((hi = loc_auth(argv[5], argv[6], argv[7], argv[4]))) { /* Return a AC A */ putsock("%s " P10_ACCOUNT " %s A %s "FMT_TIME_T, self->numeric, server->numeric , argv[3], hi->registered); @@ -1739,6 +1728,12 @@ irc_privs(struct userNode *target, char *flag, int add) putsock("%s " P10_PRIVS " %s %s%s", self->numeric, target->numeric, (add == PRIV_ADD) ? "+" : "-", flag); } +void +irc_raw_privs(struct userNode *target, const char *privs) +{ + putsock("%s " P10_PRIVS " %s %s", self->numeric, target->numeric, privs); +} + static CMD_FUNC(cmd_privs) { char *tstr = NULL; @@ -1782,7 +1777,8 @@ static CMD_FUNC(cmd_privs) for (tmp = x3_strtok(&p, argv[i], ","); tmp; tmp = x3_strtok(&p, NULL, ",")) { if (!strcmp(tmp, "PRIV_NONE")) { - clear_privs(user); + if (now > user->timestamp+5) + clear_privs(user); break; } else client_modify_priv_by_name(user, tmp, what); @@ -1966,7 +1962,7 @@ static CMD_FUNC(cmd_mark) } else if(!strcasecmp(argv[2], "CVERSION")) { - /* DNSBL_DATA name */ + /* CTCP VERSION mark */ target = GetUserH(argv[1]); if(!target) { log_module(MAIN_LOG, LOG_ERROR, "Unable to find user %s whose version mark is changing.", argv[1]); @@ -1984,6 +1980,22 @@ static CMD_FUNC(cmd_mark) return 1; } + else if(!strcasecmp(argv[2], "SSLCLIFP")) { + /* SSL fingerprint mark */ + target = GetUserH(argv[1]); + if(!target) { + log_module(MAIN_LOG, LOG_ERROR, "Unable to find user %s whose SSL fingerprint mark is changing.", argv[1]); + return 0; + } + + char *sslfp = unsplit_string(argv + 3, argc - 3, NULL); + if(!sslfp) + sslfp = ""; + + target->sslfp = strdup(sslfp); + + return 1; + } /* unknown type of mark */ return 1; } @@ -2496,10 +2508,11 @@ free_user(struct userNode *user) } static void -parse_cleanup(void) +parse_cleanup(UNUSED_ARG(void *extra)) { unsigned int nn; free(of_list); + free(of_list_extra); free(privmsg_funcs); num_privmsg_funcs = 0; free(notice_funcs); @@ -2519,7 +2532,7 @@ p10_conf_reload(void) { } static void -remove_unbursted_channel(struct chanNode *cNode) { +remove_unbursted_channel(struct chanNode *cNode, UNUSED_ARG(void *extra)) { if (unbursted_channels) dict_remove(unbursted_channels, cNode->name); } @@ -2693,6 +2706,11 @@ init_parse(void) /* We have reliable clock! Always! Wraaa! */ dict_insert(irc_func_dict, CMD_SETTIME, cmd_dummy); dict_insert(irc_func_dict, TOK_SETTIME, cmd_dummy); + /* Ignore ZLINE/ZL/REMOVE/RM */ + dict_insert(irc_func_dict, CMD_ZLINE, cmd_dummy); + dict_insert(irc_func_dict, TOK_ZLINE, cmd_dummy); + dict_insert(irc_func_dict, CMD_REMOVE, cmd_dummy); + dict_insert(irc_func_dict, TOK_REMOVE, cmd_dummy); /* ignore /trace and /motd commands targetted at us */ dict_insert(irc_func_dict, TOK_TRACE, cmd_dummy); @@ -2731,8 +2749,8 @@ init_parse(void) memset(notice_funcs, 0, sizeof(privmsg_func_t)*num_notice_funcs); userList_init(&dead_users); - reg_del_channel_func(remove_unbursted_channel); - reg_exit_func(parse_cleanup); + reg_del_channel_func(remove_unbursted_channel, NULL); + reg_exit_func(parse_cleanup, NULL); // reg_notice_func(opserv, check_ctcp); } @@ -3008,7 +3026,7 @@ static struct userNode* AddUser(struct server* uplink, const char *nick, const char *ident, const char *hostname, const char *modes, const char *numeric, const char *userinfo, time_t timestamp, const char *realip) { struct userNode *oldUser, *uNode; - unsigned int n, ignore_user, dummy; + unsigned int ignore_user, dummy; char *tstr; int type; @@ -3070,7 +3088,7 @@ AddUser(struct server* uplink, const char *nick, const char *ident, const char * tstr = conf_get_data("server/type", RECDB_QSTRING); type = atoi(tstr); - if (type > 6) { + if (type == 7) { if (irc_in_addr_is_ipv4(uNode->ip)) { make_virtip((char*)irc_ntoa(&uNode->ip), (char*)irc_ntoa(&uNode->ip), uNode->cryptip); make_virthost((char*)irc_ntoa(&uNode->ip), uNode->hostname, uNode->crypthost); @@ -3106,8 +3124,7 @@ AddUser(struct server* uplink, const char *nick, const char *ident, const char * } if (IsLocal(uNode)) irc_user(uNode); - for (n=0; (ndead; n++) - nuf_list[n](uNode); + call_new_user_funcs(uNode); if ((uNode->loc == 1) && (uNode->handle_info)) send_func_list(uNode); @@ -3119,7 +3136,6 @@ AddUser(struct server* uplink, const char *nick, const char *ident, const char * void DelUser(struct userNode* user, struct userNode *killer, int announce, const char *why) { - unsigned int n; verify(user); @@ -3135,8 +3151,7 @@ DelUser(struct userNode* user, struct userNode *killer, int announce, const char /* Call these in reverse order so ChanServ can update presence information before NickServ nukes the handle_info. */ - for (n = duf_used; n > 0; ) - duf_list[--n](user, killer, why); + call_del_user_funcs(user, killer, why); user->uplink->clients--; user->uplink->users[user->num_local] = NULL; @@ -3172,6 +3187,12 @@ DelUser(struct userNode* user, struct userNode *killer, int announce, const char user->version_reply = NULL; } + /* Clean up SSL fingerprint data */ + if(user->sslfp) { + free(user->sslfp); + user->sslfp = NULL; + } + /* clean up mark */ if(user->mark) { free(user->mark);