comparison src/imap/ngx_imap.h @ 76:da9a3b14312d NGINX_0_1_38

nginx 0.1.38 *) Feature: the "limit_rate" directive is supported in in proxy and FastCGI mode. *) Feature: the "X-Accel-Limit-Rate" response header line is supported in proxy and FastCGI mode. *) Feature: the "break" directive. *) Feature: the "log_not_found" directive. *) Bugfix: the response status code was not changed when request was redirected by the ""X-Accel-Redirect" header line. *) Bugfix: the variables set by the "set" directive could not be used in SSI. *) Bugfix: the segmentation fault may occurred if the SSI page has more than one remote subrequest. *) Bugfix: nginx treated the backend response as invalid if the status line in the header was transferred in two packets; bug appeared in 0.1.29. *) Feature: the "ssi_types" directive. *) Feature: the "autoindex_exact_size" directive. *) Bugfix: the ngx_http_autoindex_module did not support the long file names in UTF-8. *) Feature: the IMAP/POP3 proxy.
author Igor Sysoev <http://sysoev.ru>
date Fri, 08 Jul 2005 00:00:00 +0400
parents
children e916a291e9aa
comparison
equal deleted inserted replaced
75:985847bb65f9 76:da9a3b14312d
1
2 /*
3 * Copyright (C) Igor Sysoev
4 */
5
6
7 #ifndef _NGX_IMAP_H_INCLUDED_
8 #define _NGX_IMAP_H_INCLUDED_
9
10
11 #include <ngx_config.h>
12 #include <ngx_core.h>
13 #include <ngx_event.h>
14 #include <ngx_event_connect.h>
15
16
17 typedef struct {
18 void **main_conf;
19 void **srv_conf;
20 } ngx_imap_conf_ctx_t;
21
22
23 typedef struct {
24 ngx_array_t servers; /* ngx_imap_core_srv_conf_t */
25 } ngx_imap_core_main_conf_t;
26
27
28 #define NGX_IMAP_POP3_PROTOCOL 0
29 #define NGX_IMAP_IMAP_PROTOCOL 1
30
31 typedef struct {
32 ngx_msec_t timeout;
33
34 size_t imap_client_buffer_size;
35 size_t proxy_buffer_size;
36
37 ngx_uint_t protocol;
38
39 ngx_buf_t *pop3_capability;
40 ngx_buf_t *imap_capability;
41
42 ngx_array_t pop3_capabilities;
43 ngx_array_t imap_capabilities;
44
45 /* server ctx */
46 ngx_imap_conf_ctx_t *ctx;
47 } ngx_imap_core_srv_conf_t;
48
49
50 typedef struct {
51 void *(*create_main_conf)(ngx_conf_t *cf);
52 char *(*init_main_conf)(ngx_conf_t *cf, void *conf);
53
54 void *(*create_srv_conf)(ngx_conf_t *cf);
55 char *(*merge_srv_conf)(ngx_conf_t *cf, void *prev, void *conf);
56 } ngx_imap_module_t;
57
58
59 typedef enum {
60 ngx_imap_start = 0,
61 ngx_imap_login,
62 ngx_imap_user,
63 ngx_imap_passwd,
64 } ngx_imap_state_e;
65
66
67 typedef enum {
68 ngx_pop3_start = 0,
69 ngx_pop3_user,
70 ngx_pop3_passwd
71 } ngx_po3_state_e;
72
73
74 typedef struct {
75 ngx_peer_connection_t upstream;
76 ngx_buf_t *buffer;
77 } ngx_imap_proxy_ctx_t;
78
79
80 typedef struct {
81 uint32_t signature; /* "IMAP" */
82
83 ngx_connection_t *connection;
84
85 ngx_buf_t *buffer;
86 ngx_str_t out;
87
88 void **ctx;
89 void **main_conf;
90 void **srv_conf;
91
92 ngx_imap_proxy_ctx_t *proxy;
93
94 ngx_uint_t imap_state;
95
96 unsigned protocol:1;
97 unsigned quoted:1;
98
99 ngx_str_t login;
100 ngx_str_t passwd;
101
102 ngx_str_t tag;
103
104 ngx_uint_t command;
105 ngx_array_t args;
106
107 ngx_uint_t login_attempt;
108
109 /* used to parse IMAP/POP3 command */
110
111 ngx_uint_t state;
112 u_char *cmd_start;
113 u_char *arg_start;
114 u_char *arg_end;
115 ngx_uint_t literal_len;
116 } ngx_imap_session_t;
117
118
119 #define NGX_POP3_USER 1
120 #define NGX_POP3_PASS 2
121 #define NGX_POP3_CAPA 3
122 #define NGX_POP3_QUIT 4
123 #define NGX_POP3_NOOP 5
124 #define NGX_POP3_APOP 6
125 #define NGX_POP3_STAT 7
126 #define NGX_POP3_LIST 8
127 #define NGX_POP3_RETR 9
128 #define NGX_POP3_DELE 10
129 #define NGX_POP3_RSET 11
130 #define NGX_POP3_TOP 12
131 #define NGX_POP3_UIDL 13
132
133
134 #define NGX_IMAP_LOGIN 1
135 #define NGX_IMAP_LOGOUT 2
136 #define NGX_IMAP_CAPABILITY 3
137 #define NGX_IMAP_NOOP 4
138
139 #define NGX_IMAP_NEXT 5
140
141
142 #define NGX_IMAP_PARSE_INVALID_COMMAND 20
143
144
145 #define NGX_IMAP_PROXY_INVALID 10
146 #define NGX_IMAP_PROXY_ERROR 11
147
148
149 #define NGX_IMAP_MODULE 0x50414D49 /* "IMAP" */
150
151 #define NGX_IMAP_MAIN_CONF 0x02000000
152 #define NGX_IMAP_SRV_CONF 0x04000000
153
154
155 #define NGX_IMAP_MAIN_CONF_OFFSET offsetof(ngx_imap_conf_ctx_t, main_conf)
156 #define NGX_IMAP_SRV_CONF_OFFSET offsetof(ngx_imap_conf_ctx_t, srv_conf)
157
158
159 #define ngx_imap_get_module_ctx(s, module) (s)->ctx[module.ctx_index]
160 #define ngx_imap_set_ctx(s, c, module) s->ctx[module.ctx_index] = c;
161 #define ngx_imap_delete_ctx(s, module) s->ctx[module.ctx_index] = NULL;
162
163
164 #define ngx_imap_get_module_main_conf(s, module) \
165 (s)->main_conf[module.ctx_index]
166 #define ngx_imap_get_module_srv_conf(s, module) (s)->srv_conf[module.ctx_index]
167
168
169 void ngx_imap_init_connection(ngx_connection_t *c);
170 void ngx_imap_auth_state(ngx_event_t *rev);
171 void ngx_pop3_auth_state(ngx_event_t *rev);
172 void ngx_imap_close_connection(ngx_connection_t *c);
173 void ngx_imap_session_internal_server_error(ngx_imap_session_t *s);
174
175 ngx_int_t ngx_imap_parse_command(ngx_imap_session_t *s);
176 ngx_int_t ngx_pop3_parse_command(ngx_imap_session_t *s);
177
178
179 /* STUB */
180 void ngx_imap_proxy_init(ngx_imap_session_t *s, ngx_peers_t *peers);
181 void ngx_imap_auth_http_init(ngx_imap_session_t *s);
182 /**/
183
184
185 extern ngx_uint_t ngx_imap_max_module;
186 extern ngx_module_t ngx_imap_core_module;
187
188
189 #endif /* _NGX_IMAP_H_INCLUDED_ */