login-proxy.c revision d5cebe7f98e63d4e2822863ef2faa4971e8b3a5d
/* Copyright (C) 2004 Timo Sirainen */
#include "common.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "hash.h"
#include "client-common.h"
#include "login-proxy.h"
#define MAX_PROXY_INPUT_SIZE 4096
#define OUTBUF_THRESHOLD 1024
struct login_proxy {
struct istream *server_input;
unsigned int port;
void *context;
unsigned int destroying:1;
};
static struct hash_table *login_proxies;
static void server_input(void *context)
{
unsigned char buf[OUTBUF_THRESHOLD];
/* client's output buffer is already quite full.
don't send more until we're below threshold. */
return;
}
if (ret > 0)
else if (ret < 0)
}
static void proxy_client_input(void *context)
{
unsigned char buf[OUTBUF_THRESHOLD];
/* proxy's output buffer is already quite full.
don't send more until we're below threshold. */
return;
}
if (ret > 0)
else if (ret < 0)
}
static int server_output(void *context)
{
return 1;
}
/* there's again space in proxy's output buffer, so we can
read more from client. */
}
return 1;
}
static int proxy_client_output(void *context)
{
return 1;
}
/* there's again space in client's output buffer, so we can
read more from proxy. */
}
return 1;
}
static void proxy_prelogin_input(void *context)
{
}
static void proxy_wait_connect(void *context)
{
int err;
if (err != 0) {
i_error("proxy: connect(%s, %u) failed: %s",
return;
}
/* connect successful */
}
struct login_proxy *
{
struct login_proxy *proxy;
int fd;
return NULL;
}
i_error("proxy(%s): %s is not a valid IP",
return NULL;
}
if (fd < 0) {
i_error("proxy(%s): connect(%s, %u) failed: %m",
return NULL;
}
return proxy;
}
{
if (proxy->destroying)
return;
/* detached proxy */
main_unref();
i_info("proxy(%s): disconnecting %s",
} else {
}
}
struct ostream *client_output)
{
const unsigned char *data;
/* send all pending client input to proxy and get rid of the stream */
if (size != 0)
/* from now on, just do dummy proxying */
if (login_proxies == NULL) {
}
main_ref();
}
void login_proxy_deinit(void)
{
struct hash_iterate_context *iter;
if (login_proxies == NULL)
return;
}