true,
func(cl *Client) {
cl.ipBlockList = iplist.New([]iplist.Range{
- iplist.Range{First: net.ParseIP("10.0.0.1"), Last: net.ParseIP("10.0.0.255")},
+ {First: net.ParseIP("10.0.0.1"), Last: net.ParseIP("10.0.0.255")},
})
},
},
require.Equal(t, tc.expectedOk, cl.badPeerIPPort(tc.ip, tc.port))
})
}
-
}
}
func writeMetainfoToFile(mi metainfo.MetaInfo, path string) error {
- f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0640)
+ f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o640)
if err != nil {
return err
}
package metainfo
// For more context on why these numbers, see http://wiki.vuze.com/w/Torrent_Piece_Size
-const minimumPieceLength = 16 * 1024
-const targetPieceCountLog2 = 10
-const targetPieceCountMin = 1 << targetPieceCountLog2
+const (
+ minimumPieceLength = 16 * 1024
+ targetPieceCountLog2 = 10
+ targetPieceCountMin = 1 << targetPieceCountLog2
+)
// Target piece count should be < targetPieceCountMax
const targetPieceCountMax = targetPieceCountMin << 1
func connIsIpv6(nc interface {
LocalAddr() net.Addr
-}) bool {
+},
+) bool {
ra := nc.LocalAddr()
rip := addrIpOrNil(ra)
return rip.To4() == nil && rip.To16() != nil
lastItem.Set(_i)
ih := _i.key.InfoHash
- var t = input.Torrent(ih)
+ t := input.Torrent(ih)
pieceLength := t.PieceLength()
if storageLeft != nil {
if *storageLeft < pieceLength {
}
return nil
}
+
func (ts *mmapTorrentStorage) Flush() error {
errs := ts.span.Flush()
if len(errs) > 0 {
url_ *url.URL
}
-type ProxyFunc func(*http.Request) (*url.URL, error)
-type DialContextFunc func(ctx context.Context, network, addr string) (net.Conn, error)
+type (
+ ProxyFunc func(*http.Request) (*url.URL, error)
+ DialContextFunc func(ctx context.Context, network, addr string) (net.Conn, error)
+)
type NewClientOpts struct {
Proxy ProxyFunc
return fmt.Errorf("creating offer: %w", err)
}
- err = tc.announce(event, infoHash, []outboundOffer{{
- offerId: offerIDBinary,
- outboundOfferValue: outboundOfferValue{
- originalOffer: offer,
- peerConnection: pc,
- infoHash: infoHash,
- dataChannel: dc,
- }},
+ err = tc.announce(event, infoHash, []outboundOffer{
+ {
+ offerId: offerIDBinary,
+ outboundOfferValue: outboundOfferValue{
+ originalOffer: offer,
+ peerConnection: pc,
+ infoHash: infoHash,
+ dataChannel: dc,
+ },
+ },
})
if err != nil {
dc.Close()
package webtorrent
import (
+ "testing"
+
"github.com/anacrolix/log"
qt "github.com/frankban/quicktest"
"github.com/pion/webrtc/v3"
- "testing"
)
func TestClosingPeerConnectionDoesNotCloseUnopenedDataChannel(t *testing.T) {