Expose a property to set Dialer.Control #184
Merged
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.
The PR introduces a DialerControl property to allow a caller to execute syscalls on the socket before a connection is established.
Binding an IP via
Source
property is not always an option, in my case I am using a series of devices which get all the same IP and all have the same subnet: the only way to control which one has to be used is to bind the socket to a specific interface.Here an example of the code
This allows speedtest-go to work directly on the interface without having to bind on a specific IP.
The PR doesn't change the dialer used for the resolver as the library alters the DefaultResolver.
NOTE: SO_BINDTODEVICE is Linux specific, not sure what the other OS support, but the PR has no impact on the portability of the library itself as it only allows to define the
Control
property of the Dialer