Insert a refresh tag into the /client-tags cgi page
[privoxy.git] / cgisimple.c
index c2983e3..078a001 100644 (file)
@@ -1,4 +1,4 @@
-const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.145 2017/01/23 13:05:12 fabiankeil Exp $";
+const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.146 2017/02/20 13:45:14 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
@@ -345,6 +345,7 @@ jb_err cgi_show_client_tags(struct client_state *csp,
    jb_err err = JB_ERR_OK;
    char *client_tag_status;
    char buf[1000];
+   time_t refresh_delay;
 
    assert(csp);
    assert(rsp);
@@ -397,6 +398,24 @@ jb_err cgi_show_client_tags(struct client_state *csp,
       }
       if (!err) err = string_append(&client_tag_status, "</table>\n");
    }
+   refresh_delay = get_next_tag_timeout_for_client(csp->client_address);
+   if (refresh_delay != 0)
+   {
+      snprintf(buf, sizeof(buf), "%d", csp->config->client_tag_lifetime);
+      if (map(exports, "refresh-delay", 1, buf, 1))
+      {
+         free_map(exports);
+         return JB_ERR_MEMORY;
+      }
+   }
+   else
+   {
+      err = map_block_killer(exports, "tags-expire");
+      if (err != JB_ERR_OK)
+      {
+         return err;
+      }
+   }
 
    if (map(exports, "client-tags", 1, client_tag_status, 0))
    {