TELNET_KEEPALIVE feature
authorAri Johnson <ari@theari.com>
Thu, 24 Sep 2015 21:19:59 +0000 (17:19 -0400)
committerAri Johnson <ari@theari.com>
Thu, 24 Sep 2015 21:19:59 +0000 (17:19 -0400)
options.h.dist
src/bsd.c

index 4e01b875404cc9801f9e900302123412529ec17f..f2908c8d50dd2d58c734f5b10d4ca38db478a899 100644 (file)
 /* 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 /* */
 
index e260e9909aba2c0ba205b117bf75da0ce49c7733..39c81c1f4d001d59987ece096873ee7b276f26a0 100644 (file)
--- 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);