gofumpt
This commit is contained in:
parent
81201050bc
commit
e8b04c7181
|
@ -808,7 +808,7 @@ func TestBadPeerIpPort(t *testing.T) {
|
|||
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")},
|
||||
})
|
||||
},
|
||||
},
|
||||
|
@ -845,5 +845,4 @@ func TestBadPeerIpPort(t *testing.T) {
|
|||
require.Equal(t, tc.expectedOk, cl.badPeerIPPort(tc.ip, tc.port))
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ func waitForPieces(ctx context.Context, t *torrent.Torrent, beginIndex, endIndex
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -31,9 +31,11 @@
|
|||
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
|
||||
|
|
3
misc.go
3
misc.go
|
@ -115,7 +115,8 @@ func connLessTrusted(l, r *Peer) bool {
|
|||
|
||||
func connIsIpv6(nc interface {
|
||||
LocalAddr() net.Addr
|
||||
}) bool {
|
||||
},
|
||||
) bool {
|
||||
ra := nc.LocalAddr()
|
||||
rip := addrIpOrNil(ra)
|
||||
return rip.To4() == nil && rip.To16() != nil
|
||||
|
|
|
@ -66,7 +66,7 @@ func GetRequestablePieces(
|
|||
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 {
|
||||
|
|
|
@ -71,6 +71,7 @@ func (ts *mmapTorrentStorage) Close() error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ts *mmapTorrentStorage) Flush() error {
|
||||
errs := ts.span.Flush()
|
||||
if len(errs) > 0 {
|
||||
|
|
|
@ -13,8 +13,10 @@ type Client struct {
|
|||
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
|
||||
|
|
|
@ -233,14 +233,16 @@ func (tc *TrackerClient) Announce(event tracker.AnnounceEvent, infoHash [20]byte
|
|||
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()
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package webtorrent
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/anacrolix/log"
|
||||
qt "github.com/frankban/quicktest"
|
||||
"github.com/pion/webrtc/v3"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestClosingPeerConnectionDoesNotCloseUnopenedDataChannel(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue