From: Ari Johnson Date: Thu, 24 Sep 2015 21:19:59 +0000 (-0400) Subject: TELNET_KEEPALIVE feature X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=3e31a807af42c07beebc539a3efa7476ba1ef096;p=cobramush.git TELNET_KEEPALIVE feature --- 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);