annotate src/login-common/login-proxy.h @ 10616:23956a9b915b HEAD

login: Proxying supports now doing DNS lookups for host names.
author Timo Sirainen <tss@iki.fi>
date Sun, 31 Jan 2010 19:11:21 +0200
parents 6b3dc91ae0c5
children c872378a8de6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
9756
e30495ae11de *-login: Moved most of the common code to login-common.
Timo Sirainen <tss@iki.fi>
parents: 9165
diff changeset
4 struct client;
2773
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
5 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
6
9165
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
7 enum login_proxy_ssl_flags {
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
8 /* Use SSL/TLS enabled */
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
9 PROXY_SSL_FLAG_YES = 0x01,
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
10 /* Don't do SSL handshake immediately after connected */
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
11 PROXY_SSL_FLAG_STARTTLS = 0x02,
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
12 /* Don't require that the received certificate is valid */
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
13 PROXY_SSL_FLAG_ANY_CERT = 0x04
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
14 };
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
15
9773
8e099a00f8a9 login proxy: Added client_proxy passdb extra field to specify proxy's connect timeout.
Timo Sirainen <tss@iki.fi>
parents: 9756
diff changeset
16 struct login_proxy_settings {
8e099a00f8a9 login proxy: Added client_proxy passdb extra field to specify proxy's connect timeout.
Timo Sirainen <tss@iki.fi>
parents: 9756
diff changeset
17 const char *host;
10616
23956a9b915b login: Proxying supports now doing DNS lookups for host names.
Timo Sirainen <tss@iki.fi>
parents: 10612
diff changeset
18 const char *dns_client_socket_path;
9773
8e099a00f8a9 login proxy: Added client_proxy passdb extra field to specify proxy's connect timeout.
Timo Sirainen <tss@iki.fi>
parents: 9756
diff changeset
19 unsigned int port;
8e099a00f8a9 login proxy: Added client_proxy passdb extra field to specify proxy's connect timeout.
Timo Sirainen <tss@iki.fi>
parents: 9756
diff changeset
20 unsigned int connect_timeout_msecs;
8e099a00f8a9 login proxy: Added client_proxy passdb extra field to specify proxy's connect timeout.
Timo Sirainen <tss@iki.fi>
parents: 9756
diff changeset
21 enum login_proxy_ssl_flags ssl_flags;
8e099a00f8a9 login proxy: Added client_proxy passdb extra field to specify proxy's connect timeout.
Timo Sirainen <tss@iki.fi>
parents: 9756
diff changeset
22 };
8e099a00f8a9 login proxy: Added client_proxy passdb extra field to specify proxy's connect timeout.
Timo Sirainen <tss@iki.fi>
parents: 9756
diff changeset
23
2773
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
24 /* Called when new input comes from proxy. */
10612
6b3dc91ae0c5 login: Proxy code API cleanup.
Timo Sirainen <tss@iki.fi>
parents: 10171
diff changeset
25 typedef void proxy_callback_t(struct client *client);
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
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
27 /* 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
28 called when new input is available from proxy. */
10612
6b3dc91ae0c5 login: Proxy code API cleanup.
Timo Sirainen <tss@iki.fi>
parents: 10171
diff changeset
29 int login_proxy_new(struct client *client,
6b3dc91ae0c5 login: Proxy code API cleanup.
Timo Sirainen <tss@iki.fi>
parents: 10171
diff changeset
30 const struct login_proxy_settings *set,
10616
23956a9b915b login: Proxying supports now doing DNS lookups for host names.
Timo Sirainen <tss@iki.fi>
parents: 10612
diff changeset
31 proxy_callback_t *callback);
2773
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
32 /* 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
33 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
34
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
35 /* 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
36 connection. */
7912
81806d402514 Added more consts, ATTR_CONSTs and ATTR_PUREs.
Timo Sirainen <tss@iki.fi>
parents: 6472
diff changeset
37 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
38 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
39
2773
e624a9ad6a30 More smart IMAP and POP3 proxies. Now if remote login fails, it just
Timo Sirainen <tss@iki.fi>
parents: 2768
diff changeset
40 /* 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
41 successful and all that is left is the dummy proxying. */
9929
d60fa42fbaac *-login: Fixes to SSL/login proxy connection counting.
Timo Sirainen <tss@iki.fi>
parents: 9774
diff changeset
42 void login_proxy_detach(struct login_proxy *proxy);
2768
d344be0bb70f Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
43
9165
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
44 /* STARTTLS command was issued. */
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
45 int login_proxy_starttls(struct login_proxy *proxy);
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
46
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
47 struct istream *login_proxy_get_istream(struct login_proxy *proxy);
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
48 struct ostream *login_proxy_get_ostream(struct login_proxy *proxy);
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
49
7912
81806d402514 Added more consts, ATTR_CONSTs and ATTR_PUREs.
Timo Sirainen <tss@iki.fi>
parents: 6472
diff changeset
50 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
51 unsigned int login_proxy_get_port(const struct login_proxy *proxy) ATTR_PURE;
9165
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
52 enum login_proxy_ssl_flags
96678e83eab6 imap/pop3 proxy: Support SSL/TLS connections to remote servers.
Timo Sirainen <tss@iki.fi>
parents: 9159
diff changeset
53 login_proxy_get_ssl_flags(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
54
10171
7f0ccd367351 Handle shutdown_clients globally for all services.
Timo Sirainen <tss@iki.fi>
parents: 9929
diff changeset
55 void login_proxy_kill_idle(void);
7f0ccd367351 Handle shutdown_clients globally for all services.
Timo Sirainen <tss@iki.fi>
parents: 9929
diff changeset
56
9774
da0a48b243a2 login-proxy: If proxy destination is known to be down, fail immediately.
Timo Sirainen <tss@iki.fi>
parents: 9773
diff changeset
57 void login_proxy_init(void);
2768
d344be0bb70f Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
58 void login_proxy_deinit(void);
d344be0bb70f Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
59
d344be0bb70f Added IMAP and POP3 proxying support.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
60 #endif