diff --git a/be_misc.c b/be_misc.c index 7f50a643..de15a34e 100644 --- a/be_misc.c +++ b/be_misc.c @@ -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: { diff --git a/network.h b/network.h index 92662ac7..05b71279 100644 --- a/network.h +++ b/network.h @@ -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 diff --git a/proxy.c b/proxy.c index 1a737cae..4fa8f16f 100644 --- a/proxy.c +++ b/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. */ diff --git a/unix/fd-socket.c b/unix/fd-socket.c index 6c468e6b..afd37957 100644 --- a/unix/fd-socket.c +++ b/unix/fd-socket.c @@ -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; } diff --git a/windows/handle-socket.c b/windows/handle-socket.c index 93bb500a..77b9067c 100644 --- a/windows/handle-socket.c +++ b/windows/handle-socket.c @@ -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; }