1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 11:32:48 -05:00

Non-SSH network backends: handle PLUGLOG_CONNECT_SUCCESS.

All four of the other network-protocol backends (Raw, Telnet, rlogin
and SUPDUP) now have a 'socket_connected' flag, which starts off false
and is set to true when (if) their Socket signals that the connection
attempt has succeeded.

This field is used to tell backend_socket_log whether the session has
started yet (hence, whether it should still be logging messages from
the proxy). This replaces various ad-hoc answers to that question in
each backend, which were the best I could do when sockets didn't
notify connection success. Now they do, we can do it properly.

Also, the new flag controls the answer to each backend's sendok()
method, which makes them all satisfy a new policy rule: no backend
shall return true from sendok() while its network connection attempt
is still ongoing.

(Rationale: the network connection attempt may in future involve a
proxy implementation interacting with the user via the terminal, and
it can't do that if the backend is already consuming all the terminal
input.)
This commit is contained in:
Simon Tatham
2021-09-13 12:00:01 +01:00
parent 6b1154cc5b
commit 0b099b6a6f
5 changed files with 37 additions and 20 deletions

View File

@ -171,6 +171,7 @@ static const struct Opt *const opts[] = {
typedef struct Telnet Telnet;
struct Telnet {
Socket *s;
bool socket_connected;
bool closed_on_socket_error;
Seat *seat;
@ -186,7 +187,6 @@ struct Telnet {
bool in_synch;
int sb_opt;
strbuf *sb_buf;
bool session_started;
enum {
TOP_LEVEL, SEENIAC, SEENWILL, SEENWONT, SEENDO, SEENDONT,
@ -619,7 +619,9 @@ static void telnet_log(Plug *plug, PlugLogType type, SockAddr *addr, int port,
Telnet *telnet = container_of(plug, Telnet, plug);
backend_socket_log(telnet->seat, telnet->logctx, type, addr, port,
error_msg, error_code, telnet->conf,
telnet->session_started);
telnet->socket_connected);
if (type == PLUGLOG_CONNECT_SUCCESS)
telnet->socket_connected = true;
}
static void telnet_closing(Plug *plug, const char *error_msg, int error_code,
@ -654,7 +656,6 @@ static void telnet_receive(
Telnet *telnet = container_of(plug, Telnet, plug);
if (urgent)
telnet->in_synch = true;
telnet->session_started = true;
do_telnet_read(telnet, data, len);
}
@ -699,6 +700,7 @@ static char *telnet_init(const BackendVtable *vt, Seat *seat,
telnet->backend.vt = vt;
telnet->conf = conf_copy(conf);
telnet->s = NULL;
telnet->socket_connected = false;
telnet->closed_on_socket_error = false;
telnet->echoing = true;
telnet->editing = true;
@ -711,7 +713,6 @@ static char *telnet_init(const BackendVtable *vt, Seat *seat,
telnet->state = TOP_LEVEL;
telnet->ldisc = NULL;
telnet->pinger = NULL;
telnet->session_started = true;
*backend_handle = &telnet->backend;
/*
@ -1001,8 +1002,8 @@ static bool telnet_connected(Backend *be)
static bool telnet_sendok(Backend *be)
{
/* Telnet *telnet = container_of(be, Telnet, backend); */
return true;
Telnet *telnet = container_of(be, Telnet, backend);
return telnet->socket_connected;
}
static void telnet_unthrottle(Backend *be, size_t backlog)