Open sakno opened 2 years ago
Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.
Author: | sakno |
---|---|
Assignees: | - |
Labels: | `api-suggestion`, `area-System.Net.Sockets`, `untriaged` |
Milestone: | - |
@sakno have you tried using GetRawSocketOption
for your scenario?
I'm not sure if it's a good idea to implement a seemingly xplat socket option that is not supported by all platforms in reality.
This issue has been marked needs-author-action
and may be missing some important information.
@antonfirsov , I'll try! Thanks for advice. Anyway, I don't see any problem with some API which is not supported on all platforms. .NET has a lot of such API.
GetRawSocketOption
works as expected! On FreeBSD, xucred
differs from Linux version: https://cgit.freebsd.org/src/tree/sys/sys/ucred.h
Feel free to close this issue.
Happy to hear it works for you!
We have a couple of similar feature requests (like #1476 or #36170), so maybe we can keep this one open too, so people who are interested can upvote/comment.
On the other hand, it's very unlikely that we will address these in the near future, so it would also make sense to close all of them to shorten our backlog.
Triage: Given we have a few similar issues open in Future, let's keep this one as well. We can decide on it later.
Background and motivation
I would like to verify remote peer connecting to my application through Unix Domain Socket. Linux and FreeBSD allow to do that using
SO_PEERCRED
(orLOCAL_PEERCRED
on FreeBSD) socket option viagetsockopt
native function. This function needs to be called on accepted socket by server side.API Proposal
The returned data can be represented as
ValueTuple<uint, uint, uint>
to match the original ucred structure.The option must be requested on accepted socket with
SocketOptionLevel.Socket
value. On Windows,GetSocketOption
returns null.API Usage
Alternative Designs
We can keep
SocketOptionName
enum untouched and introduce static method inUnixDomainSocketEndPoint
class:On unsupported platforms, the method returns false.
Risks
I don't see any.