From 3e31a807af42c07beebc539a3efa7476ba1ef096 Mon Sep 17 00:00:00 2001 From: Ari Johnson Date: Thu, 24 Sep 2015 17:19:59 -0400 Subject: [PATCH] TELNET_KEEPALIVE feature --- options.h.dist | 6 ++++++ src/bsd.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/options.h.dist b/options.h.dist index 4e01b87..f2908c8 100644 --- a/options.h.dist +++ b/options.h.dist @@ -153,6 +153,12 @@ /* These are options specific to CobraMUSH. */ +/* Automatic keepalive for telnet-enabled connections */ +#define TELNET_KEEPALIVE /* */ + +/* Keepalive timer interval (in seconds) */ +#define KEEPALIVE_INTERVAL 300 + /* Colored WHO */ #define COLOREDWHO /* */ diff --git a/src/bsd.c b/src/bsd.c index e260e99..39c81c1 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -4771,6 +4771,19 @@ inactivity_check(void) back, the client probably doesn't understand them */ if ((d->conn_flags & CONN_TELNET_QUERY) && idle_for > 60) d->conn_flags &= ~CONN_TELNET_QUERY; + +#ifndef COMPILE_CONSOLE +#ifdef TELNET_KEEPALIVE + if (idle_for && !(idle_for % KEEPALIVE_INTERVAL) && + (d->conn_flags & CONN_TELNET)) { + tbuf[0] = IAC; + tbuf[1] = NOP; + tbuf[2] = '\0'; + queue_newwrite(d, (unsigned char *) tbuf, 2); + } +#endif /* TELNET_KEEPALIVE */ +#endif /* !COMPILE_CONSOLE */ + if(d->connected && GoodObject(d->player) && ((a = atr_get(d->player, "IDLE_TIMEOUT"))!=NULL)) { memset(tbuf, '\0', BUFFER_LEN); strncpy(tbuf, atr_value(a), BUFFER_LEN-1); -- 2.30.2