Mercurial > dovecot > core-2.2
annotate src/login-common/login-proxy.h @ 8583:2ff2cac3578b HEAD
imap/pop3-login: Cleaned up proxying code. Don't disconnect client on proxy failures.
Log proxy failures as errors.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 21 Dec 2008 09:43:20 +0200 |
parents | 81806d402514 |
children | 6324a79d3ee1 |
rev | line source |
---|---|
6410
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
5048
diff
changeset
|
1 #ifndef LOGIN_PROXY_H |
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
5048
diff
changeset
|
2 #define LOGIN_PROXY_H |
2768
d344be0bb70f
Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 |
2773
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
4 struct login_proxy; |
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
5 |
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
6 /* Called when new input comes from proxy. */ |
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
7 typedef void proxy_callback_t(struct istream *input, struct ostream *output, |
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
8 void *context); |
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
9 |
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
10 /* Create a proxy to given host. Returns NULL if failed. Given callback is |
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
11 called when new input is available from proxy. */ |
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
12 struct login_proxy * |
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
13 login_proxy_new(struct client *client, const char *host, unsigned int port, |
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
14 proxy_callback_t *callback, void *context); |
4906
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
15 #ifdef CONTEXT_TYPE_SAFETY |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
16 # define login_proxy_new(client, host, port, callback, context) \ |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
17 ({(void)(1 ? 0 : callback((struct istream *)NULL, \ |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
18 (struct ostream *)NULL, context)); \ |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
19 login_proxy_new(client, host, port, \ |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
20 (proxy_callback_t *)callback, context); }) |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
21 #else |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
22 # define login_proxy_new(client, host, port, callback, context) \ |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
23 login_proxy_new(client, host, port, \ |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
24 (proxy_callback_t *)callback, context) |
0c3c948412c5
Type safe callbacks weren't as easy as I thought. Only callback(void
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
25 #endif |
2773
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
26 /* Free the proxy. This should be called if authentication fails. */ |
8583
2ff2cac3578b
imap/pop3-login: Cleaned up proxying code. Don't disconnect client on proxy failures.
Timo Sirainen <tss@iki.fi>
parents:
7912
diff
changeset
|
27 void login_proxy_free(struct login_proxy **proxy); |
2773
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
28 |
6472
6afb29dc9273
If proxy points to the same host/port/user combination as we currently have,
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
29 /* Return TRUE if host/port/destuser combination points to same as current |
6afb29dc9273
If proxy points to the same host/port/user combination as we currently have,
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
30 connection. */ |
7912
81806d402514
Added more consts, ATTR_CONSTs and ATTR_PUREs.
Timo Sirainen <tss@iki.fi>
parents:
6472
diff
changeset
|
31 bool login_proxy_is_ourself(const struct client *client, const char *host, |
6472
6afb29dc9273
If proxy points to the same host/port/user combination as we currently have,
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
32 unsigned int port, const char *destuser); |
6afb29dc9273
If proxy points to the same host/port/user combination as we currently have,
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
33 |
2773
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
34 /* Detach proxy from client. This is done after the authentication is |
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
35 successful and all that is left is the dummy proxying. */ |
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
36 void login_proxy_detach(struct login_proxy *proxy, struct istream *client_input, |
e624a9ad6a30
More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents:
2768
diff
changeset
|
37 struct ostream *client_output); |
2768
d344be0bb70f
Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
38 |
7912
81806d402514
Added more consts, ATTR_CONSTs and ATTR_PUREs.
Timo Sirainen <tss@iki.fi>
parents:
6472
diff
changeset
|
39 const char *login_proxy_get_host(const struct login_proxy *proxy) ATTR_PURE; |
81806d402514
Added more consts, ATTR_CONSTs and ATTR_PUREs.
Timo Sirainen <tss@iki.fi>
parents:
6472
diff
changeset
|
40 unsigned int login_proxy_get_port(const struct login_proxy *proxy) ATTR_PURE; |
5048
5c0a5cf4626d
Forgot to commit for the "log proxy destination" change.
Timo Sirainen <tss@iki.fi>
parents:
4906
diff
changeset
|
41 |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
2773
diff
changeset
|
42 /* Return number of active detached login proxies */ |
7912
81806d402514
Added more consts, ATTR_CONSTs and ATTR_PUREs.
Timo Sirainen <tss@iki.fi>
parents:
6472
diff
changeset
|
43 unsigned int login_proxy_get_count(void) ATTR_PURE; |
4538
9d9e72374164
Fixes to login process handling, especially with
Timo Sirainen <tss@iki.fi>
parents:
2773
diff
changeset
|
44 |
2768
d344be0bb70f
Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
45 void login_proxy_deinit(void); |
d344be0bb70f
Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
46 |
d344be0bb70f
Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
47 #endif |