From 7a690778e2d288338c66a2a7f70efa9a85578312 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 9 Mar 2017 10:46:36 -0500 Subject: [PATCH] pop3-login: Log proxy state as human-readable string. --- src/pop3-login/client.c | 2 +- src/pop3-login/client.h | 4 +++- src/pop3-login/pop3-proxy.c | 11 +++++++++++ src/pop3-login/pop3-proxy.h | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/pop3-login/client.c b/src/pop3-login/client.c index f262a5cdef..a1514e8731 100644 --- a/src/pop3-login/client.c +++ b/src/pop3-login/client.c @@ -312,7 +312,7 @@ static struct client_vfuncs pop3_client_vfuncs = { pop3_proxy_reset, pop3_proxy_parse_line, pop3_proxy_error, - NULL, + pop3_proxy_get_state, }; static const struct login_binary pop3_login_binary = { diff --git a/src/pop3-login/client.h b/src/pop3-login/client.h index 37653750af..f92f70ad00 100644 --- a/src/pop3-login/client.h +++ b/src/pop3-login/client.h @@ -10,7 +10,9 @@ enum pop3_proxy_state { POP3_PROXY_STARTTLS, POP3_PROXY_XCLIENT, POP3_PROXY_LOGIN1, - POP3_PROXY_LOGIN2 + POP3_PROXY_LOGIN2, + + POP3_PROXY_STATE_COUNT }; struct pop3_client { diff --git a/src/pop3-login/pop3-proxy.c b/src/pop3-login/pop3-proxy.c index f823dce2e0..0079488c8c 100644 --- a/src/pop3-login/pop3-proxy.c +++ b/src/pop3-login/pop3-proxy.c @@ -12,6 +12,10 @@ #include "client.h" #include "pop3-proxy.h" +static const char *pop3_proxy_state_names[POP3_PROXY_STATE_COUNT] = { + "banner", "starttls", "xclient", "login1", "login2" +}; + static void proxy_free_password(struct client *client) { if (client->proxy_password == NULL) @@ -216,6 +220,8 @@ int pop3_proxy_parse_line(struct client *client, const char *line) client_proxy_finish_destroy_client(client); return 1; + case POP3_PROXY_STATE_COUNT: + i_unreached(); } /* Login failed. Pass through the error message to client. @@ -259,3 +265,8 @@ void pop3_proxy_error(struct client *client, const char *text) { client_send_reply(client, POP3_CMD_REPLY_ERROR, text); } + +const char *pop3_proxy_get_state(struct client *client) +{ + return pop3_proxy_state_names[client->proxy_state]; +} diff --git a/src/pop3-login/pop3-proxy.h b/src/pop3-login/pop3-proxy.h index a60784b651..b6758d5484 100644 --- a/src/pop3-login/pop3-proxy.h +++ b/src/pop3-login/pop3-proxy.h @@ -5,5 +5,6 @@ void pop3_proxy_reset(struct client *client); int pop3_proxy_parse_line(struct client *client, const char *line); void pop3_proxy_error(struct client *client, const char *text); +const char *pop3_proxy_get_state(struct client *client); #endif -- 2.47.3