Skip to content

Commit e01614a

Browse files
committed
add module.h
1 parent b5fdafe commit e01614a

6 files changed

+81
-66
lines changed

CHANGES

Whitespace-only changes.

README

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ Status
1212
Synopsis
1313
http {
1414

15-
listen 80;
16-
1715
upstream cluster {
1816
# simple round-robin
1917
server 127.0.0.1:3306;

config

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ngx_feature_name=
33
ngx_feature_run=no
44
ngx_feature_incs=
55
ngx_feature_path="$ngx_addon_dir/modules $ngx_addon_dir"
6-
ngx_feature_deps="$ngx_addon_dir/ngx_http_upstream_check_handler.h"
6+
ngx_feature_deps="$ngx_addon_dir/ngx_http_upstream_check_module.h $ngx_addon_dir/ngx_http_upstream_check_handler.h"
77
ngx_check_src="$ngx_addon_dir/ngx_http_upstream_check_module.c $ngx_addon_dir/ngx_http_upstream_check_handler.c $ngx_addon_dir/http_response_parse.c $ngx_addon_dir/smtp_response_parse.c"
88
ngx_feature_test="int a;"
99
. auto/feature

ngx_http_upstream_check_handler.h

+4-63
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef _NGX_HTTP_UPSTREAM_CHECK_H_INCLUDED_
2-
#define _NGX_HTTP_UPSTREAM_CHECK_H_INCLUDED_
1+
#ifndef _NGX_HTTP_UPSTREAM_CHECK_HANDLER_H_INCLUDED_
2+
#define _NGX_HTTP_UPSTREAM_CHECK_HANDLER_H_INCLUDED_
33

44

55
#include <ngx_config.h>
@@ -8,11 +8,8 @@
88
#include <ngx_event_connect.h>
99
#include <ngx_event_pipe.h>
1010
#include <ngx_http.h>
11+
#include "ngx_http_upstream_check_module.h"
1112

12-
/* make nginx-0.8.22+ happy */
13-
#if defined(nginx_version) && nginx_version >= 8022
14-
typedef ngx_addr_t ngx_peer_addr_t;
15-
#endif
1613

1714
typedef struct {
1815
u_char major;
@@ -81,53 +78,6 @@ typedef struct {
8178
ngx_http_check_peer_shm_t peers[0];
8279
} ngx_http_check_peers_shm_t;
8380

84-
typedef ngx_int_t (*ngx_http_check_packet_init_pt)(ngx_http_check_peer_conf_t *peer_conf);
85-
typedef ngx_int_t (*ngx_http_check_packet_parse_pt)(ngx_http_check_peer_conf_t *peer_conf);
86-
typedef void (*ngx_http_check_packet_clean_pt)(ngx_http_check_peer_conf_t *peer_conf);
87-
88-
#define NGX_HTTP_CHECK_TCP 0x0001
89-
#define NGX_HTTP_CHECK_HTTP 0x0002
90-
#define NGX_HTTP_CHECK_SSL_HELLO 0x0004
91-
#define NGX_HTTP_CHECK_SMTP 0x0008
92-
#define NGX_HTTP_CHECK_MYSQL 0x0010
93-
#define NGX_HTTP_CHECK_POP3 0x0020
94-
#define NGX_HTTP_CHECK_IMAP 0x0040
95-
96-
97-
#define NGX_CHECK_HTTP_2XX 0x0002
98-
#define NGX_CHECK_HTTP_3XX 0x0004
99-
#define NGX_CHECK_HTTP_4XX 0x0008
100-
#define NGX_CHECK_HTTP_5XX 0x0010
101-
#define NGX_CHECK_HTTP_6XX 0x0020
102-
#define NGX_CHECK_HTTP_ERR 0x8000
103-
104-
#define NGX_CHECK_SMTP_2XX 0x0002
105-
#define NGX_CHECK_SMTP_3XX 0x0004
106-
#define NGX_CHECK_SMTP_4XX 0x0008
107-
#define NGX_CHECK_SMTP_5XX 0x0010
108-
#define NGX_CHECK_SMTP_6XX 0x0020
109-
#define NGX_CHECK_SMTP_ERR 0x8000
110-
111-
struct check_conf_s {
112-
ngx_uint_t type;
113-
114-
char *name;
115-
116-
ngx_str_t default_send;
117-
118-
/*HTTP*/
119-
ngx_uint_t default_status_alive;
120-
121-
ngx_event_handler_pt send_handler;
122-
ngx_event_handler_pt recv_handler;
123-
124-
ngx_http_check_packet_init_pt init;
125-
ngx_http_check_packet_parse_pt parse;
126-
ngx_http_check_packet_clean_pt reinit;
127-
128-
unsigned need_pool;
129-
};
130-
13181
struct ngx_http_check_peer_conf_s {
13282

13383
ngx_flag_t state;
@@ -220,21 +170,12 @@ int smtp_parser_is_finished(smtp_parser *parser);
220170
#define http_parser_nread(parser) (parser)->nread
221171

222172

223-
ngx_int_t ngx_http_upstream_init_main_check_conf(ngx_conf_t *cf, void*conf);
224-
225-
ngx_int_t ngx_http_check_init_process(ngx_cycle_t *cycle);
226-
227173
ngx_int_t ngx_http_upstream_check_status_handler(ngx_http_request_t *r);
228174

229-
ngx_uint_t ngx_http_check_add_peer(ngx_conf_t *cf, ngx_http_upstream_srv_conf_t *uscf,
230-
ngx_peer_addr_t *peer);
231-
232175
ngx_uint_t ngx_http_check_peer_down(ngx_uint_t index);
233176

234177
void ngx_http_check_get_peer(ngx_uint_t index);
235178
void ngx_http_check_free_peer(ngx_uint_t index);
236179

237-
check_conf_t *ngx_http_get_check_type_conf(ngx_str_t *str);
238-
239-
#endif //_NGX_HTTP_UPSTREAM_CHECK_H_INCLUDED_
180+
#endif //_NGX_HTTP_UPSTREAM_CHECK_HANDLER_H_INCLUDED_
240181

ngx_http_upstream_check_module.c

+2
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,5 @@ ngx_http_upstream_check_status_set_status(ngx_conf_t *cf,
233233

234234
return NGX_CONF_OK;
235235
}
236+
237+

ngx_http_upstream_check_module.h

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#ifndef _NGX_HTTP_UPSTREAM_CHECK_MODELE_H_INCLUDED_
2+
#define _NGX_HTTP_UPSTREAM_CHECK_MODELE_H_INCLUDED_
3+
4+
5+
#include <ngx_config.h>
6+
#include <ngx_core.h>
7+
#include <ngx_event.h>
8+
#include <ngx_event_connect.h>
9+
#include <ngx_event_pipe.h>
10+
#include <ngx_http.h>
11+
12+
/* make nginx-0.8.22+ happy */
13+
#if defined(nginx_version) && nginx_version >= 8022
14+
typedef ngx_addr_t ngx_peer_addr_t;
15+
#endif
16+
17+
typedef ngx_int_t (*ngx_http_check_packet_init_pt)(ngx_http_check_peer_conf_t *peer_conf);
18+
typedef ngx_int_t (*ngx_http_check_packet_parse_pt)(ngx_http_check_peer_conf_t *peer_conf);
19+
typedef void (*ngx_http_check_packet_clean_pt)(ngx_http_check_peer_conf_t *peer_conf);
20+
21+
#define NGX_HTTP_CHECK_TCP 0x0001
22+
#define NGX_HTTP_CHECK_HTTP 0x0002
23+
#define NGX_HTTP_CHECK_SSL_HELLO 0x0004
24+
#define NGX_HTTP_CHECK_SMTP 0x0008
25+
#define NGX_HTTP_CHECK_MYSQL 0x0010
26+
#define NGX_HTTP_CHECK_POP3 0x0020
27+
#define NGX_HTTP_CHECK_IMAP 0x0040
28+
29+
30+
#define NGX_CHECK_HTTP_2XX 0x0002
31+
#define NGX_CHECK_HTTP_3XX 0x0004
32+
#define NGX_CHECK_HTTP_4XX 0x0008
33+
#define NGX_CHECK_HTTP_5XX 0x0010
34+
#define NGX_CHECK_HTTP_6XX 0x0020
35+
#define NGX_CHECK_HTTP_ERR 0x8000
36+
37+
#define NGX_CHECK_SMTP_2XX 0x0002
38+
#define NGX_CHECK_SMTP_3XX 0x0004
39+
#define NGX_CHECK_SMTP_4XX 0x0008
40+
#define NGX_CHECK_SMTP_5XX 0x0010
41+
#define NGX_CHECK_SMTP_6XX 0x0020
42+
#define NGX_CHECK_SMTP_ERR 0x8000
43+
44+
struct check_conf_s {
45+
ngx_uint_t type;
46+
47+
char *name;
48+
49+
ngx_str_t default_send;
50+
51+
/*HTTP*/
52+
ngx_uint_t default_status_alive;
53+
54+
ngx_event_handler_pt send_handler;
55+
ngx_event_handler_pt recv_handler;
56+
57+
ngx_http_check_packet_init_pt init;
58+
ngx_http_check_packet_parse_pt parse;
59+
ngx_http_check_packet_clean_pt reinit;
60+
61+
unsigned need_pool;
62+
};
63+
64+
ngx_int_t ngx_http_upstream_init_main_check_conf(ngx_conf_t *cf, void*conf);
65+
66+
ngx_int_t ngx_http_check_init_process(ngx_cycle_t *cycle);
67+
68+
ngx_uint_t ngx_http_check_add_peer(ngx_conf_t *cf, ngx_http_upstream_srv_conf_t *uscf,
69+
ngx_peer_addr_t *peer);
70+
71+
check_conf_t *ngx_http_get_check_type_conf(ngx_str_t *str);
72+
73+
#endif //_NGX_HTTP_UPSTREAM_CHECK_MODELE_H_INCLUDED_
74+

0 commit comments

Comments
 (0)