Anti-idle in OpenSSH client?
Tom Rudnick
tom at avatar.itc.nrcs.usda.gov
Tue Apr 8 02:34:44 EST 2003
Mandar-
Here's yet another patch for the same function. I posted this about 2yrs
ago. It applies against 2.5.1,... I can rediff it for 3.6.1 if you're
interested.
I had pretty much given up the push to get it (or something like it)
into the main code.
After the ClientAlive feature was added, it gave another way of doing
this, so I dropped it.
Let me know if the attached patch is useful or not, and if you'd like
a 3.6.1 version.
Thanks,
-Tom Rudnick
>
>
> Martin, Darren et al - thanks for the various patches :) They certainly
> fit my need..
>
> I hope one day some form of the anti-idle stuff makes it to the main
> distrib...
>
> - Mandar
>
> _______________________________________________
> openssh-unix-dev mailing list
> openssh-unix-dev at mindrot.org
> http://www.mindrot.org/mailman/listinfo/openssh-unix-dev
>
--
----------------/----------------------------------------------
Tom Rudnick | USDA Natural Resources Conservation Service
Fort Collins,CO | tom at avatar.itc.nrcs.usda.gov (970) 295-5427
** The 3rd Millennium started Jan 1, 2001. see: **
** http://aa.usno.navy.mil/AA/faq/docs/millennium.html **
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-------------- next part --------------
--- readconf.h 2001/03/11 01:49:20 1.21
+++ readconf.h 2001/03/23 21:47:36
@@ -61,6 +61,10 @@
int compression_level; /* Compression level 1 (fast) to 9
* (best). */
int keepalives; /* Set SO_KEEPALIVE. */
+ time_t noop_msg_interval; /* Number of seconds between
+ * SSH_MSG_IGNORE packets to keep
+ * firewall connections from
+ * timing out */
LogLevel log_level; /* Level for logging. */
int port; /* Port to connect. */
--- readconf.c 2001/03/22 01:24:05 1.42
+++ readconf.c 2001/03/23 21:47:37
@@ -110,7 +110,7 @@
oUsePrivilegedPort, oLogLevel, oCiphers, oProtocol, oMacs,
oGlobalKnownHostsFile2, oUserKnownHostsFile2, oPubkeyAuthentication,
oKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias,
- oPreferredAuthentications
+ oPreferredAuthentications, oNoopMsgInterval
} OpCodes;
/* Textual representations of the tokens. */
@@ -173,6 +173,7 @@
{ "numberofpasswordprompts", oNumberOfPasswordPrompts },
{ "loglevel", oLogLevel },
{ "preferredauthentications", oPreferredAuthentications },
+ { "noopmsginterval", oNoopMsgInterval },
{ NULL, 0 }
};
@@ -387,6 +388,10 @@
intptr = &options->keepalives;
goto parse_flag;
+ case oNoopMsgInterval:
+ intptr = &options->noop_msg_interval;
+ goto parse_int;
+
case oNumberOfPasswordPrompts:
intptr = &options->number_of_password_prompts;
goto parse_int;
@@ -707,6 +712,7 @@
options->strict_host_key_checking = -1;
options->compression = -1;
options->keepalives = -1;
+ options->noop_msg_interval = -1;
options->compression_level = -1;
options->port = -1;
options->connection_attempts = -1;
@@ -791,6 +797,8 @@
options->compression = 0;
if (options->keepalives == -1)
options->keepalives = 1;
+ if (options->noop_msg_interval == -1)
+ options->noop_msg_interval = 0;
if (options->compression_level == -1)
options->compression_level = 6;
if (options->port == -1)
--- clientloop.c 2001/03/06 03:34:40 1.36
+++ clientloop.c 2001/03/23 21:47:37
@@ -365,6 +365,10 @@
client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
int *maxfdp)
{
+ struct timeval tv = {0};
+ tv.tv_sec = options.noop_msg_interval;
+ /* Send a noop message at this frequency as a keepalive. */
+
/* Add any selections by the channel mechanism. */
channel_prepare_select(readsetp, writesetp, maxfdp);
@@ -403,7 +407,8 @@
* SSH_MSG_IGNORE packet when the timeout expires.
*/
- if (select((*maxfdp)+1, *readsetp, *writesetp, NULL, NULL) < 0) {
+ switch (select((*maxfdp)+1, *readsetp, *writesetp, NULL, ((tv.tv_sec)?(&tv):NULL))) {
+ case -1: {
char buf[100];
/*
@@ -420,7 +425,24 @@
snprintf(buf, sizeof buf, "select: %s\r\n", strerror(errno));
buffer_append(&stderr_buffer, buf, strlen(buf));
quit_pending = 1;
- }
+
+ }
+ break;
+
+ case 0:
+ /* Send a keepalive packet (SSH_MSG_IGNORE crashes
+ * some servers...).
+ */
+ if(compat20)
+ packet_start(SSH2_MSG_IGNORE);
+ else
+ packet_start(SSH_MSG_IGNORE);
+ packet_send();
+ break;
+
+ default:
+ break;
+ }
}
void
More information about the openssh-unix-dev
mailing list