summaryrefslogtreecommitdiff
path: root/common/smtppass.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/smtppass.c')
-rw-r--r--common/smtppass.c31
1 files changed, 21 insertions, 10 deletions
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)