diff options
author | Lorenz <12514511+RincewindsHat@users.noreply.github.com> | 2022-01-03 13:48:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-03 13:48:39 +0100 |
commit | 2714df42fd27ec377228a102acff3744d6bff86d (patch) | |
tree | 3098fa3d9be4826e5da9d1df39ecf6b42bf3570b /plugins/check_http.c | |
parent | 11af74de386ba7c02d5d0e53f2500b5029a4537d (diff) | |
parent | 78a999edd4dd3305ef8fa3e06c43f6a893fb6fea (diff) | |
download | monitoring-plugins-2714df42fd27ec377228a102acff3744d6bff86d.tar.gz |
Merge branch 'master' into master
Diffstat (limited to 'plugins/check_http.c')
-rw-r--r-- | plugins/check_http.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index de59a068..34fb4f01 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -72,7 +72,7 @@ int maximum_age = -1; | |||
72 | 72 | ||
73 | enum { | 73 | enum { |
74 | REGS = 2, | 74 | REGS = 2, |
75 | MAX_RE_SIZE = 256 | 75 | MAX_RE_SIZE = 1024 |
76 | }; | 76 | }; |
77 | #include "regex.h" | 77 | #include "regex.h" |
78 | regex_t preg; | 78 | regex_t preg; |
@@ -931,6 +931,21 @@ check_http (void) | |||
931 | 931 | ||
932 | if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT); | 932 | if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT); |
933 | asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent); | 933 | asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent); |
934 | if (strlen(proxy_auth)) { | ||
935 | base64_encode_alloc (proxy_auth, strlen (proxy_auth), &auth); | ||
936 | xasprintf (&buf, "%sProxy-Authorization: Basic %s\r\n", buf, auth); | ||
937 | } | ||
938 | /* optionally send any other header tag */ | ||
939 | if (http_opt_headers_count) { | ||
940 | for (i = 0; i < http_opt_headers_count ; i++) { | ||
941 | if (force_host_header != http_opt_headers[i]) { | ||
942 | xasprintf (&buf, "%s%s\r\n", buf, http_opt_headers[i]); | ||
943 | } | ||
944 | } | ||
945 | /* This cannot be free'd here because a redirection will then try to access this and segfault */ | ||
946 | /* Covered in a testcase in tests/check_http.t */ | ||
947 | /* free(http_opt_headers); */ | ||
948 | } | ||
934 | asprintf (&buf, "%sProxy-Connection: keep-alive\r\n", buf); | 949 | asprintf (&buf, "%sProxy-Connection: keep-alive\r\n", buf); |
935 | asprintf (&buf, "%sHost: %s\r\n", buf, host_name); | 950 | asprintf (&buf, "%sHost: %s\r\n", buf, host_name); |
936 | /* we finished our request, send empty line with CRLF */ | 951 | /* we finished our request, send empty line with CRLF */ |
@@ -1438,8 +1453,8 @@ redir (char *pos, char *status_line) | |||
1438 | !strncmp(server_address, addr, MAX_IPV4_HOSTLENGTH) && | 1453 | !strncmp(server_address, addr, MAX_IPV4_HOSTLENGTH) && |
1439 | (host_name && !strncmp(host_name, addr, MAX_IPV4_HOSTLENGTH)) && | 1454 | (host_name && !strncmp(host_name, addr, MAX_IPV4_HOSTLENGTH)) && |
1440 | !strcmp(server_url, url)) | 1455 | !strcmp(server_url, url)) |
1441 | die (STATE_WARNING, | 1456 | die (STATE_CRITICAL, |
1442 | _("HTTP WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n"), | 1457 | _("HTTP CRITICAL - redirection creates an infinite loop - %s://%s:%d%s%s\n"), |
1443 | type, addr, i, url, (display_html ? "</A>" : "")); | 1458 | type, addr, i, url, (display_html ? "</A>" : "")); |
1444 | 1459 | ||
1445 | strcpy (server_type, type); | 1460 | strcpy (server_type, type); |
@@ -1552,6 +1567,10 @@ print_help (void) | |||
1552 | 1567 | ||
1553 | print_usage (); | 1568 | print_usage (); |
1554 | 1569 | ||
1570 | #ifdef HAVE_SSL | ||
1571 | printf (_("In the first form, make an HTTP request.")); | ||
1572 | printf (_("In the second form, connect to the server and check the TLS certificate.")); | ||
1573 | #endif | ||
1555 | printf (_("NOTE: One or both of -H and -I must be specified")); | 1574 | printf (_("NOTE: One or both of -H and -I must be specified")); |
1556 | 1575 | ||
1557 | printf ("\n"); | 1576 | printf ("\n"); |
@@ -1711,6 +1730,8 @@ print_usage (void) | |||
1711 | printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]\n"); | 1730 | printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]\n"); |
1712 | printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n"); | 1731 | printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n"); |
1713 | printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n"); | 1732 | printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n"); |
1714 | printf (" [-A string] [-k string] [-S <version>] [--sni] [-C <warn_age>[,<crit_age>]]\n"); | 1733 | printf (" [-A string] [-k string] [-S <version>] [--sni]\n"); |
1715 | printf (" [-T <content-type>] [-j method]\n"); | 1734 | printf (" [-T <content-type>] [-j method]\n"); |
1735 | printf (" %s -H <vhost> | -I <IP-address> -C <warn_age>[,<crit_age>]\n",progname); | ||
1736 | printf (" [-p <port>] [-t <timeout>] [-4|-6] [--sni]\n"); | ||
1716 | } | 1737 | } |