login-proxy.c revision ba90e657bc68a72ab3b3021e2f4a874fac9965ba
/* Copyright (C) 2004 Timo Sirainen */
#include "common.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "safe-memset.h"
#include "hash.h"
#include "client-common.h"
#include "login-proxy.h"
#define MAX_INBUF_SIZE 4096
#define OUTBUF_THRESHOLD 1024
struct login_proxy {
unsigned int port;
};
static struct hash_table *login_proxies;
static void proxy_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 void proxy_output(void *context)
{
return;
}
/* there's again space in proxy's output buffer, so we can
read more from client. */
}
}
static void proxy_client_output(void *context)
{
return;
}
/* there's again space in client's output buffer, so we can
read more from proxy. */
}
}
static void proxy_prelogin_input(void *context)
{
unsigned char buf[1024];
if (ret < 0) {
/* disconnected */
return;
}
/* we just want to eat away the first banner line. be dummy and don't
check any errors, so we don't need any IMAP/POP3-specific things
here (except for assuming the banner line..) */
return;
/* send LOGIN command */
/* from now on, just do dummy proxying */
}
static void proxy_wait_connect(void *context)
{
int err;
if (err != 0) {
i_error("proxy: connect(%s, %u) failed: %s",
return;
}
/* initialize proxy's streams */
}
{
struct login_proxy *proxy;
int fd;
return -1;
}
i_error("proxy(%s): %s is not a valid IP",
return -1;
}
if (fd < 0) {
i_error("proxy(%s): connect(%s, %u) failed: %m",
return -1;
}
/* move client fd */
if (login_proxies == NULL) {
}
main_ref();
return 0;
}
{
main_unref();
}
}
void login_proxy_deinit(void)
{
struct hash_iterate_context *iter;
if (login_proxies == NULL)
return;
}