Skip to content

Commit

Permalink
pop3-login: Log proxy state as human-readable string.
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed Mar 9, 2017
1 parent b4bf604 commit d77f679
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/pop3-login/client.c
Expand Up @@ -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 = {
Expand Down
4 changes: 3 additions & 1 deletion src/pop3-login/client.h
Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions src/pop3-login/pop3-proxy.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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];
}
1 change: 1 addition & 0 deletions src/pop3-login/pop3-proxy.h
Expand Up @@ -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

0 comments on commit d77f679

Please sign in to comment.