import (
"bufio"
"bytes"
+ "context"
"crypto/rand"
"encoding/hex"
"errors"
}
func (cl *Client) dialUTP(addr string, t *Torrent) (net.Conn, error) {
- return cl.utpSock.DialTimeout(addr, cl.dialTimeout(t))
+ ctx, cancel := context.WithTimeout(context.Background(), cl.dialTimeout(t))
+ defer cancel()
+ return cl.utpSock.DialContext(ctx, addr)
}
// Returns a connection over UTP or TCP, whichever is first to connect.
package torrent
import (
+ "context"
"net"
"time"
)
SetWriteDeadline(time.Time) error
SetReadDeadline(time.Time) error
WriteTo([]byte, net.Addr) (int, error)
- DialTimeout(string, time.Duration) (net.Conn, error)
- Dial(string) (net.Conn, error)
+ DialContext(ctx context.Context, addr string) (net.Conn, error)
+ Dial(addr string) (net.Conn, error)
}