Support hostnames #6
No reviewers
Labels
No labels
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/multinet#6
Loading…
Reference in a new issue
No description provided.
Delete branch "dstepanov-yadro/multinet:feat/host_names"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Now IP adresses are resolved by hostname. The implementation is very similar to the implementation of the standard library: https://github.com/golang/go/blob/master/src/net/dial.go#L490 First, possible IP addresses are determined, then a connection is created to the first available IP address. If IPv4 and IPv6 addresses are available, then the connection to the addresses of the version of the first address is carried out first. After
FallbackDelay
, connections to addresses of another version begin to be created.Also fixed some issues:
hardcoded network values
use
dialContext
(with override check) method in all requestsset
Dialer
fromConfig
todialer
fieldtests requires
sudo
moved tointegration
tagCloses #4
b9ccf8bcfb
to068d8e9a4c
068d8e9a4c
tofff0ee7c85
d3217f2aac
to1db030957d
WIP: Support hostnamesto Support hostnames@ -68,0 +85,4 @@
FallbackDelay time.Duration
// InterfaceSource is custom `Interface`` source.
// If not specified, default implementation is used (`net.Interfaces()``).
InterfaceSource func() ([]Interface, error)
Do we have usecase for this besides using in tests?
For example tracing, logging, metrics.
It is called once during construction, so I doubt it is useful, but ok
@ -173,2 +228,4 @@
}
var primaries, fallbacks []netip.AddrPort
if d.fallbackDelay >= 0 && network == "tcp" {
Only
tcp
ortcp4
/tcp6
too?In stdlib only
tcp
defined: https://github.com/golang/go/blob/master/src/net/dial.go#L502I was looking at this function https://github.com/golang/go/blob/master/src/net/dial.go#L229, which is called inside
resolveAddrList
@ -175,0 +237,4 @@
return d.dialParallel(ctx, network, primaries, fallbacks)
}
func (d *dialer) dialSerial(ctx context.Context, network string, addrs []netip.AddrPort) (net.Conn, error) {
If this is taken from stdlib, could we supply references in comments?
Done
@ -190,3 +382,2 @@
func (d *dialer) dialContext(nd *net.Dialer, ctx context.Context, network, address string) (net.Conn, error) {
if h := d.testHookDialContext; h != nil {
return h(nd, ctx, "tcp", address)
if h := d.customDialContext; h != nil {
What was wrong with
testHook
? It is in spirit of the related stdlib piecesb5f87b5407/src/net/dial.go (L423)
Nothing wrong. But I guess it could be used not only for tests. For example tracing, logging, metrics.
1db030957d
to5298ec4295
@ -175,0 +302,4 @@
select {
case <-fallbackTimer.C:
fallbackCtx, fallbackCancel := context.WithCancel(ctx)
defer fallbackCancel()
I don't know whether it was your idea or this is copy-pasted but seems really good
Nice!