From 98e0f3dac41d2d722d2e6e7448ba6ca3ce0f4fbe Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 10 Nov 2026 21:13:27 -0700 Subject: [PATCH 1/2] net: expose peer name of pipe connections getpeername(2) on a Unix domain socket returns the path the peer is bound to, but the pipe handle had no getpeername method, so socket.remoteAddress was always undefined for pipe connections. Add getpeername to the pipe handle, backed by uv_pipe_getpeername(), so that socket.remoteAddress reports the listening path on the connecting side and the path of a bound client on the accepting side. It remains undefined for an unbound peer, and on Windows, where a named pipe has a single name rather than one per end. The server 'drop' data and BlockList check keyed off the presence of getpeername on the accepted handle, so restrict both to non-pipe handles to keep their behavior for pipe servers unchanged. Signed-off-by: Guy Bedford Assisted-by: Claude Fable 5.2 --- doc/api/net.md | 14 +++ lib/net.js | 6 +- src/pipe_wrap.cc | 47 ++++++++- src/pipe_wrap.h | 4 +- test/parallel/test-net-pipe-remote-address.js | 99 +++++++++++++++++++ 5 files changed, 165 insertions(+), 5 deletions(-) create mode 100644 test/parallel/test-net-pipe-remote-address.js diff --git a/doc/api/net.md b/doc/api/net.md index 0a3800f3b905..ce4ab711ec97 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -1602,6 +1602,10 @@ If the socket is `ref`ed calling `ref` again will have no effect. * Type: {string} @@ -1610,6 +1614,14 @@ The string representation of the remote IP address. For example, `'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if the socket is destroyed (for example, if the client disconnected). +For a [Unix domain socket][IPC], this is the path the peer is bound to: the +listening path on the connecting side, and on the accepting side the path of a +client that was bound before connecting (see [`BoundSocket`][]). It is +`undefined` if the peer is not bound to a path, which is the case for most +clients. [`socket.remoteFamily`][] and [`socket.remotePort`][] are always +`undefined` for these connections, as is `socket.remoteAddress` for a Windows +named pipe. + ### `socket.remoteFamily`