gofumpt
This commit is contained in:
parent
81201050bc
commit
e8b04c7181
|
@ -808,7 +808,7 @@ func TestBadPeerIpPort(t *testing.T) {
|
||||||
true,
|
true,
|
||||||
func(cl *Client) {
|
func(cl *Client) {
|
||||||
cl.ipBlockList = iplist.New([]iplist.Range{
|
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))
|
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 {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,11 @@
|
||||||
package metainfo
|
package metainfo
|
||||||
|
|
||||||
// For more context on why these numbers, see http://wiki.vuze.com/w/Torrent_Piece_Size
|
// For more context on why these numbers, see http://wiki.vuze.com/w/Torrent_Piece_Size
|
||||||
const minimumPieceLength = 16 * 1024
|
const (
|
||||||
const targetPieceCountLog2 = 10
|
minimumPieceLength = 16 * 1024
|
||||||
const targetPieceCountMin = 1 << targetPieceCountLog2
|
targetPieceCountLog2 = 10
|
||||||
|
targetPieceCountMin = 1 << targetPieceCountLog2
|
||||||
|
)
|
||||||
|
|
||||||
// Target piece count should be < targetPieceCountMax
|
// Target piece count should be < targetPieceCountMax
|
||||||
const targetPieceCountMax = targetPieceCountMin << 1
|
const targetPieceCountMax = targetPieceCountMin << 1
|
||||||
|
|
3
misc.go
3
misc.go
|
@ -115,7 +115,8 @@ func connLessTrusted(l, r *Peer) bool {
|
||||||
|
|
||||||
func connIsIpv6(nc interface {
|
func connIsIpv6(nc interface {
|
||||||
LocalAddr() net.Addr
|
LocalAddr() net.Addr
|
||||||
}) bool {
|
},
|
||||||
|
) bool {
|
||||||
ra := nc.LocalAddr()
|
ra := nc.LocalAddr()
|
||||||
rip := addrIpOrNil(ra)
|
rip := addrIpOrNil(ra)
|
||||||
return rip.To4() == nil && rip.To16() != nil
|
return rip.To4() == nil && rip.To16() != nil
|
||||||
|
|
|
@ -66,7 +66,7 @@ func GetRequestablePieces(
|
||||||
lastItem.Set(_i)
|
lastItem.Set(_i)
|
||||||
|
|
||||||
ih := _i.key.InfoHash
|
ih := _i.key.InfoHash
|
||||||
var t = input.Torrent(ih)
|
t := input.Torrent(ih)
|
||||||
pieceLength := t.PieceLength()
|
pieceLength := t.PieceLength()
|
||||||
if storageLeft != nil {
|
if storageLeft != nil {
|
||||||
if *storageLeft < pieceLength {
|
if *storageLeft < pieceLength {
|
||||||
|
|
|
@ -71,6 +71,7 @@ func (ts *mmapTorrentStorage) Close() error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts *mmapTorrentStorage) Flush() error {
|
func (ts *mmapTorrentStorage) Flush() error {
|
||||||
errs := ts.span.Flush()
|
errs := ts.span.Flush()
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
|
|
|
@ -13,8 +13,10 @@ type Client struct {
|
||||||
url_ *url.URL
|
url_ *url.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProxyFunc func(*http.Request) (*url.URL, error)
|
type (
|
||||||
type DialContextFunc func(ctx context.Context, network, addr string) (net.Conn, error)
|
ProxyFunc func(*http.Request) (*url.URL, error)
|
||||||
|
DialContextFunc func(ctx context.Context, network, addr string) (net.Conn, error)
|
||||||
|
)
|
||||||
|
|
||||||
type NewClientOpts struct {
|
type NewClientOpts struct {
|
||||||
Proxy ProxyFunc
|
Proxy ProxyFunc
|
||||||
|
|
|
@ -233,14 +233,16 @@ func (tc *TrackerClient) Announce(event tracker.AnnounceEvent, infoHash [20]byte
|
||||||
return fmt.Errorf("creating offer: %w", err)
|
return fmt.Errorf("creating offer: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tc.announce(event, infoHash, []outboundOffer{{
|
err = tc.announce(event, infoHash, []outboundOffer{
|
||||||
|
{
|
||||||
offerId: offerIDBinary,
|
offerId: offerIDBinary,
|
||||||
outboundOfferValue: outboundOfferValue{
|
outboundOfferValue: outboundOfferValue{
|
||||||
originalOffer: offer,
|
originalOffer: offer,
|
||||||
peerConnection: pc,
|
peerConnection: pc,
|
||||||
infoHash: infoHash,
|
infoHash: infoHash,
|
||||||
dataChannel: dc,
|
dataChannel: dc,
|
||||||
}},
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dc.Close()
|
dc.Close()
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package webtorrent
|
package webtorrent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/anacrolix/log"
|
"github.com/anacrolix/log"
|
||||||
qt "github.com/frankban/quicktest"
|
qt "github.com/frankban/quicktest"
|
||||||
"github.com/pion/webrtc/v3"
|
"github.com/pion/webrtc/v3"
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestClosingPeerConnectionDoesNotCloseUnopenedDataChannel(t *testing.T) {
|
func TestClosingPeerConnectionDoesNotCloseUnopenedDataChannel(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue