-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: Add ControlContext to Dialer #55301
Comments
/cc @neild |
Using the That said, I can think of other cases where it might be useful to pass a I don't have a strong opinion on whether we should add a |
This proposal has been added to the active column of the proposals project |
The filtering sounds maybe questionable, but there are other good reasons to have a ControlContext form. |
Based on the discussion above, this proposal seems like a likely accept. |
No change in consensus, so accepted. 🎉 |
Change https://go.dev/cl/444955 mentions this issue: |
It might be too late to post this, but I think it would be nice if the new control function has |
This change breaks forward compatibility for types that wrap a |
That is true, but it's OK (not ideal, but OK) if a program that uses a new library feature fails to work as expected when using an existing package that is not aware of that new library feature. It should be straightforward for those packages to be updated for the new release. |
Change https://go.dev/cl/451420 mentions this issue: |
For #50101 For #51152 For #53482 For #55301 For #56515 Change-Id: I11edeb4be0a7f80fb72fd7680a3407d081f83b8b Reviewed-on: https://go-review.googlesource.com/c/go/+/451420 TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Damien Neil <[email protected]> Run-TryBot: Damien Neil <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
- Use net.Dialer.ControlContext instead of use net.Dialer.Control Using Dialer.ControlContext instead of Dialer.Control allows; - propagation of logging contexts, metric context or other metadata down to the callback. - cancellation if the callback potentially does I/O. - Fixes: #149 - golang/go#55301
The
net.Dialer
struct contains a the.Control
field, a callback. The original intention of this method was to "Permit setting socket options", as noted in the Go 1.11 release notes. One additional use case for this function is a defensive purpose: Preventing some types of Server Side Request Forgery (SSRF) -- as detailed in this blog post:https://www.agwa.name/blog/post/preventing_server_side_request_forgery_in_golang
In security focused use case, having a variant of the
.Control
method which received thecontext.Context
would be very helpful:context.Context
, you don't get cancellation or other context.Values that could be helpful.Proposed addition to the Dialer struct:
Similar to other
*Context
variants in the standard library, it would only be used if set, and used in preference to the non-context variant.The text was updated successfully, but these errors were encountered: