-
Notifications
You must be signed in to change notification settings - Fork 17.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net: document possible networks for {Dialer,ListenConfig}.Control #69693
Comments
Such a table risks going out of date. More importantly, I don't see what it adds. You will have to write your Control function to recognize all the networks you know about. If that goes out of date, the table you describe won't help. |
@ianlancetaylor My primary objective is to enforce IPv4 or IPv6 exclusively on dual-stack machines. I agree the entire table might be excessive, but just a few additional assumptions can ensure the code's correctness. How about these two:
These assumptions are essential for enforcing IPv4 or IPv6 using The current documentation explicitly specifies the behavior for the PS: I understand that, if the |
Go version
go version go1.23.1 linux/amd64
What did you do?
The
Control
function is useful for enforcing IPv4 or IPv6 on a dual-stack machine. The idea is to selectively reject IPv6 for IPv4-only connections and IPv4 for IPv6-only ones. However, in order to do so, it's crucial to identify known networks that could be sent to theControl
function. A demonstration of the idea is at https://go.dev/play/p/ttwNDrCXplaWhat did you see happen?
The current documentation says:
The documentation is uncommitted about the behavior in other scenarios, such as
udp
andip:<protocol>
.What did you expect to see?
The source code (across all platforms) seems to indicate the following relation between
Dial/Listen
andControl
:network
forDial/Listen
network
forControl
unix
,unixgram
,unixpacket
,udp4
,udp6
,tcp4
,tcp6
network
valueudp
udp4
orudp6
(but notudp
)tcp
tcp4
ortcp6
(but nottcp
)ip4:<protocol>
ip4
ip6:<protocol>
ip6
ip:<protocol>
ip4
orip6
(but notip
)If the table is accurate, I wonder if we can explicitly document it?
Edits (after some comments)
I did not mean we should literally document the whole table. Documenting the general rules behind the table is sufficient! My real question is, can we document the general rules and guarantee that they will be followed in the future?
The text was updated successfully, but these errors were encountered: