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

FdSocket, HandleSocket: store a notional peer address.

In the case where these socket types are constructed because of a
local proxy command, we do actually have a SockAddr representing the
logical host we were trying to make a connection to. So we might as
well store it in the socket implementation, and then we can include it
in the PLUGLOG_CONNECT_SUCCESS call to make the log message more
informative.
This commit is contained in:
Simon Tatham
2021-09-13 14:34:46 +01:00
parent 8f5e9a4f8d
commit a4b8ff911b
10 changed files with 32 additions and 18 deletions

View File

@ -23,6 +23,8 @@ typedef struct FdSocket {
int pending_error;
SockAddr *addr;
int port;
Plug *plug;
Socket sock;
@ -134,6 +136,9 @@ static void fdsocket_close(Socket *s)
bufchain_clear(&fds->pending_input_data);
bufchain_clear(&fds->pending_output_data);
if (fds->addr)
sk_addr_free(fds->addr);
delete_callbacks_for_context(fds);
sfree(fds);
@ -318,15 +323,19 @@ static const SocketVtable FdSocket_sockvt = {
static void fdsocket_connect_success_callback(void *ctx)
{
FdSocket *fds = (FdSocket *)ctx;
plug_log(fds->plug, PLUGLOG_CONNECT_SUCCESS, NULL, 0, NULL, 0);
plug_log(fds->plug, PLUGLOG_CONNECT_SUCCESS, fds->addr, fds->port,
NULL, 0);
}
Socket *make_fd_socket(int infd, int outfd, int inerrfd, Plug *plug)
Socket *make_fd_socket(int infd, int outfd, int inerrfd,
SockAddr *addr, int port, Plug *plug)
{
FdSocket *fds;
fds = snew(FdSocket);
fds->sock.vt = &FdSocket_sockvt;
fds->addr = addr;
fds->port = port;
fds->plug = plug;
fds->outgoingeof = EOF_NO;
fds->pending_error = 0;