7 "github.com/anacrolix/missinggo/perf"
10 type Dialer interface {
11 // The network is implied by the instance.
12 Dial(_ context.Context, addr string) (net.Conn, error)
13 // This is required for registering with the connection tracker (router connection table
14 // emulating rate-limiter) before dialing. TODO: What about connections that wouldn't infringe
15 // on routers, like localhost or unix sockets.
19 type NetDialer struct {
24 func (me NetDialer) Dial(ctx context.Context, addr string) (_ net.Conn, err error) {
25 defer perf.ScopeTimerErr(&err)()
26 return me.Dialer.DialContext(ctx, me.Network, addr)
29 func (me NetDialer) LocalAddr() net.Addr {
30 return netDialerLocalAddr{me.Network, me.Dialer.LocalAddr}
33 type netDialerLocalAddr struct {
38 func (me netDialerLocalAddr) Network() string { return me.network }
40 func (me netDialerLocalAddr) String() string {
44 return me.addr.String()