X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/985d4109d818518b2230dc63736800e17d153e6c..ff5f1ab219f7f2daf7ceee8e9186219b24c0dc0d:/src/opserv.c diff --git a/src/opserv.c b/src/opserv.c index 3566c9a..cd0617f 100644 --- a/src/opserv.c +++ b/src/opserv.c @@ -25,6 +25,7 @@ #include "nickserv.h" #include "modcmd.h" #include "modules.h" +#include "proto.h" #include "opserv.h" #include "timeq.h" #include "saxdb.h" @@ -173,19 +174,30 @@ static const struct message_entry msgtab[] = { { "OSMSG_HOP_DONE", "Halfopped the requested lusers." }, { "OSMSG_HOPALL_DONE", "Halfopped everyone on $b%s$b." }, { "OSMSG_WHOIS_IDENT", "%s (%s@%s) from %d.%d.%d.%d" }, - { "OSMSG_WHOIS_NICK", "Nick : %s" }, - { "OSMSG_WHOIS_HOST", "Host : %s@%s" }, - { "OSMSG_WHOIS_FAKEHOST", "Fakehost : %s" }, - { "OSMSG_WHOIS_CRYPT_HOST", "Crypt Host : %s" }, - { "OSMSG_WHOIS_CRYPT_IP", "Crypt IP : %s" }, - { "OSMSG_WHOIS_IP", "Real IP : %s" }, - { "OSMSG_WHOIS_MODES", "Modes : +%s " }, - { "OSMSG_WHOIS_INFO", "Info : %s" }, - { "OSMSG_WHOIS_NUMERIC", "Numnick : %s" }, - { "OSMSG_WHOIS_SERVER", "Server : %s" }, - { "OSMSG_WHOIS_NICK_AGE", "Nick Age : %s" }, - { "OSMSG_WHOIS_ACCOUNT", "Account : %s" }, - { "OSMSG_WHOIS_CHANNELS", "Channels : %s" }, + { "OSMSG_WHOIS_NICK", "Nick : %s" }, + { "OSMSG_WHOIS_HOST", "Host : %s@%s" }, + { "OSMSG_WHOIS_FAKEHOST", "Fakehost : %s" }, + { "OSMSG_WHOIS_CRYPT_HOST", "Crypt Host : %s" }, + { "OSMSG_WHOIS_CRYPT_IP", "Crypt IP : %s" }, + { "OSMSG_WHOIS_IP", "Real IP : %s" }, + { "OSMSG_WHOIS_COUNTRY", "Country : %s" }, + { "OSMSG_WHOIS_COUNTRY_CODE","Country Code : %s" }, + { "OSMSG_WHOIS_CITY", "City : %s" }, + { "OSMSG_WHOIS_REGION", "Region/State : %s" }, + { "OSMSG_WHOIS_POSTAL_CODE","Postal Code : %s" }, + { "OSMSG_WHOIS_LATITUDE", "Latitude : %f" }, + { "OSMSG_WHOIS_LONGITUDE", "Longitude : %f" }, + { "OSMSG_WHOIS_MAP", "Map : %s" }, + { "OSMSG_WHOIS_DMA_CODE", "DMA Code : %d" }, + { "OSMSG_WHOIS_AREA_CODE", "Area Code : %d" }, + { "OSMSG_WHOIS_MODES", "Modes : +%s " }, + { "OSMSG_WHOIS_INFO", "Info : %s" }, + { "OSMSG_WHOIS_NUMERIC", "Numnick : %s" }, + { "OSMSG_WHOIS_SERVER", "Server : %s" }, + { "OSMSG_WHOIS_NICK_AGE", "Nick Age : %s" }, + { "OSMSG_WHOIS_ACCOUNT", "Account : %s" }, + { "OSMSG_WHOIS_PRIVS", "IRCd Privs : %s" }, + { "OSMSG_WHOIS_CHANNELS", "Channels : %s" }, { "OSMSG_WHOIS_HIDECHANS", "Channel list omitted for your sanity." }, { "OSMSG_UNBAN_DONE", "Ban(s) removed from channel %s." }, { "OSMSG_CHANNEL_VOICED", "All users on %s voiced." }, @@ -392,6 +404,9 @@ static const struct message_entry msgtab[] = { { "OSMSG_DEFCON_SHUN_NEW_CLIENTS", "Shunning New Clients" }, { "OSMSG_DEFCON_NO_NEW_MEMOS", "Disallowing New Memos" }, + { "OSMSG_PRIV_UNKNOWN", "Unknown privilege flag %s, see /msg $O HELP PRIVFLAGS for a flag list" }, + { "OSMSG_PRIV_SET", "Privilege flag %s has been %sset" }, + { NULL, NULL } }; @@ -724,6 +739,55 @@ static MODCMD_FUNC(cmd_defcon) return 1; } +/* TODO +static MODCMD_FUNC(cmd_privallow) +{ +//privallow servername/username +/-flag (global is set in conf) +} + +static MODCMD_FUNC(cmd_privdissallow) +{ +//privdisallow servername/username +/-flag (global is set in conf) +} + +static MODCMD_FUNC(cmd_privlist) +{ +//privlist servername/user (global with none) +} +*/ + +static MODCMD_FUNC(cmd_privset) +{ + struct userNode *target; + char *flag; + int add = PRIV_ADD; + + flag = argv[2]; + if (*flag == '-') { + add = PRIV_DEL; + flag++; + } else if (*flag == '+') { + add = PRIV_ADD; + flag++; + } + + target = GetUserH(argv[1]); + if (!target) { + reply("MSG_NICK_UNKNOWN", argv[1]); + return 0; + } + + if (check_priv(flag)) { + irc_privs(target, flag, add); + reply("OSMSG_PRIV_SET", argv[2], (add == 1) ? "" : "un"); + } else { + reply("OSMSG_PRIV_UNKNOWN", argv[2]); + return 0; + } + + return 1; +} + /* A lot of these commands are very similar to what ChanServ can do, * but OpServ can do them even on channels that aren't registered. */ @@ -867,9 +931,7 @@ static MODCMD_FUNC(cmd_warn) dict_insert(opserv_chan_warn, strdup(argv[1]), reason); reply("OSMSG_WARN_ADDED", argv[1], reason); if (dict_find(channels, argv[1], NULL)) { - message = alloca(strlen(reason) + strlen(argv[1]) + 55); - sprintf(message, "Channel activity warning for channel %s: %s", argv[1], reason); - global_message(MESSAGE_RECIPIENT_OPERS, message); + global_message_args(MESSAGE_RECIPIENT_OPERS, "OSMSG_CHANNEL_ACTIVITY_WARN" argv[1], reason); } return 1; } @@ -1758,6 +1820,32 @@ static MODCMD_FUNC(cmd_whois) reply("OSMSG_WHOIS_CRYPT_HOST", target->crypthost); reply("OSMSG_WHOIS_CRYPT_IP", target->cryptip); reply("OSMSG_WHOIS_IP", irc_ntoa(&target->ip)); + + if (target->city) { + reply("OSMSG_WHOIS_COUNTRY", target->country_name); + reply("OSMSG_WHOIS_COUNTRY_CODE", target->country_code); + reply("OSMSG_WHOIS_CITY", target->city); + reply("OSMSG_WHOIS_REGION", target->region); + + reply("OSMSG_WHOIS_POSTAL_CODE", target->postal_code); + reply("OSMSG_WHOIS_LATITUDE", target->latitude); + reply("OSMSG_WHOIS_LONGITUDE", target->longitude); + /* Only show a map url if we have a city, latitude and longitude. + * Theres not much point of latitude and longitude coordinates are + * returned but no city, the coordinates are useless. + */ + if (target->latitude && target->longitude && target->city) { + char map_url[MAXLEN]; + snprintf(map_url, sizeof(map_url), "http://www.mapquest.com/maps/map.adp?searchtype=address&formtype=address&latlongtype=decimal&latitude=%f&longitude=%f", + target->latitude, target->longitude); + reply("OSMSG_WHOIS_MAP", map_url); + } + reply("OSMSG_WHOIS_DMA_CODE", target->dma_code); + reply("OSMSG_WHOIS_AREA_CODE", target->area_code); + } else if (target->country_name) { + reply("OSMSG_WHOIS_COUNTRY", target->country_name); + } + if (target->modes) { bpos = 0; #define buffer_cat(str) (herelen = strlen(str), memcpy(buffer+bpos, str, herelen), bpos += herelen) @@ -1787,6 +1875,9 @@ static MODCMD_FUNC(cmd_whois) #endif reply("OSMSG_WHOIS_SERVER", target->uplink->name); reply("OSMSG_WHOIS_ACCOUNT", (target->handle_info ? target->handle_info->handle : "Not authenticated")); + + reply("OSMSG_WHOIS_PRIVS", client_report_privs(target)); + intervalString(buffer, now - target->timestamp, user->handle_info); reply("OSMSG_WHOIS_NICK_AGE", buffer); if (target->channels.used <= MAX_CHANNELS_WHOIS) @@ -2490,9 +2581,7 @@ opserv_channel_check(struct chanNode *newchan) } /* if ((warning = dict_find(opserv_chan_warn, newchan->name, NULL))) { - char message[MAXLEN]; - snprintf(message, sizeof(message), "Channel activity warning for channel %s: %s", newchan->name, warning); - global_message(MESSAGE_RECIPIENT_OPERS, message); + global_message_args(MESSAGE_RECIPIENT_OPERS, "OSMSG_CHANNEL_ACTIVITY_WARN", newchan->name, warning); } */ @@ -2976,6 +3065,10 @@ routing_connect_server(char *server, int port, struct server *to) wc->server = strdup(server); wc->target = strdup(to->name); + /* Just to make sure there isn't one left hanging + * if 2 connections are attempted at once.. + * */ + routing_delete_connect_timer(server); dict_insert(opserv_waiting_connections, strdup(server), wc); timeq_add(now + ROUTING_CONNECT_TIMEOUT, routing_connect_timeout, wc); @@ -6395,6 +6488,7 @@ init_opserv(const char *nick) opserv_define_func("HOP", cmd_hop, 100, 2, 2); opserv_define_func("HOPALL", cmd_hopall, 400, 2, 0); opserv_define_func("MAP", cmd_stats_links, 0, 0, 0); + opserv_define_func("PRIVSET", cmd_privset, 900, 0, 3); opserv_define_func("PART", cmd_part, 601, 0, 2); opserv_define_func("QUERY", cmd_query, 0, 0, 0); opserv_define_func("RAW", cmd_raw, 999, 0, 2);