mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12:48 -05:00
New Seat method, notify_session_started().
This is called by the backend to notify the Seat that the connection has progressed to the point where the main session channel (i.e. the thing that would typically correspond to the client's stdin/stdout) has been successfully set up. The only Seat that implements this method nontrivially is the one in SshProxy, which uses it as an indication that the proxied connection to the remote host has succeeded, and sends the PLUGLOG_CONNECT_SUCCESS notification to its own Plug. Hence, the only backends that need to implement it at the moment are the two SSH-shaped backends (SSH proper and bare-connection / psusan). For other backends, it's not always obvious what 'main session channel' would even mean, or whether it means anything very useful; so I've also introduced a backend flag indicating whether the backend is expecting to call that method at all, so as not to have to spend pointless effort on defining an arbitrary meaning for it in other contexts. So a lot of this patch is just introducing the new method and putting its trivial do-nothing implementation into all the existing Seat methods. The interesting parts happen in ssh/mainchan.c (which actually calls it), and sshproxy.c (which does something useful in response).
This commit is contained in:
17
sshproxy.c
17
sshproxy.c
@ -66,6 +66,7 @@ typedef struct SshProxy {
|
||||
bool rcvd_eof_ssh_to_socket, sent_eof_ssh_to_socket;
|
||||
|
||||
SockAddr *addr;
|
||||
int port;
|
||||
|
||||
/* Traits implemented: we're a Socket from the point of view of
|
||||
* the client connection, and a Seat from the POV of the SSH
|
||||
@ -245,6 +246,12 @@ static void try_send_ssh_to_socket(void *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
static void sshproxy_notify_session_started(Seat *seat)
|
||||
{
|
||||
SshProxy *sp = container_of(seat, SshProxy, seat);
|
||||
plug_log(sp->plug, PLUGLOG_CONNECT_SUCCESS, sp->addr, sp->port, NULL, 0);
|
||||
}
|
||||
|
||||
static size_t sshproxy_output(Seat *seat, bool is_stderr,
|
||||
const void *data, size_t len)
|
||||
{
|
||||
@ -431,6 +438,7 @@ static const SeatVtable SshProxy_seat_vt = {
|
||||
.eof = sshproxy_eof,
|
||||
.sent = sshproxy_sent,
|
||||
.get_userpass_input = sshproxy_get_userpass_input,
|
||||
.notify_session_started = sshproxy_notify_session_started,
|
||||
.notify_remote_exit = nullseat_notify_remote_exit,
|
||||
.notify_remote_disconnect = sshproxy_notify_remote_disconnect,
|
||||
.connection_fatal = sshproxy_connection_fatal,
|
||||
@ -470,6 +478,7 @@ Socket *sshproxy_new_connection(SockAddr *addr, const char *hostname,
|
||||
bufchain_init(&sp->ssh_to_socket);
|
||||
|
||||
sp->addr = addr;
|
||||
sp->port = port;
|
||||
|
||||
sp->conf = conf_new();
|
||||
/* Try to treat proxy_hostname as the title of a saved session. If
|
||||
@ -513,6 +522,14 @@ Socket *sshproxy_new_connection(SockAddr *addr, const char *hostname,
|
||||
return &sp->sock;
|
||||
}
|
||||
|
||||
/*
|
||||
* We also expect that the backend will announce a willingness to
|
||||
* notify us that the session has started. Any backend providing
|
||||
* NC_HOST should also provide this.
|
||||
*/
|
||||
assert(backvt->flags & BACKEND_NOTIFIES_SESSION_START &&
|
||||
"Backend provides NC_HOST without SESSION_START!");
|
||||
|
||||
/*
|
||||
* Turn off SSH features we definitely don't want. It would be
|
||||
* awkward and counterintuitive to have the proxy SSH connection
|
||||
|
Reference in New Issue
Block a user