Repository navigation
net: expose peer name of pipe connections - #67402
guybedford wants to merge 4 commits into
Conversation
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 <guybedford@gmail.com> Assisted-by: Claude Fable 5.2
|
Review requested:
|
Signed-off-by: Guy Bedford <guybedford@gmail.com> Assisted-by: Claude Fable 5.2
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67402 +/- ##
==========================================
- Coverage 90.74% 90.71% -0.04%
==========================================
Files 798 801 +3
Lines 280102 280817 +715
Branches 53901 54212 +311
==========================================
+ Hits 254186 254734 +548
- Misses 16198 16246 +48
- Partials 9718 9837 +119
🚀 New features to boost your workflow:
|
Ethan-Arrowood
left a comment
There was a problem hiding this comment.
This LGTM. Need to run the C++ linter though.
My agent claims this change is currently causing a crash for "http2 client over TLS on a Linux abstract socket" because initOriginSet falls back to socket.remoteAdress when there is no servername. This causes an ERR_INVALID_URL on this branch, but currently works fine on main. It suggest using remoteAddress only when remoteFamily is set. I checked its work, and am confident in the analysis, but since its pretty far out of my core understanding, I'll leave it to you to independently verify and consider what is the most appropriate change.
I'm personally fine with this landing as is as long as it passes CI of course.
Great work!
AI-assisted (Claude Opus 5.5, my setup). The words are my own, per the Human Voice policy.
Keep the http2 origin set from using a pipe's peer path as a host name, and apply clang-format. Signed-off-by: Guy Bedford <guybedford@gmail.com> Assisted-by: Claude Fable 5.2
Use localhost as the http2 origin host for a pipe without a servername. Signed-off-by: Guy Bedford <guybedford@gmail.com> Assisted-by: Claude Fable 5.2
|
Thanks @Ethan-Arrowood for the review. Both points were correct - when |
Commit Queue failedThe pull request was removed from the Commit Queue and labeled
commit-queue-failed
Full Commit Queue output |
This exposes the peer name of Unix domain socket connections as
socket.remoteAddress.getpeername(2)on a Unix domain socket returns the path the peer is bound to, but the pipe handle had nogetpeernamemethod, sosocket.remoteAddresswas alwaysundefinedfor pipe connections, even when the client was bound to a path throughnet.BoundSocket({ path }).getpeername, backed byuv_pipe_getpeername().remoteAddressstaysundefinedwhen the peer is not bound to a path, which is the case for most clients.remoteFamilyandremotePortstayundefinedfor pipes, matchinglocalFamilyandlocalPort.remoteAddressstaysundefined, since a named pipe has a single name rather than one per end.'drop'data andblockListcheck keyed off the accepted handle havinggetpeername, so both are now restricted to non-pipe handles. Without this ablockListon a pipe server would reject every connection, and'drop'would stop passingundefinedfor pipes as documented.remoteAddressas the origin host for a TLS socket without a servername, so a pipe's peer path would be parsed as a host, throwingERR_INVALID_URLfor an abstract name.session.originSetnow useshttps://localhostwhen the socket has no remote family, where it previously reportedhttps://undefined.Tests cover bound and unbound clients, the connecting side, abstract names, reading the cached value after the peer has closed and the socket is destroyed, the
'drop'andblockListcases for pipe servers, and the http2 origin set for TLS over a pipe without a servername. TCP behavior is unchanged.