summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2004-10-30 18:10:07 +0000
committerStef Walter <stef@memberwebs.com>2004-10-30 18:10:07 +0000
commit409ee41b2e979c1b48690a82839d622e1f6ab99b (patch)
tree15825beababdade348d1a9e8811f8fbb81e8a359
parentad408f3c5264ade2c9fad5d795dd8fb3f802f798 (diff)
Allow configuration of server keep alives (NOOPs). Default to none.
-rw-r--r--ChangeLog1
-rw-r--r--common/smtppass.c31
-rw-r--r--common/sppriv.h1
-rw-r--r--configure.in4
-rw-r--r--doc/clamsmtpd.conf3
-rw-r--r--doc/clamsmtpd.conf.57
6 files changed, 35 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index e9c29c8..95d9443 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
- Added CLIENT and SERVER variables to VirusAction script environment.
- Even better logging for network errors.
- Print out clamsmtp version in debug logs
+ - Allow configuration of server keep alives (NOOPs). Default to none
1.0
- Removed user option from startup script (use User config option)
diff --git a/common/smtppass.c b/common/smtppass.c
index 93bc9cb..5d25719 100644
--- a/common/smtppass.c
+++ b/common/smtppass.c
@@ -127,9 +127,6 @@ spthread_t;
#define LINE_TOO_LONG(l) ((l) >= (SP_LINE_LENGTH - 2))
-/* The amount interval at which to send NOOPS to server */
-#define INTERACTION_DELTA 10
-
/* -----------------------------------------------------------------------
* CONFIGURATION OPTIONS
*
@@ -146,6 +143,7 @@ spthread_t;
#define CFG_LISTENADDR "Listen"
#define CFG_TRANSPARENT "TransparentProxy"
#define CFG_DIRECTORY "TempDirectory"
+#define CFG_KEEPALIVES "KeepAlives"
#define CFG_USER "User"
#define CFG_PIDFILE "PidFile"
@@ -157,6 +155,7 @@ spthread_t;
#define DEFAULT_PORT 10025
#define DEFAULT_MAXTHREADS 64
#define DEFAULT_TIMEOUT 180
+#define DEFAULT_KEEPALIVES 0
/* -----------------------------------------------------------------------
* GLOBALS
@@ -206,6 +205,7 @@ void sp_init(const char* name)
g_state.debug_level = -1;
g_state.max_threads = DEFAULT_MAXTHREADS;
g_state.timeout.tv_sec = DEFAULT_TIMEOUT;
+ g_state.keepalives = DEFAULT_KEEPALIVES;
g_state.directory = _PATH_TMP;
g_state.name = name;
@@ -1138,13 +1138,16 @@ int sp_read_data(spctx_t* ctx, const char** data)
return -1;
};
- /*
- * During this time we're just reading from the client. If we haven't
- * had any interaction with the server recently then send something
- * to let it know we're still around.
- */
- if((ctx->server.last_action + INTERACTION_DELTA) < time(NULL))
- do_server_noop(ctx);
+ if(g_state.keepalives > 0)
+ {
+ /*
+ * During this time we're just reading from the client. If we haven't
+ * had any interaction with the server recently then send something
+ * to let it know we're still around.
+ */
+ if((ctx->server.last_action + g_state.keepalives) < time(NULL))
+ do_server_noop(ctx);
+ }
if(ctx->_crlf && strcmp(ctx->client.line, DATA_END_SIG) == 0)
return 0;
@@ -1587,6 +1590,14 @@ int sp_parse_option(const char* name, const char* value)
ret = 1;
}
+ else if(strcasecmp(CFG_KEEPALIVES, name) == 0)
+ {
+ g_state.keepalives = strtol(value, &t, 10);
+ if(*t || g_state.keepalives < 0)
+ errx(2, "invalid setting: " CFG_KEEPALIVES);
+ ret = 1;
+ }
+
else if(strcasecmp(CFG_OUTADDR, name) == 0)
{
if(sock_any_pton(value, &(g_state.outaddr), SANY_OPT_DEFPORT(25)) == -1)
diff --git a/common/sppriv.h b/common/sppriv.h
index cc6590a..e978107 100644
--- a/common/sppriv.h
+++ b/common/sppriv.h
@@ -47,6 +47,7 @@ typedef struct spstate
int debug_level; /* The level to print stuff to console */
int max_threads; /* Maximum number of threads to process at once */
struct timeval timeout; /* Timeout for communication */
+ int keepalives; /* Send server keep alives at this interval */
int transparent; /* Transparent proxying */
const char* directory; /* The temp directory */
const char* user; /* User to run as */
diff --git a/configure.in b/configure.in
index 757263c..26f30b6 100644
--- a/configure.in
+++ b/configure.in
@@ -36,8 +36,8 @@ dnl Nate Nielsen <nielsen@memberwebs.com>
dnl
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(clamsmtp, 1.0, nielsen@memberwebs.com)
-AM_INIT_AUTOMAKE(clamsmtp, 1.0)
+AC_INIT(clamsmtp, 1.0.90, nielsen@memberwebs.com)
+AM_INIT_AUTOMAKE(clamsmtp, 1.0.90)
LDFLAGS="$LDFLAGS -L/usr/local/lib"
CFLAGS="$CFLAGS -I/usr/local/include"
diff --git a/doc/clamsmtpd.conf b/doc/clamsmtpd.conf
index b42851a..2033171 100644
--- a/doc/clamsmtpd.conf
+++ b/doc/clamsmtpd.conf
@@ -19,6 +19,9 @@ OutAddress: 10026
# Amount of time (in seconds) to wait on network IO
#TimeOut: 180
+# Keep Alives (ie: NOOP's to server)
+#KeepAlives: 0
+
# Address to listen on (defaults to all local addresses on port 10025)
#Listen: 0.0.0.0:10025
diff --git a/doc/clamsmtpd.conf.5 b/doc/clamsmtpd.conf.5
index e481af9..7df06bc 100644
--- a/doc/clamsmtpd.conf.5
+++ b/doc/clamsmtpd.conf.5
@@ -82,6 +82,13 @@ on. See syntax of addresses below.
[ Default:
.Pa /var/run/clamav/clamd
]
+.It Ar KeepAlives
+On slow connections the server will sometimes timeout before
+.Nm
+is finished scanning the file. This option sends NOOP's to the server
+to keep the connection alive. Specify the number of seconds, or 0
+to disable.
+[ Default: 0 ]
.It Ar Listen
The address and port to listen for SMTP connections on. See syntax of
addresses below.