auth-penalty.c revision 183bea41fa640dc8117f3eb45ff935cd81377a84
/* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "network.h"
#include "crc32.h"
#include "master-service.h"
#include "anvil-client.h"
#include "auth-request.h"
#include "auth-penalty.h"
#include <stdio.h>
/* We don't want IPv6 hosts being able to flood our penalty
tracking with tons of different IPs. */
#define PENALTY_IPV6_MASK_BITS 48
struct auth_penalty_request {
struct auth_request *auth_request;
struct anvil_client *client;
};
struct auth_penalty {
struct anvil_client *client;
unsigned int disabled:1;
};
{
struct auth_penalty *penalty;
else {
"PENALTY-SET-EXPIRE-SECS\t%u", AUTH_PENALTY_TIMEOUT));
}
return penalty;
}
{
}
unsigned int auth_penalty_to_secs(unsigned int penalty)
{
unsigned int i, secs = AUTH_PENALTY_INIT_SECS;
for (i = 0; i < penalty; i++)
secs *= 2;
}
{
unsigned int penalty = 0;
unsigned long last_penalty = 0;
unsigned int secs, drop_penalty;
/* internal failure. */
/* we probably didn't have permissions to reconnect
back to anvil. need to restart ourself. */
}
} else {
/* time moved backwards? */
}
/* update penalty. */
while (penalty > 0) {
break;
drop_penalty--;
penalty--;
}
}
}
static const char *
{
#ifdef HAVE_IPV6
if (IPADDR_IS_V6(&ip)) {
}
#endif
return net_ip2addr(&ip);
}
struct auth_request *auth_request,
{
struct auth_penalty_request *request;
const char *ident;
ident = auth_penalty_get_ident(auth_request);
callback(0, auth_request);
return;
}
T_BEGIN {
t_strdup_printf("PENALTY-GET\t%s", ident),
} T_END;
}
static unsigned int
{
auth_request->user);
}
{
const char *ident;
ident = auth_penalty_get_ident(auth_request);
return;
if (value > AUTH_PENALTY_MAX_PENALTY) {
/* even if the actual value doesn't change, the last_change
timestamp does. */
}
T_BEGIN {
const char *cmd;
unsigned int checksum;
} T_END;
}