summaryrefslogtreecommitdiffstats
path: root/web/attachments/367917-check_http.HTTP_CONNECT_patch
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-09-29 22:03:24 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-09-29 22:03:24 (GMT)
commit0b6423f9c99d9edf8c96fefd0f6c453859395aa1 (patch)
tree1c2b6b21704a294940f87c7892676998d8371707 /web/attachments/367917-check_http.HTTP_CONNECT_patch
downloadsite-0b6423f9c99d9edf8c96fefd0f6c453859395aa1.tar.gz
Import Nagios Plugins site
Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files.
Diffstat (limited to 'web/attachments/367917-check_http.HTTP_CONNECT_patch')
-rw-r--r--web/attachments/367917-check_http.HTTP_CONNECT_patch145
1 files changed, 145 insertions, 0 deletions
diff --git a/web/attachments/367917-check_http.HTTP_CONNECT_patch b/web/attachments/367917-check_http.HTTP_CONNECT_patch
new file mode 100644
index 0000000..00a4008
--- /dev/null
+++ b/web/attachments/367917-check_http.HTTP_CONNECT_patch
@@ -0,0 +1,145 @@
1*** plugins/check_http.c.orig 2010-03-18 15:05:53.000000000 -0400
2--- plugins/check_http.c 2010-03-23 14:26:48.000000000 -0400
3***************
4*** 121,126 ****
5--- 121,127 ----
6 char *http_post_data;
7 char *http_content_type;
8 char buffer[MAX_INPUT_BUFFER];
9+ int http_connect = FALSE;
10
11 int process_arguments (int, char **);
12 int check_http (void);
13***************
14*** 186,191 ****
15--- 187,193 ----
16 {"link", no_argument, 0, 'L'},
17 {"nohtml", no_argument, 0, 'n'},
18 {"ssl", no_argument, 0, 'S'},
19+ {"http-connect", no_argument, 0, 'K'},
20 {"post", required_argument, 0, 'P'},
21 {"method", required_argument, 0, 'j'},
22 {"IP-address", required_argument, 0, 'I'},
23***************
24*** 229,235 ****
25 }
26
27 while (1) {
28! c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:e:p:s:R:r:u:f:C:nlLSm:M:N", longopts, &option);
29 if (c == -1 || c == EOF)
30 break;
31
32--- 231,237 ----
33 }
34
35 while (1) {
36! c = getopt_long (argc, argv, "Vvh46Kt:c:w:A:k:H:P:j:T:I:a:e:p:s:R:r:u:f:C:nlLSm:M:N", longopts, &option);
37 if (c == -1 || c == EOF)
38 break;
39
40***************
41*** 401,406 ****
42--- 403,411 ----
43 usage4 (_("IPv6 support not available"));
44 #endif
45 break;
46+ case 'K': /* use http-connect */
47+ http_connect = TRUE;
48+ break;
49 case 'v': /* verbose */
50 verbose = TRUE;
51 break;
52***************
53*** 790,795 ****
54--- 795,807 ----
55 die (STATE_CRITICAL, _("HTTP CRITICAL - Unable to open TCP socket\n"));
56 #ifdef HAVE_SSL
57 if (use_ssl == TRUE) {
58+
59+ if (http_connect == TRUE) {
60+ /* only using port 443 */
61+ if (http_connect_through_proxy(host_name, 443, user_agent, sd) != STATE_OK)
62+ die (STATE_CRITICAL, _("HTTP CRITICAL - Unable to open proxy tunnel TCP socket\n"));
63+ }
64+
65 np_net_ssl_init_with_hostname(sd, host_name);
66 if (check_cert == TRUE) {
67 result = np_net_ssl_check_cert(days_till_exp);
68***************
69*** 1234,1239 ****
70--- 1246,1290 ----
71 }
72
73
74+
75+ /* start the HTTP CONNECT method exchange with a proxy host */
76+ int
77+ http_connect_through_proxy (char *host_name, int port, char *user_agent, int sd)
78+ {
79+ int result;
80+ char *send_buffer=NULL;
81+ char recv_buffer[MAX_INPUT_BUFFER];
82+ char *status_line;
83+ char *status_code;
84+ int http_status;
85+
86+ asprintf( &send_buffer, "CONNECT %s:%d HTTP/1.0\r\nUser-agent: %s\r\n\r\n", host_name, port, user_agent);
87+
88+ result = STATE_OK;
89+ result = send_tcp_request (sd, send_buffer, recv_buffer, sizeof(recv_buffer));
90+ if (result != STATE_OK)
91+ return result;
92+
93+ status_line = recv_buffer;
94+ status_line[strcspn(status_line, "\r\n")] = 0;
95+ strip (status_line);
96+ if (verbose)
97+ printf ("HTTP_CONNECT STATUS: %s\n", status_line);
98+
99+ status_code = strchr (status_line, ' ') + sizeof (char);
100+ if (strspn (status_code, "1234567890") != 3)
101+ die (STATE_CRITICAL, _("HTTP CRITICAL: HTTP_CONNECT Returns Invalid Status Line (%s)\n"), status_line);
102+
103+ http_status = atoi (status_code);
104+
105+ if (http_status != 200) {
106+ die (STATE_CRITICAL, _("HTTP CRITICAL: Invalid HTTP Connect Proxy Status (%s)\n"), status_line);
107+ }
108+
109+ return STATE_OK;
110+ }
111+
112+
113 int
114 server_type_check (const char *type)
115 {
116***************
117*** 1308,1313 ****
118--- 1359,1368 ----
119 #ifdef HAVE_SSL
120 printf (" %s\n", "-S, --ssl");
121 printf (" %s\n", _("Connect via SSL. Port defaults to 443"));
122+ printf (" %s\n", "-K, --http-connect");
123+ printf (" %s\n", _("Connect to a proxy using the HTTP CONNECT protocol (SSL tunnel)."));
124+ printf (" %s\n", _("Requires -S option. Will only connect to host through tunnel"));
125+ printf (" %s\n", _("on port 443."));
126 printf (" %s\n", "-C, --certificate=INTEGER");
127 printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443"));
128 printf (" %s\n", _("(when this option is used the URL is not checked.)\n"));
129***************
130*** 1406,1412 ****
131 {
132 printf (_("Usage:"));
133 printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname);
134! printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n");
135 printf (" [-a auth] [-f <ok | warn | critcal | follow | sticky | stickyport>]\n");
136 printf (" [-e <expect>] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n");
137 printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n");
138--- 1461,1467 ----
139 {
140 printf (_("Usage:"));
141 printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname);
142! printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-K]\n");
143 printf (" [-a auth] [-f <ok | warn | critcal | follow | sticky | stickyport>]\n");
144 printf (" [-e <expect>] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n");
145 printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n");