From: Ari Johnson Date: Fri, 25 Sep 2015 03:34:31 +0000 (-0400) Subject: Make telnet keepalive functionality a @configurable setting X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=612e3f355148d27213f8f2682d23f461baf72008;p=cobramush.git Make telnet keepalive functionality a @configurable setting --- diff --git a/hdrs/conf.h b/hdrs/conf.h index 31220eb..d62880d 100644 --- a/hdrs/conf.h +++ b/hdrs/conf.h @@ -159,6 +159,7 @@ struct options_table { int idle_time; /** Time for the system to consider player 'idle' used in conjuntion with @AUNIDLE */ int unconnected_idle_timeout; /**< Maximum idle time for connections without dbrefs, in minutes */ int keepalive_timeout; /**< Number of seconds between TCP keepalive pings */ + int telnet_keepalive_interval; /**< Number of seconds between telnet NOP transmissions */ int dump_interval; /**< Interval between database dumps, in seconds */ char dump_message[256]; /**< Message shown at start of nonforking dump */ char dump_complete[256]; /**< Message shown at end of nonforking dump */ @@ -396,6 +397,7 @@ int cf_time(const char *opt, const char *val, void *loc, int maxval, #define PURGE_INTERVAL (options.purge_interval) #define DBCK_INTERVAL (options.dbck_interval) +#define TELNET_KEEPALIVE_INTERVAL (options.telnet_keepalive_interval) #define MAX_PARENTS (options.max_parents) #define MAX_DEPTH (options.max_depth) #define MAX_PENNIES (options.max_pennies) diff --git a/hdrs/dbdefs.h b/hdrs/dbdefs.h index cfd6a94..80d338a 100644 --- a/hdrs/dbdefs.h +++ b/hdrs/dbdefs.h @@ -154,6 +154,7 @@ extern dbref first_free; /* pointer to free list */ #define Halted(x) (has_flag_by_name(x, "HALT", NOTYPE)) #define Haven(x) (has_flag_by_name(x, "HAVEN", NOTYPE)) #define Inherit(x) (has_flag_by_name(x, "INHERIT", TYPE_THING|TYPE_EXIT|TYPE_ROOM)) +#define Keepalive(x) (has_flag_by_name(x, "KEEPALIVE", TYPE_PLAYER)) #define Light(x) (has_flag_by_name(x, "LIGHT", NOTYPE)) #define LinkOk(x) (has_flag_by_name(x, "LINK_OK", NOTYPE)) #define Loud(x) (has_flag_by_name(x, "LOUD", NOTYPE)) diff --git a/options.h.dist b/options.h.dist index f2908c8..4e01b87 100644 --- a/options.h.dist +++ b/options.h.dist @@ -153,12 +153,6 @@ /* 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 39c81c1..ec20b63 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -4773,15 +4773,15 @@ inactivity_check(void) d->conn_flags &= ~CONN_TELNET_QUERY; #ifndef COMPILE_CONSOLE -#ifdef TELNET_KEEPALIVE - if (idle_for && !(idle_for % KEEPALIVE_INTERVAL) && - (d->conn_flags & CONN_TELNET)) { + if (TELNET_KEEPALIVE_INTERVAL && idle_for && + !(idle_for % TELNET_KEEPALIVE_INTERVAL) && + (d->conn_flags & CONN_TELNET) && + Keepalive(d->player)) { 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)) { diff --git a/src/conf.c b/src/conf.c index 0e71f63..026ea53 100644 --- a/src/conf.c +++ b/src/conf.c @@ -297,6 +297,8 @@ COBRA_CONF conftable[] = { , {"keepalive_timeout", cf_time, &options.keepalive_timeout, 10000, 0, "limits"} , + {"telnet_keepalive_interval", cf_time, &options.telnet_keepalive_interval, 10000, 0, "limits"} + , {"whisper_loudness", cf_int, &options.whisper_loudness, 100, 0, "limits"} , {"starting_quota", cf_int, &options.starting_quota, 10000, 0, "limits"} @@ -1076,6 +1078,7 @@ conf_default_set(void) options.idle_time = 0; options.unconnected_idle_timeout = 300; options.keepalive_timeout = 300; + options.telnet_keepalive_interval = 300; options.dump_interval = 3601; strcpy(options.dump_message, T("GAME: Dumping database. Game may freeze for a minute")); diff --git a/src/flags.c b/src/flags.c index 0691252..6a0d8f9 100644 --- a/src/flags.c +++ b/src/flags.c @@ -771,6 +771,7 @@ flag_add_additional(void) add_flag("PARALYZED", '\0', TYPE_PLAYER, F_PRIVILEGE, F_PRIVILEGE); add_flag("RPAPPROVED", '\0', TYPE_THING, F_PRIVILEGE, F_PRIVILEGE); #endif + add_flag("KEEPALIVE", '\0', TYPE_PLAYER, F_ANY, F_ANY); if ((f = match_flag("TERSE"))) f->type |= TYPE_THING; if ((f = match_flag("PUPPET")))