client.c revision 66251e6ab31e5cc153fe5cae608e416dacafe9cd
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "hash.h"
#include "iobuffer.h"
#include "client.h"
#include "client-authenticate.h"
#include "ssl-proxy.h"
#include <syslog.h>
/* Disconnect client after idling this many seconds */
#define CLIENT_LOGIN_IDLE_TIMEOUT 60
/* 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
{
const char *capability;
" LOGINDISABLED" : "",
NULL);
return TRUE;
}
{
#ifdef HAVE_SSL
int fd_ssl;
return TRUE;
}
if (fd_ssl != -1) {
} else {
}
#else
#endif
return TRUE;
}
{
return TRUE;
}
{
return TRUE;
}
{
case -2:
/* buffer full */
return FALSE;
case -1:
/* disconnected */
return FALSE;
default:
/* something was read */
return TRUE;
}
}
static char *get_next_arg(char **line)
{
char *start;
int quoted;
if (**line == '"') {
(*line)++;
(*line)++;
(*line)++;
}
if (**line == '"')
*(*line)++ = '\0';
} else {
(*line)++;
if (**line == ' ')
*(*line)++ = '\0';
}
return start;
}
{
char *cmd;
}
return cmd_capability(client);
return cmd_starttls(client);
return cmd_logout(client);
return FALSE;
}
{
char *line;
if (!client_read(client))
return;
/* split the arguments, make sure we have at
least tag + command */
/* error */
"received by server.");
}
}
if (client_unref(client))
}
void *user_data)
{
int i;
for (i = 0; i < CLIENT_DESTROY_OLDEST_COUNT; i++) {
if (destroy_clients[i] == NULL ||
sizeof(Client *) *
(CLIENT_DESTROY_OLDEST_COUNT - i-1));
destroy_clients[i] = client;
break;
}
}
}
static void client_destroy_oldest(void)
{
int i;
for (i = 0; i < CLIENT_DESTROY_OLDEST_COUNT; i++) {
"Disconnected: Connection queue full");
}
}
{
/* reached max. users count, kill few of the
oldest connections */
}
IO_PRIORITY_DEFAULT, 8192);
IO_PRIORITY_DEFAULT, 1024);
return client;
}
{
}
}
{
}
{
return TRUE;
return FALSE;
}
{
}
{
}
{
char host[MAX_IP_LEN];
host[0] = '\0';
}
void *user_data __attr_unused__)
{
}
}
{
}
void clients_init(void)
{
}
void *user_data __attr_unused__)
{
}
void clients_deinit(void)
{
}