Repository navigation
net: expose peer name of pipe connections - #67402
Open
guybedford wants to merge 2 commits into
Open
guybedford wants to merge 2 commits into
guybedford wants to merge 2 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
Collaborator
|
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.73% -0.02%
==========================================
Files 798 798
Lines 280102 280131 +29
Branches 53901 53905 +4
==========================================
- Hits 254186 254169 -17
- Misses 16198 16253 +55
+ Partials 9718 9709 -9
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.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, and the
'drop'andblockListcases for pipe servers. TCP behavior is unchanged.