]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
*-login: Add client.proxy_get_state() for providing human-readable proxy state
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 9 Mar 2017 15:31:39 +0000 (10:31 -0500)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 16 Mar 2017 17:41:21 +0000 (19:41 +0200)
If not implemented, it defaults to the old method of returning proxy_state
number.

src/imap-urlauth/imap-urlauth-login.c
src/login-common/client-common-auth.c
src/login-common/client-common.c
src/login-common/client-common.h
src/login-common/login-proxy.c
src/pop3-login/client.c

index 593e9c721cd7d11b2c8c87e035d536df10ad847a..37b3b90f65101e0ec97e5583ba9882df96689fc9 100644 (file)
@@ -172,7 +172,8 @@ static struct client_vfuncs imap_urlauth_vfuncs = {
        imap_urlauth_client_auth_result,
        NULL,
        NULL,
-       NULL
+       NULL,
+       NULL,
 };
 
 static const struct login_binary imap_urlauth_login_binary = {
index f7941c2adeed75be00b19100c38193a2b631be23..867de35454291e3d5314da28fb10fc9b57cfe05a 100644 (file)
@@ -239,6 +239,14 @@ static void client_proxy_error(struct client *client, const char *text)
        client->v.proxy_error(client, text);
 }
 
+const char *client_proxy_get_state(struct client *client)
+{
+       if (client->v.proxy_get_state == NULL)
+               return dec2str(client->proxy_state);
+       else
+               return client->v.proxy_get_state(client);
+}
+
 void client_proxy_log_failure(struct client *client, const char *line)
 {
        string_t *str = t_str_new(128);
@@ -312,11 +320,11 @@ static void proxy_input(struct client *client)
                duration = ioloop_time - client->created;
                client_log_err(client, t_strdup_printf(
                        "proxy: Remote %s:%u disconnected: %s "
-                       "(state=%u, duration=%us)%s",
+                       "(state=%s, duration=%us)%s",
                        login_proxy_get_host(client->login_proxy),
                        login_proxy_get_port(client->login_proxy),
                        io_stream_get_disconnect_reason(input, NULL),
-                       client->proxy_state, duration,
+                       client_proxy_get_state(client), duration,
                        line == NULL ? "" : t_strdup_printf(
                                " - BUG: line not read: %s", line)));
                client_proxy_failed(client, TRUE);
index 9ca9f877340653aa3bda9a5d06ce5b9eb0be43e9..7096d2c1726753b4861ad0aa399e10ac54474421 100644 (file)
@@ -65,10 +65,10 @@ static void client_idle_disconnect_timeout(struct client *client)
                user_reason = "Timeout while finishing login.";
                destroy_reason = t_strdup_printf(
                        "proxy: Logging in to %s:%u timed out "
-                       "(state=%u, duration=%us)",
+                       "(state=%s, duration=%us)",
                        login_proxy_get_host(client->login_proxy),
                        login_proxy_get_port(client->login_proxy),
-                       client->proxy_state, secs);
+                       client_proxy_get_state(client), secs);
                client_log_err(client, destroy_reason);
        } else {
                user_reason = "Disconnected for inactivity.";
index 64c8856fa9171b8d2955045859d8e083f48089ec..9fc9ba05156690565622f58a5edb8ffecd12288d 100644 (file)
@@ -99,6 +99,7 @@ struct client_vfuncs {
        void (*proxy_reset)(struct client *client);
        int (*proxy_parse_line)(struct client *client, const char *line);
        void (*proxy_error)(struct client *client, const char *text);
+       const char *(*proxy_get_state)(struct client *client);
 };
 
 struct client {
@@ -252,6 +253,7 @@ int client_auth_read_line(struct client *client);
 void client_proxy_finish_destroy_client(struct client *client);
 void client_proxy_log_failure(struct client *client, const char *line);
 void client_proxy_failed(struct client *client, bool send_line);
+const char *client_proxy_get_state(struct client *client);
 
 void clients_notify_auth_connected(void);
 void client_destroy_oldest(void);
index c6e7904bbbe590f4e29ec45b54d403fcf0bb5a59..3401971f13288a4edf1f0cfcd5fa2ce33a09cf45 100644 (file)
@@ -282,9 +282,9 @@ proxy_log_connect_error(struct login_proxy *proxy)
                str_printfa(str, "connect(%s, %u) failed: %m",
                            proxy->host, proxy->port);
        } else {
-               str_printfa(str, "Login for %s:%u timed out in state=%u",
+               str_printfa(str, "Login for %s:%u timed out in state=%s",
                            proxy->host, proxy->port,
-                           proxy->client->proxy_state);
+                           client_proxy_get_state(proxy->client));
        }
        str_printfa(str, " (after %u secs",
                    (unsigned int)(ioloop_time - proxy->created.tv_sec));
index a88c6d19939fca1adac88bcbc4171fc7539b1f37..f262a5cdefd699a0f330f3a0bc17af848dbb6159 100644 (file)
@@ -311,7 +311,8 @@ static struct client_vfuncs pop3_client_vfuncs = {
        pop3_client_auth_result,
        pop3_proxy_reset,
        pop3_proxy_parse_line,
-       pop3_proxy_error
+       pop3_proxy_error,
+       NULL,
 };
 
 static const struct login_binary pop3_login_binary = {