client.c revision 851e9036cb96ec72f433a491d47a0049d0cda3f8
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "buffer.h"
#include "hash.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "process-title.h"
#include "safe-memset.h"
#include "strescape.h"
#include "client.h"
#include "client-authenticate.h"
#include "ssl-proxy.h"
/* max. length of input command line (spec says 512) */
#define MAX_INBUF_SIZE 2048
/* Disconnect client after idling this many seconds */
#define CLIENT_LOGIN_IDLE_TIMEOUT 60
/* Disconnect client when it sends too many bad commands */
#define CLIENT_MAX_BAD_COMMANDS 10
/* When max. number of simultaneous connections is reached, few of the
oldest connections are disconnected. Since we have to go through the whole
client hash, it's faster if we disconnect multiple clients. */
#define CLIENT_DESTROY_OLDEST_COUNT 16
#endif
static struct hash_table *clients;
{
const char *host;
if (!verbose_proctitle || !process_per_connection)
return;
host = "??";
host));
}
{
}
{
int fd_ssl;
return TRUE;
}
if (!ssl_initialized) {
return TRUE;
}
/* must be removed before ssl_proxy_new(), since it may
io_add() the same fd. */
}
if (fd_ssl != -1) {
} else {
}
return TRUE;
}
{
return TRUE;
}
const char *args)
{
return FALSE;
}
{
case -2:
/* buffer full */
return FALSE;
case -1:
/* disconnected */
return FALSE;
default:
/* something was read */
return TRUE;
}
}
void client_input(void *context)
{
if (!client_read(client))
return;
args = "";
else
*args++ = '\0';
client->bad_counter = 0;
"Disconnected: Too many bad commands");
}
}
if (client_unref(client))
}
void *context)
{
struct pop3_client *const *destroy_clients;
count /= sizeof(struct pop3_client *);
for (i = 0; i < count; i++) {
i * sizeof(struct pop3_client *),
&client, sizeof(struct pop3_client *));
break;
}
}
}
static void client_destroy_oldest(void)
{
struct pop3_client *const *destroy_clients;
/* find the oldest clients and put them to destroy-buffer */
sizeof(struct pop3_client *) *
/* then kill them */
count /= sizeof(struct pop3_client *);
for (i = 0; i < count; i++) {
"Disconnected: Connection queue full");
}
}
{
struct pop3_client *client;
/* reached max. users count, kill few of the
oldest connections */
}
/* always use nonblocking I/O */
main_ref();
}
{
return;
}
}
{
}
{
return TRUE;
main_unref();
return FALSE;
}
{
}
{
const char *host;
host = "??";
}
void *context __attr_unused__)
{
}
{
}
unsigned int clients_get_count(void)
{
}
void *context __attr_unused__)
{
}
void clients_destroy_all(void)
{
}
void clients_init(void)
{
}
void clients_deinit(void)
{
}