]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] report haproxy's version by default on the stats page
authorKrzysztof Oledzki <ole@ans.pl>
Mon, 15 Oct 2007 08:05:11 +0000 (10:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 15 Oct 2007 08:05:11 +0000 (10:05 +0200)
For people who manage many haproxies, it is sometimes convenient
to be informed of their version. This patch adds this, with the
option to disable this report by specifying "stats hide-version".

Also, the feature may be permanently disabled by setting the
STATS_VERSION_STRING to "" (empty string), or the format can
simply be adjusted.

doc/configuration.txt
include/common/defaults.h
include/common/uri_auth.h
src/cfgparse.c
src/proto_http.c
src/uri_auth.c

index 994df07e2c0ca559e1057b031c6879b275e38125..97c427c86acbd5ae6fa71be2dc3604b04194a251 100644 (file)
@@ -2,9 +2,9 @@
                                  HAProxy
                           Configuration Manual
                          ----------------------
-                             version 1.3.12.3
+                             version 1.3.13
                              willy tarreau
-                               2007/09/11
+                               2007/10/15
 
 
 This document covers the configuration language as implemented in the version
@@ -299,6 +299,7 @@ stats realm                 X          -         X         X
 stats refresh               X          -         X         X
 stats scope                 X          -         X         X
 stats uri                   X          -         X         X
+stats hide-version          X          -         X         X
 transparent                 X          X         X         -
 use_backend                 -          X         X         -
 usesrc                      X          -         X         X
index 2c757d2f585174690c156a573e0741054216057f..5b18767ca58d1ce80294fb7f26b9f1f663361cb5 100644 (file)
 #define SRV_CHK_INTER_THRES 1000
 #endif
 
+/* Specifies the string used to report the version and release date on the
+ * statistics page. May be defined to the empty string ("") to permanently
+ * disable the feature.
+ */
+#ifndef STATS_VERSION_STRING
+#define STATS_VERSION_STRING " version " HAPROXY_VERSION ", released " HAPROXY_DATE
+#endif
+
 #endif /* _COMMON_DEFAULTS_H */
index 9f675db6a828927ff3e8e7a749eca70cb1eee526..fbbe7df8164df2c19ea00abbcbfc10d506adee9c 100644 (file)
@@ -31,12 +31,15 @@ struct stat_scope {
        char *px_id;                    /* proxy id */
 };
 
+#define        ST_HIDEVER      0x00000001      /* do not report the version and reldate */
+
 /* later we may link them to support multiple URI matching */
 struct uri_auth {
        int uri_len;                    /* the prefix length */
        char *uri_prefix;               /* the prefix we want to match */
        char *auth_realm;               /* the realm reported to the client */
        int refresh;                    /* refresh interval for the browser (in seconds) */
+       int flags;                      /* some flags describing the statistics page */
        struct user_auth *users;        /* linked list of valid user:passwd couples */
        struct stat_scope *scope;       /* linked list of authorized proxies */
 };
@@ -67,6 +70,7 @@ struct uri_auth *stats_check_init_uri_auth(struct uri_auth **root);
 struct uri_auth *stats_set_uri(struct uri_auth **root, char *uri);
 struct uri_auth *stats_set_realm(struct uri_auth **root, char *realm);
 struct uri_auth *stats_set_refresh(struct uri_auth **root, int interval);
+struct uri_auth *stats_set_flag(struct uri_auth **root, int flag);
 struct uri_auth *stats_add_auth(struct uri_auth **root, char *user);
 struct uri_auth *stats_add_scope(struct uri_auth **root, char *scope);
 
index 43ed8aa81077e3d0c8e1e5459344836f742d9140..53c900a697b1971af2c326d61503cb7f1df54ffb 100644 (file)
@@ -1089,8 +1089,13 @@ int cfg_parse_listen(const char *file, int linenum, char **args)
                                Alert("parsing [%s:%d] : out of memory.\n", file, linenum);
                                return -1;
                        }
+               } else if (!strcmp(args[1], "hide-version")) {
+                       if (!stats_set_flag(&curproxy->uri_auth, ST_HIDEVER)) {
+                               Alert("parsing [%s:%d] : out of memory.\n", file, linenum);
+                               return -1;
+                       }
                } else {
-                       Alert("parsing [%s:%d] : unknown stats parameter '%s' (expects 'uri', 'realm', 'auth' or 'enable').\n",
+                       Alert("parsing [%s:%d] : unknown stats parameter '%s' (expects 'hide-version', 'uri', 'realm', 'auth' or 'enable').\n",
                              file, linenum, args[0]);
                        return -1;
                }
index 3cd97fe823750ebe7f725c233af5826b117a77c7..c218e6bb96f5275b1cd1489a7063df6b30802323 100644 (file)
@@ -3579,7 +3579,7 @@ int produce_content_stats(struct session *s)
                         */
                chunk_printf(&msg, sizeof(trash),
                             "<body><h1><a href=\"" PRODUCT_URL "\" style=\"text-decoration: none;\">"
-                            PRODUCT_NAME "</a></h1>\n"
+                            PRODUCT_NAME "%s</a></h1>\n"
                             "<h2>Statistics Report for pid %d</h2>\n"
                             "<hr width=\"100%%\" class=\"hr\">\n"
                             "<h3>&gt; General process information</h3>\n"
@@ -3607,6 +3607,7 @@ int produce_content_stats(struct session *s)
                             "<td align=\"left\" valign=\"top\" nowrap width=\"1%%\">"
                             "<b>Display option:</b><ul style=\"margin-top: 0.25em;\">"
                             "",
+                            (s->be->uri_auth->flags&ST_HIDEVER)?"":(STATS_VERSION_STRING),
                             pid, pid, global.nbproc,
                             up / 86400, (up % 86400) / 3600,
                             (up % 3600) / 60, (up % 60),
index f5f90af7b251f09f59733ee8c59d85a6a2da1f48..8ac618cc373a2fcad43a56610668cda0d2fb8c88 100644 (file)
@@ -126,6 +126,19 @@ struct uri_auth *stats_set_refresh(struct uri_auth **root, int interval)
        return u;
 }
 
+/*
+ * Returns a default uri_auth with the <flag> set.
+ * Uses the pointer provided if not NULL and not initialized.
+ */
+struct uri_auth *stats_set_flag(struct uri_auth **root, int flag)
+{
+       struct uri_auth *u;
+       
+       if ((u = stats_check_init_uri_auth(root)) != NULL)
+               u->flags |= flag;
+       return u;
+}
+
 /*
  * Returns a default uri_auth with a <user:passwd> entry added to the list of
  * authorized users. If a matching entry is found, no update will be performed.