]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/opserv.c
an initial fix to the vsend error, now we just need to do the reg_auth_func bits...
[irc/evilnet/x3.git] / src / opserv.c
index c74b3c4b9a49ce60a9d7513b069b506cc22f49b0..626afda39c3a5d32458eee19ce22750579ac16eb 100644 (file)
@@ -76,6 +76,7 @@
 #define KEY_BLOCK_GLINE_DURATION "block_gline_duration"
 #define KEY_ISSUER "issuer"
 #define KEY_ISSUED "issued"
+#define KEY_ADMIN_LEVEL "admin_level"
 
 #define IDENT_FORMAT           "%s [%s@%s/%s]"
 #define IDENT_DATA(user)       user->nick, user->ident, user->hostname, inet_ntoa(user->ip)
@@ -203,7 +204,8 @@ static const struct message_entry msgtab[] = {
     { "OSMSG_USER_SEARCH_RESULTS", "The following users were found:" },
     { "OSMSG_USER_SEARCH_HEADER", "Nick                  User@Host   (Account)" },
     { "OSMSG_USER_SEARCH_BAR",    "-------------------------------------------" },
-    { "OSMSG_USER_SEARCH_COUNT",  "------------ Found %4u matches -----------" },
+    { "OSMSG_USER_SEARCH_COUNT",  "There were %4u matches" },
+    { "OSMSG_USER_SEARCH_COUNT_BAR",  "------------ Found %4u matches -----------" },
     { "OSMSG_CHANNEL_SEARCH_RESULTS", "The following channels were found:" },
     { "OSMSG_GLINE_SEARCH_RESULTS", "The following glines were found:" },
     { "OSMSG_LOG_SEARCH_RESULTS", "The following log entries were found:" },
@@ -238,6 +240,7 @@ static const struct message_entry msgtab[] = {
     { "OSMSG_SERVER_JUPED", "Added new jupe server %s." },
     { "OSMSG_SERVER_NOT_JUPE", "That server is not a juped server." },
     { "OSMSG_SERVER_UNJUPED", "Server jupe removed." },
+    /*
     { "OSMSG_WARN_ADDED", "Added channel activity warning for $b%s$b (%s)" },
     { "OSMSG_WARN_EXISTS", "Channel activity warning for $b%s$b already exists." },
     { "OSMSG_WARN_DELETED", "Removed channel activity warning for $b%s$b" },
@@ -245,6 +248,7 @@ static const struct message_entry msgtab[] = {
     { "OSMSG_WARN_LISTSTART", "Channel activity warnings:" },
     { "OSMSG_WARN_LISTENTRY", "%s (%s)" },
     { "OSMSG_WARN_LISTEND", "End of activity warning list." },
+    */
     { "OSMSG_UPLINK_CONNECTING", "Establishing connection with %s (%s:%d)." },
     { "OSMSG_CURRENT_UPLINK", "$b%s$b is already the current uplink." },
     { "OSMSG_INVALID_UPLINK", "$b%s$b is not a valid uplink name." },
@@ -269,7 +273,7 @@ static const struct message_entry msgtab[] = {
     { NULL, NULL }
 };
 
-#define OPSERV_SYNTAX() svccmd_send_help(user, opserv, cmd)
+#define OPSERV_SYNTAX() svccmd_send_help_brief(user, opserv, cmd)
 
 typedef int (*discrim_search_func)(struct userNode *match, void *extra);
 
@@ -301,6 +305,7 @@ static struct {
     unsigned long purge_lock_delay;
     unsigned long join_flood_moderate;
     unsigned long join_flood_moderate_threshold;
+    unsigned long admin_level;
 } opserv_conf;
 
 struct trusted_host {
@@ -1954,9 +1959,10 @@ int
 opserv_bad_channel(const char *name)
 {
     unsigned int found;
+    int present;
 
-    dict_find(opserv_exempt_channels, name, &found);
-    if (found)
+    dict_find(opserv_exempt_channels, name, &present);
+    if (present)
         return 0;
 
     if (gline_find(name))
@@ -1992,26 +1998,26 @@ opserv_shutdown_channel(struct chanNode *channel, const char *reason)
     timeq_add(now + opserv_conf.purge_lock_delay, opserv_part_channel, channel);
 }
 
-/*
 static void
 opserv_channel_check(struct chanNode *newchan)
 {
-    char *warning;
+    /*char *warning; */
 
     if (!newchan->join_policer.params) {
         newchan->join_policer.last_req = now;
         newchan->join_policer.params = opserv_conf.join_policer_params;
     }
+    /*
     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);
     }
+    */
 
-    * Wait until the join check to shut channels down. *
+    /* Wait until the join check to shut channels down. */
     newchan->bad_channel = opserv_bad_channel(newchan->name);
 }
-*/
 
 static void
 opserv_channel_delete(struct chanNode *chan)
@@ -2735,9 +2741,14 @@ opserv_add_user_alert(struct userNode *req, const char *name, opserv_alert_react
         alert->discrim->reason = strdup(name);
     alert->reaction = reaction;
     dict_insert(opserv_user_alerts, name_dup, alert);
-    if (alert->discrim->channel)
+    /* Stick the alert into the appropriate additional alert dict(s).
+     * For channel alerts, we only use channels and min_channels;
+     * max_channels would have to be checked on /part, which we do not
+     * yet do, and which seems of questionable value.
+     */
+    if (alert->discrim->channel || alert->discrim->min_channels)
         dict_insert(opserv_channel_alerts, name_dup, alert);
-    else if (alert->discrim->mask_nick)
+    if (alert->discrim->mask_nick)
         dict_insert(opserv_nick_based_alerts, name_dup, alert);
     return alert;
 }
@@ -3566,7 +3577,7 @@ static MODCMD_FUNC(cmd_trace)
 
     if (action == trace_print_func)
     {
-       reply("OSMSG_USER_SEARCH_RESULTS");
+        reply("OSMSG_USER_SEARCH_RESULTS");
         reply("OSMSG_USER_SEARCH_BAR");
         reply("OSMSG_USER_SEARCH_HEADER");
         reply("OSMSG_USER_SEARCH_BAR");
@@ -3588,9 +3599,14 @@ static MODCMD_FUNC(cmd_trace)
         dict_foreach(das.dict, opserv_show_hostinfo, &das);
 
     if (matches)
-       reply("OSMSG_USER_SEARCH_COUNT", matches);
+    {
+        if(action == trace_print_func)
+           reply("OSMSG_USER_SEARCH_COUNT_BAR", matches);
+        else
+            reply("OSMSG_USER_SEARCH_COUNT", matches);
+    }
     else
-       reply("MSG_NO_MATCHES");
+           reply("MSG_NO_MATCHES");
 
     if (das.discrim->channel)
         UnlockChannel(das.discrim->channel);
@@ -4141,6 +4157,10 @@ opserv_conf_read(void)
     } else {
         opserv_conf.staff_auth_channel = NULL;
     }
+
+    str = database_get_data(conf_node, KEY_ADMIN_LEVEL, RECDB_QSTRING);
+    opserv_conf.admin_level = str ? strtoul(str, NULL, 0): 800;
+
     str = database_get_data(conf_node, KEY_UNTRUSTED_MAX, RECDB_QSTRING);
     opserv_conf.untrusted_max = str ? strtoul(str, NULL, 0) : 5;
     str = database_get_data(conf_node, KEY_PURGE_LOCK_DELAY, RECDB_QSTRING);
@@ -4179,6 +4199,13 @@ opserv_conf_read(void)
        dict_foreach(child, set_policer_param, pp);
 }
 
+/* lame way to export opserv_conf value to nickserv.c ... */
+unsigned int 
+opserv_conf_admin_level()
+{
+    return(opserv_conf.admin_level);
+}
+
 static void
 opserv_db_init(void) {
     /* set up opserv_trusted_hosts dict */
@@ -4351,7 +4378,7 @@ init_opserv(const char *nick)
     reg_new_user_func(opserv_new_user_check);
     reg_nick_change_func(opserv_alert_check_nick);
     reg_del_user_func(opserv_user_cleanup);
-/*    reg_new_channel_func(opserv_channel_check); */
+    reg_new_channel_func(opserv_channel_check); 
     reg_del_channel_func(opserv_channel_delete);
     reg_join_func(opserv_join_check);
     reg_auth_func(opserv_staff_alert);