X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/5177fd2177fcd1ea3ddd3b977c917abf4bbeea5e..f0b5157b276881c2e9aed38f2c9e88df2d054011:/src/proto-p10.c diff --git a/src/proto-p10.c b/src/proto-p10.c index 119f487..ac5ff46 100644 --- a/src/proto-p10.c +++ b/src/proto-p10.c @@ -20,6 +20,7 @@ #include "nickserv.h" #include "chanserv.h" +#include "hosthiding.h" #include "proto-common.c" /* Full commands. */ @@ -90,6 +91,7 @@ #define CMD_SQUIT "SQUIT" #define CMD_STATS "STATS" #define CMD_SVSNICK "SVSNICK" +#define CMD_SWHOIS "SWHOIS" #define CMD_TIME "TIME" #define CMD_TOPIC "TOPIC" #define CMD_TRACE "TRACE" @@ -177,6 +179,7 @@ #define TOK_SQUIT "SQ" #define TOK_STATS "R" #define TOK_SVSNICK "SN" +#define TOK_SWHOIS "SW" #define TOK_TIME "TI" #define TOK_TOPIC "T" #define TOK_TRACE "TR" @@ -274,6 +277,7 @@ #define P10_SQUIT TYPE(SQUIT) #define P10_STATS TYPE(STATS) #define P10_SVSNICK TYPE(SVSNICK) +#define P10_SWHOIS TYPE(SWHOIS) #define P10_TIME TYPE(TIME) #define P10_TOPIC TYPE(TOPIC) #define P10_TRACE TYPE(TRACE) @@ -860,7 +864,7 @@ irc_invite(struct userNode *from, struct userNode *who, struct chanNode *to) void irc_silence(struct userNode *who, const char *mask, int add) { - putsock("%s " P10_SILENCE " %s %s%s", self->numeric, who->numeric, add ? "" : "-", mask); + putsock("%s " P10_SILENCE " %s %s%s", self->numeric, who->numeric, add ? "+" : "-", mask); } void @@ -896,6 +900,14 @@ irc_svsnick(struct userNode *from, struct userNode *target, const char *newnick) putsock("%s " P10_SVSNICK " %s %s "FMT_TIME_T, from->uplink->numeric, target->numeric, newnick, now); } +void +irc_swhois(struct userNode *from, struct userNode *target, const char *message) +{ + putsock("%s " P10_SWHOIS " %s %s%s", from->uplink->numeric, target->numeric, message ? ":" : "", + message ? message : ""); + +} + void irc_part(struct userNode *who, struct chanNode *what, const char *reason) { @@ -913,12 +925,15 @@ irc_topic(struct userNode *service, struct userNode *who, struct chanNode *what, int type = 4; const char *str; str = conf_get_data("server/type", RECDB_QSTRING); - type = atoi(str); + if(str) + type = atoi(str); + else + type = 4;/* default to 040 style topics */ if (type == 5) { putsock("%s " P10_TOPIC " %s %s " FMT_TIME_T " " FMT_TIME_T " :%s", service->numeric, what->name, who->nick, what->timestamp, now, topic); } else { - who = service; /* REMOVE LINE FOR NEFARIOUS 0.5.0 */ + who = service; putsock("%s " P10_TOPIC " %s :%s", who->numeric, what->name, topic); } } @@ -1617,6 +1632,50 @@ static CMD_FUNC(cmd_part) return 1; } +static CMD_FUNC(cmd_silence) +{ + struct userNode *user; + char *mask; + char *new_mask; + unsigned int i; + + if (argc < 2) + return 0; + + user = GetUserN(argv[1]); + + /* Sanity, go nuts if this happens */ + if (!user) + return 0; + + /* We can safely ignore this if a user adding a silence is not + * ignored. However this brings up a TODO. If a user logs in and + * they have silences on the IRCd then we need to set them here + * somehow + */ + if (!user->handle_info) + return 1; + + mask = strdup(argv[2]); + + if (*mask == '-') { + for (i=0; ihandle_info->ignores->used; i++) { + if (!irccasecmp(mask+1, user->handle_info->ignores->list[i])) + user->handle_info->ignores->list[i] = user->handle_info->ignores->list[--user->handle_info->ignores->used]; + } + } else { + for (i=0; ihandle_info->ignores->used; i++) { + if (!strcmp(mask+1, user->handle_info->ignores->list[i])) + return 1; /* Already on the users NickServ ignore list, safely ignore */ + } + + new_mask = strdup(mask+1); + string_list_append(user->handle_info->ignores, mask+1); + } + free(mask); + return 1; +} + static CMD_FUNC(cmd_kick) { if (argc < 3) @@ -1851,8 +1910,8 @@ init_parse(void) dict_insert(irc_func_dict, TOK_TOPIC, cmd_topic); dict_insert(irc_func_dict, CMD_AWAY, cmd_away); dict_insert(irc_func_dict, TOK_AWAY, cmd_away); - dict_insert(irc_func_dict, CMD_SILENCE, cmd_dummy); - dict_insert(irc_func_dict, TOK_SILENCE, cmd_dummy); + dict_insert(irc_func_dict, CMD_SILENCE, cmd_silence); + dict_insert(irc_func_dict, TOK_SILENCE, cmd_silence); dict_insert(irc_func_dict, CMD_KICK, cmd_kick); dict_insert(irc_func_dict, TOK_KICK, cmd_kick); dict_insert(irc_func_dict, CMD_SQUIT, cmd_squit); @@ -1865,6 +1924,8 @@ init_parse(void) dict_insert(irc_func_dict, TOK_STATS, cmd_stats); dict_insert(irc_func_dict, CMD_SVSNICK, cmd_svsnick); dict_insert(irc_func_dict, TOK_SVSNICK, cmd_svsnick); + dict_insert(irc_func_dict, CMD_SWHOIS, cmd_dummy); + dict_insert(irc_func_dict, TOK_SWHOIS, cmd_dummy); dict_insert(irc_func_dict, CMD_WHOIS, cmd_whois); dict_insert(irc_func_dict, TOK_WHOIS, cmd_whois); dict_insert(irc_func_dict, CMD_GLINE, cmd_gline); @@ -2273,6 +2334,14 @@ AddUser(struct server* uplink, const char *nick, const char *ident, const char * safestrncpy(uNode->hostname, hostname, sizeof(uNode->hostname)); safestrncpy(uNode->numeric, numeric, sizeof(uNode->numeric)); irc_p10_pton(&uNode->ip, realip); + + 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); + } else if (irc_in_addr_is_ipv6(uNode->ip)) { + make_ipv6virthost((char*)irc_ntoa(&uNode->ip), uNode->hostname, uNode->crypthost); + } + uNode->timestamp = timestamp; modeList_init(&uNode->channels); uNode->uplink = uplink;