mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-08 08:58:00 +00:00
Send PLUGLOG_CONNECT_SUCCESS in proxied socket types.
Now the non-SSH backends critically depend on it, it's important not to forget to send it, for any socket type that's going to be used for any of those backends. But ProxySocket, and the Unix and Windows 'socket' types wrapping pipes to local subprocesses, were not doing so. Some of these socket types don't have a SockAddr available to represent the destination host. (Sometimes the concept isn't even meaningful). Therefore, I've also expanded the semantics of PLUGLOG_CONNECT_SUCCESS so that the addr parameter is allowed to be NULL, and invented a noncommittal fallback version of the log message in that situation.
This commit is contained in:
parent
6defb2b3a0
commit
8f5e9a4f8d
@ -29,7 +29,10 @@ void backend_socket_log(Seat *seat, LogContext *logctx,
|
||||
msg = dupprintf("Failed to connect to %s: %s", addrbuf, error_msg);
|
||||
break;
|
||||
case PLUGLOG_CONNECT_SUCCESS:
|
||||
sk_getaddr(addr, addrbuf, lenof(addrbuf));
|
||||
if (addr)
|
||||
sk_getaddr(addr, addrbuf, lenof(addrbuf));
|
||||
else /* fallback if address unavailable */
|
||||
sprintf(addrbuf, "remote host");
|
||||
msg = dupprintf("Connected to %s", addrbuf);
|
||||
break;
|
||||
case PLUGLOG_PROXY_MSG: {
|
||||
|
@ -67,8 +67,11 @@ struct PlugVtable {
|
||||
* addresses to fall back to. When it _is_ fatal, the closing()
|
||||
* function will be called.
|
||||
*
|
||||
* - PLUGLOG_CONNECT_SUCCESS means we have succeeded in
|
||||
* connecting to address `addr'.
|
||||
* - PLUGLOG_CONNECT_SUCCESS means we have succeeded in making a
|
||||
* connection. `addr' gives the address we connected to, if
|
||||
* available. (But sometimes, in cases of complicated proxy
|
||||
* setups, it might not be available, so receivers of this log
|
||||
* event should be prepared to deal with addr==NULL.)
|
||||
*
|
||||
* - PLUGLOG_PROXY_MSG means that error_msg contains a line of
|
||||
* logging information from whatever the connection is being
|
||||
|
2
proxy.c
2
proxy.c
@ -28,6 +28,8 @@ void proxy_activate (ProxySocket *p)
|
||||
|
||||
p->state = PROXY_STATE_ACTIVE;
|
||||
|
||||
plug_log(p->plug, PLUGLOG_CONNECT_SUCCESS, NULL, 0, NULL, 0);
|
||||
|
||||
/* we want to ignore new receive events until we have sent
|
||||
* all of our buffered receive data.
|
||||
*/
|
||||
|
@ -315,6 +315,12 @@ static const SocketVtable FdSocket_sockvt = {
|
||||
.peer_info = NULL,
|
||||
};
|
||||
|
||||
static void fdsocket_connect_success_callback(void *ctx)
|
||||
{
|
||||
FdSocket *fds = (FdSocket *)ctx;
|
||||
plug_log(fds->plug, PLUGLOG_CONNECT_SUCCESS, NULL, 0, NULL, 0);
|
||||
}
|
||||
|
||||
Socket *make_fd_socket(int infd, int outfd, int inerrfd, Plug *plug)
|
||||
{
|
||||
FdSocket *fds;
|
||||
@ -354,5 +360,7 @@ Socket *make_fd_socket(int infd, int outfd, int inerrfd, Plug *plug)
|
||||
uxsel_set(fds->inerrfd, SELECT_R, fdsocket_select_result_input_error);
|
||||
}
|
||||
|
||||
queue_toplevel_callback(fdsocket_connect_success_callback, fds);
|
||||
|
||||
return &fds->sock;
|
||||
}
|
||||
|
@ -314,6 +314,12 @@ static const SocketVtable HandleSocket_sockvt = {
|
||||
.peer_info = sk_handle_peer_info,
|
||||
};
|
||||
|
||||
static void sk_handle_connect_success_callback(void *ctx)
|
||||
{
|
||||
HandleSocket *hs = (HandleSocket *)ctx;
|
||||
plug_log(hs->plug, PLUGLOG_CONNECT_SUCCESS, NULL, 0, NULL, 0);
|
||||
}
|
||||
|
||||
Socket *make_handle_socket(HANDLE send_H, HANDLE recv_H, HANDLE stderr_H,
|
||||
Plug *plug, bool overlapped)
|
||||
{
|
||||
@ -339,5 +345,7 @@ Socket *make_handle_socket(HANDLE send_H, HANDLE recv_H, HANDLE stderr_H,
|
||||
|
||||
hs->defer_close = hs->deferred_close = false;
|
||||
|
||||
queue_toplevel_callback(sk_handle_connect_success_callback, hs);
|
||||
|
||||
return &hs->sock;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user