]> Sergey Matveev's repositories - btrtrc.git/blobdiff - dialer.go
Drop support for go 1.20
[btrtrc.git] / dialer.go
index e8126bd664ce0200e51f386d764df4b7429d7417..5cdf3fccac52230ae06f5c8e03701a2b0df35dde 100644 (file)
--- a/dialer.go
+++ b/dialer.go
@@ -1,45 +1,12 @@
 package torrent
 
 import (
-       "context"
-       "net"
-
-       "github.com/anacrolix/missinggo/perf"
+       "github.com/anacrolix/torrent/dialer"
 )
 
-type Dialer interface {
-       Dial(_ context.Context, addr string) (net.Conn, error)
-       DialerNetwork() string
-}
-
-type NetDialer struct {
-       Network string
-       Dialer  net.Dialer
-}
-
-func (me NetDialer) DialerNetwork() string {
-       return me.Network
-}
-
-func (me NetDialer) Dial(ctx context.Context, addr string) (_ net.Conn, err error) {
-       defer perf.ScopeTimerErr(&err)()
-       return me.Dialer.DialContext(ctx, me.Network, addr)
-}
-
-func (me NetDialer) LocalAddr() net.Addr {
-       return netDialerLocalAddr{me.Network, me.Dialer.LocalAddr}
-}
-
-type netDialerLocalAddr struct {
-       network string
-       addr    net.Addr
-}
-
-func (me netDialerLocalAddr) Network() string { return me.network }
+type (
+       Dialer        = dialer.T
+       NetworkDialer = dialer.WithNetwork
+)
 
-func (me netDialerLocalAddr) String() string {
-       if me.addr == nil {
-               return ""
-       }
-       return me.addr.String()
-}
+var DefaultNetDialer = &dialer.Default