Support G-line lifetimes.
[srvx.git] / src / opserv.c
index 7457336a78cb30295f01d605e573405c1662f403..4bc6be2791ba476c1bc0991a0d0b81460598e2ee 100644 (file)
@@ -201,7 +201,7 @@ static const struct message_entry msgtab[] = {
     { "OSMSG_GLINE_SEARCH_RESULTS", "The following glines were found:" },
     { "OSMSG_LOG_SEARCH_RESULTS", "The following log entries were found:" },
     { "OSMSG_GSYNC_RUNNING", "Synchronizing glines from %s." },
-    { "OSMSG_GTRACE_FORMAT", "%s (issued %s by %s, lastmod %s, expires %s): %s" },
+    { "OSMSG_GTRACE_FORMAT", "%1$s (issued %2$s ago by %3$s, lastmod %4$s ago, expires %5$s, lifetime %7$s): %6$s" },
     { "OSMSG_GAG_APPLIED", "Gagged $b%s$b, affecting %d users." },
     { "OSMSG_GAG_ADDED", "Gagged $b%s$b." },
     { "OSMSG_REDUNDANT_GAG", "Gag $b%s$b is redundant." },
@@ -490,7 +490,9 @@ static MODCMD_FUNC(cmd_chaninfo)
     qsort(members, channel->members.used, sizeof(members[0]), modeNode_sort);
 
     /* Display the array. */
-    show_oplevels = (members[0]->modes & MODE_CHANOP) && (members[0]->oplevel < MAXOPLEVEL);
+    show_oplevels = (channel->members.used != 0)
+        && (members[0]->modes & MODE_CHANOP)
+        && (members[0]->oplevel < MAXOPLEVEL);
     for (n=0; n<channel->members.used; n++) {
         moden = members[n];
         if (moden->modes & MODE_CHANOP) {
@@ -787,7 +789,7 @@ opserv_block(struct userNode *target, char *src_handle, char *reason, unsigned l
                  "G-line requested by %s.", src_handle);
     if (!duration)
         duration = opserv_conf.block_gline_duration;
-    return gline_add(src_handle, mask, duration, reason, now, now, 1);
+    return gline_add(src_handle, mask, duration, reason, now, now, 0, 1);
 }
 
 static MODCMD_FUNC(cmd_block)
@@ -861,7 +863,7 @@ static MODCMD_FUNC(cmd_gline)
         reply("MSG_INVALID_DURATION", argv[2]);
         return 0;
     }
-    gline = gline_add(user->handle_info->handle, argv[1], duration, reason, now, now, 1);
+    gline = gline_add(user->handle_info->handle, argv[1], duration, reason, now, now, 0, 1);
     reply("OSMSG_GLINE_ISSUED", gline->target);
     return 1;
 }
@@ -1020,6 +1022,10 @@ static MODCMD_FUNC(cmd_kick)
         reply("OSMSG_NOT_ON_CHANNEL", target->nick, channel->name);
         return 0;
     }
+    if (IsService(target)) {
+        reply("MSG_SERVICE_IMMUNE", target->nick);
+        return 0;
+    }
     KickChannelUser(target, channel, cmd->parent->bot, reason);
     return 1;
 }
@@ -1876,7 +1882,7 @@ opserv_new_user_check(struct userNode *user)
         } else if (ohi->clients.used > limit) {
             char target[IRC_NTOP_MAX_SIZE + 3] = { '*', '@', '\0' };
             strcpy(target + 2, addr);
-            gline_add(opserv->nick, target, opserv_conf.clone_gline_duration, "AUTO Excessive connections from a single host.", now, now, 1);
+            gline_add(opserv->nick, target, opserv_conf.clone_gline_duration, "AUTO Excessive connections from a single host.", now, now, 0, 1);
         }
     }
 }
@@ -3795,6 +3801,7 @@ gtrace_print_func(struct gline *gline, void *extra)
     char issued[INTERVALLEN];
     char lastmod[INTERVALLEN];
     char expires[INTERVALLEN];
+    char lifetime[INTERVALLEN];
 
     intervalString(issued, now - gline->issued, xtra->user->handle_info);
     if (gline->lastmod)
@@ -3805,7 +3812,8 @@ gtrace_print_func(struct gline *gline, void *extra)
         intervalString(expires, gline->expires - now, xtra->user->handle_info);
     else
         strcpy(expires, "never");
-    send_message(xtra->user, opserv, "OSMSG_GTRACE_FORMAT", gline->target, issued, gline->issuer, lastmod, expires, gline->reason);
+    intervalString(lifetime, gline->lifetime - now, xtra->user->handle_info);
+    send_message(xtra->user, opserv, "OSMSG_GTRACE_FORMAT", gline->target, issued, gline->issuer, lastmod, expires, gline->reason, lifetime);
 }
 
 static MODCMD_FUNC(cmd_stats_glines) {