1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-02 03:52:49 -05:00

Option to log proxy setup diagnostics to the terminal.

It has three settings: on, off, and 'only until session starts'. The
idea of the last one is that if you use something like 'ssh -v' as
your proxy command, you probably wanted to see the initial SSH
connection-setup messages while you were waiting to see if the
connection would be set up successfully at all, but probably _didn't_
want a slew of diagnostics from rekeys disrupting your terminal in
mid-emacs once the session had got properly under way.

Default is off, to avoid startling people used to the old behaviour. I
wonder if I should have set it more aggressively, though.
This commit is contained in:
Simon Tatham
2015-11-22 14:33:28 +00:00
parent 297efff303
commit 7c65b9c57a
10 changed files with 63 additions and 11 deletions

View File

@ -2,12 +2,16 @@
* be_misc.c: helper functions shared between main network backends.
*/
#include <assert.h>
#include <string.h>
#define DEFINE_PLUG_METHOD_MACROS
#include "putty.h"
#include "network.h"
void backend_socket_log(void *frontend, int type, SockAddr addr, int port,
const char *error_msg, int error_code)
const char *error_msg, int error_code, Conf *conf,
int session_started)
{
char addrbuf[256], *msg;
@ -27,7 +31,22 @@ void backend_socket_log(void *frontend, int type, SockAddr addr, int port,
case 2:
/* Proxy-related log messages have their own identifying
* prefix already, put on by our caller. */
msg = dupstr(error_msg);
{
int len, log_to_term;
/* Suffix \r\n temporarily, so we can log to the terminal. */
msg = dupprintf("%s\r\n", error_msg);
len = strlen(msg);
assert(len >= 2);
log_to_term = conf_get_int(conf, CONF_proxy_log_to_term);
if (log_to_term == AUTO)
log_to_term = session_started ? FORCE_OFF : FORCE_ON;
if (log_to_term == FORCE_ON)
from_backend(frontend, TRUE, msg, len);
msg[len-2] = '\0'; /* remove the \r\n again */
}
break;
default:
msg = NULL; /* shouldn't happen, but placate optimiser */