1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -05:00

Introduce a new 'Interactor' trait.

This trait will be implemented by anything that wants to display
interactive prompts or notifications to the user in the course of
setting up a network connection, _or_ anything that wants to make a
network connection whose proxy setup might in turn need to do that.

To begin with, that means every Backend that makes network connections
at all must be an Interactor, because any of those network connections
might be proxied via an SSH jump host which might need to interact
with the user.

I'll fill in the contents of this trait over the next few commits, to
keep the patches comprehensible. For the moment, I've just introduced
the trait, set up implementations of it in the five network backends,
and given it a single 'description' method.

The previous 'description' methods of Backend and Plug are now
removed, and their work is done by the new Interactor method instead.
(I changed my mind since last week about where that should best live.)
This isn't too much of an upheaval, fortunately, because I hadn't got
round yet to committing anything that used those methods!
This commit is contained in:
Simon Tatham
2021-10-30 17:16:08 +01:00
parent 74a0be9c56
commit 44db74ec51
8 changed files with 110 additions and 115 deletions

View File

@ -39,6 +39,7 @@ struct Ssh {
Plug plug;
Backend backend;
Interactor interactor;
Ldisc *ldisc;
LogContext *logctx;
@ -718,24 +719,21 @@ static char *ssh_close_warn_text(Backend *be)
return msg;
}
static char *ssh_plug_description(Plug *plug)
{
Ssh *ssh = container_of(plug, Ssh, plug);
return dupstr(ssh->description);
}
static char *ssh_backend_description(Backend *backend)
{
Ssh *ssh = container_of(backend, Ssh, backend);
return dupstr(ssh->description);
}
static const PlugVtable Ssh_plugvt = {
.log = ssh_socket_log,
.closing = ssh_closing,
.receive = ssh_receive,
.sent = ssh_sent,
.description = ssh_plug_description,
};
static char *ssh_description(Interactor *itr)
{
Ssh *ssh = container_of(itr, Ssh, interactor);
return dupstr(ssh->description);
}
static const InteractorVtable Ssh_interactorvt = {
.description = ssh_description,
};
/*
@ -940,6 +938,8 @@ static char *ssh_init(const BackendVtable *vt, Seat *seat,
ssh->term_height = conf_get_int(ssh->conf, CONF_height);
ssh->backend.vt = vt;
ssh->interactor.vt = &Ssh_interactorvt;
ssh->backend.interactor = &ssh->interactor;
*backend_handle = &ssh->backend;
ssh->bare_connection = (vt->protocol == PROT_SSHCONN);
@ -1264,7 +1264,6 @@ const BackendVtable ssh_backend = {
.cfg_info = ssh_cfg_info,
.test_for_upstream = ssh_test_for_upstream,
.close_warn_text = ssh_close_warn_text,
.description = ssh_backend_description,
.id = "ssh",
.displayname_tc = "SSH",
.displayname_lc = "SSH", /* proper name, so capitalise it anyway */
@ -1291,7 +1290,6 @@ const BackendVtable sshconn_backend = {
.cfg_info = ssh_cfg_info,
.test_for_upstream = ssh_test_for_upstream,
.close_warn_text = ssh_close_warn_text,
.description = ssh_backend_description,
.id = "ssh-connection",
.displayname_tc = "Bare ssh-connection",
.displayname_lc = "bare ssh-connection",