client.c revision eb05765777cf968a7fb784602c310a8a418156a1
/* 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 "auth-client.h"
#include "ssl-proxy.h"
#include "hostpid.h"
#include "imem.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 *addr;
if (!verbose_proctitle || !process_per_connection)
return;
addr = "??";
addr));
}
{
}
{
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))
}
static void client_destroy_oldest(void)
{
struct hash_iterate_context *iter;
int i;
/* find the oldest clients and put them to destroy-buffer */
for (i = 0; i < CLIENT_DESTROY_OLDEST_COUNT; i++) {
if (destroy_buf[i] == NULL ||
/* @UNSAFE */
sizeof(destroy_buf) -
(i+1) * sizeof(struct pop3_client *));
destroy_buf[i] = client;
break;
}
}
}
/* then kill them */
for (i = 0; i < CLIENT_DESTROY_OLDEST_COUNT; i++) {
if (destroy_buf[i] == NULL)
break;
"Disconnected: Connection queue full");
}
}
{
return NULL;
}
{
}
{
struct pop3_client *client;
const char *addr;
/* reached max. users count, kill few of the
oldest connections */
}
/* always use nonblocking I/O */
main_ref();
if (client->auth_connected)
}
{
return;
}
}
}
{
}
{
return TRUE;
main_unref();
return FALSE;
}
{
}
{
const char *addr;
addr = "??";
}
{
}
{
struct hash_iterate_context *iter;
}
}
unsigned int clients_get_count(void)
{
}
void clients_notify_auth_connected(void)
{
struct hash_iterate_context *iter;
if (!client->auth_connected) {
}
}
}
void clients_destroy_all(void)
{
struct hash_iterate_context *iter;
}
}
void clients_init(void)
{
}
void clients_deinit(void)
{
}