Commit Graph

79 Commits

Author SHA1 Message Date
Matt Joiner c18e0abe52 Fix incomplete Integer.Read
Possibly on read buffer boundaries, this would have caused errant io.ErrUnexpectedEOF.

(cherry picked from commit 22569449dad48e1c5cdeac171625585f8ca976c9)
2021-10-19 14:07:23 +11:00
Matt Joiner 118391c3bf Apply some lints from GoLand 2021-10-07 09:12:17 +11:00
Matt Joiner 4ed855070f Fix scheduling overhead in decoding benchmark 2021-09-30 11:52:50 +10:00
Matt Joiner 702cf3c8f7 Combine peer protocol fuzz targets into one file 2021-09-30 11:19:50 +10:00
Matt Joiner 2027028539 More optimizations in peer protocol message decoding 2021-09-30 11:05:01 +10:00
Matt Joiner 73696fd215 peer_protocol: Use faster form for Integer.{UnmarshalBinary,Read} 2021-09-30 10:24:03 +10:00
Matt Joiner 60a622ff4b Remove an allocation reading message length 2021-09-30 09:59:18 +10:00
Matt Joiner 709ee70b0c Try to avoid allocating buffer 2021-09-30 09:45:50 +10:00
Matt Joiner b69e6dff01 Improvements to decoder fuzzing 2021-09-30 09:42:54 +10:00
Matt Joiner 1b66994c0a Add some fuzzing in peer_protocol 2021-09-30 09:01:10 +10:00
YenForYang a8db640c62
Drop bradfitz/iter dependency (#605)
* Drop bradfitz/iter dependency

`range iter.N` looks nice and doesn't allocate, but unfortunately using a `range` expression blocks a function from being inlined wherever it's used (for now). It's not that we need inlining in all cases, but I do think a C-style for loop looks just as nice and is probably clearer to the majority. There also aren't any clear disadvantages to changing (unless you just happen to dislike the look of C)

* Update misc_test.go

* Update rlreader_test.go

* Update torrent_test.go

* Update bench_test.go

* Update client_test.go

* Update iplist_test.go

* Update mse_test.go

* Update peerconn_test.go

* Update peerconn.go

* Update order_test.go

* Update decoder_test.go

* Update main.go

* Update bench-piece-mark-complete.go

* Update main.go

* Update torrent.go

* Update iplist_test.go

* Update main.go
2021-09-14 13:46:50 +10:00
Matt Joiner 35064425eb go fmt ./... 2021-09-09 22:51:24 +10:00
YenForYang 99ba75f458 Drop xerrors and reflection dependency
Nothing wrong with missinggo.CopyExact -- but fewer dependencies is better IMO.  Also changed String() to use a consistent receiver name -- not a big deal.
2021-09-04 23:01:37 +10:00
Bora M. Alper 16176b762e
Add linter CI (#542)
* Add linter CI

Signed-off-by: Bora M. Alper <bora@boramalper.org>

* Make gosec CI ignore SHA1 and upload sarif

Signed-off-by: Bora M. Alper <bora@boramalper.org>

* Fix formatting of source files

Signed-off-by: Bora M. Alper <bora@boramalper.org>

* Make go vet ignore unkeyed composite literals and fix other warnings

Signed-off-by: Bora M. Alper <bora@boramalper.org>

* Make staticcheck ignore unused methods and fix other warnings

Signed-off-by: Bora M. Alper <bora@boramalper.org>

* Use golangci-lint

Signed-off-by: Bora M. Alper <bora@boramalper.org>
2021-08-16 11:11:31 +10:00
Matt Joiner c3c982b621 Fixes for wasm 2021-06-23 17:24:50 +10:00
Matt Joiner 15f8e77519 Add explicit metadata extension types 2021-06-21 12:14:06 +10:00
Matt Joiner 9ded7e7e87 Use bytes.Reader instead of bytes.Buffer in a few places 2021-05-05 15:48:57 +10:00
Matt Joiner f409daa93f PORT message belongs to BEP 5 2021-01-27 17:08:15 +11:00
Matt Joiner 6aaaaaffba Fix unreferenced variable 2021-01-19 10:55:22 +11:00
Matt Joiner c1d189ed31 Performance improvements to PEX 2020-10-23 08:58:55 +11:00
Matt Joiner 3e9a5a4aec Expose ClientConfig.Extensions
Also run the storage failure test with fast disabled for the seeder. This probably would have tickled some issues in the past, so it seems like a good place to try it out.
2020-04-23 13:03:40 +10:00
Yaroslav Kolomiiets 2b2c480706 PEX: add periodic deltas 2020-04-15 17:24:44 +10:00
Yaroslav Kolomiiets 93430aa01a PEX: add connection tracking 2020-04-15 17:24:44 +10:00
Yaroslav Kolomiiets 634edd2875 Share current connections with peers over PEX (anacrolix#341) 2020-04-15 17:24:44 +10:00
Matt Joiner 376ff763fe Apply staticcheck 2020-02-20 11:09:57 +11:00
Matt Joiner 5b0c895e09 Add comments 2019-10-01 18:13:55 +10:00
Matt Joiner cb1bf0f413 goimports -local 2019-08-21 20:58:40 +10:00
Matt Joiner 9224303c1e Update all imports of dht to v2 2019-08-10 18:46:07 +10:00
Matt Joiner 338287486f Always return errors when handshakes or dialing fails
I intend to use xerrors-style error handling for special cases.
2019-07-19 16:15:46 +10:00
Matt Joiner 63d215568a Tidy up function signature 2019-07-19 14:56:29 +10:00
Matt Joiner e236cbf145 bencode: Fix marshalling of []byte(nil)
Also fixes #293.
2018-11-27 08:57:17 +11:00
Matt Joiner fc4fab91f5 Switch to goimports import sorting
Used to use sortimports, but it's old, and goimports seems to have an opinion now.
2018-11-02 23:12:01 +11:00
Matt Joiner 91730696cf Rewrite piece data decoding and relax test 2018-07-14 11:50:43 +10:00
Matt Joiner 01380adac3 peer_protocol: Add a test for receiving overlong piece data
The chunk buffer pool decides the upper bound on chunk data len.
2018-07-14 11:37:56 +10:00
Matt Joiner cc6441a791 Fix peer_protocol.Message.RequestSpec for Type Piece 2018-07-13 21:33:21 +10:00
Matt Joiner c001e6e008 Add a test that short pieces are decoded correctly 2018-07-12 09:54:06 +10:00
Matt Joiner 324cc7a281 Comments and trivial tweaks 2018-07-12 09:42:00 +10:00
Matt Joiner ee985e51cb Add peer_protocol.Integer.Uint32 2018-07-12 09:16:40 +10:00
Matt Joiner 86ca9ffa7e Add peer_protocol.RequestSpec 2018-07-12 09:16:17 +10:00
Matt Joiner ba8ec1a787 Move back to net.IP for extended handshake message IPs 2018-07-12 00:00:07 +10:00
Matt Joiner 1f6ba94882 Make extended handshake a struct, and move a bunch of extended stuff into peer_protocol 2018-07-10 12:20:36 +10:00
Matt Joiner 50def7a688 Move PEX stuff into peer_protocol 2018-07-10 11:21:24 +10:00
Matt Joiner a7e338a3f1 More sortimports 2018-07-07 11:40:06 +10:00
Matt Joiner e0f0617b0b Comments and readability 2018-07-07 11:33:48 +10:00
Matt Joiner 76a3c0891a Expose handshake stuff in peer_protocol 2018-07-07 11:31:29 +10:00
Matt Joiner 54f43419e2 Fix fast extension message type constants
iota isn't worth the trouble
2018-02-05 18:00:47 +11:00
Matt Joiner 93e8d9bfaa Use stringer to generate peer_protocol.MessageType strings 2018-02-05 15:30:35 +11:00
Matt Joiner 20316e5af4 Support AllowedFast and enable fast extension 2018-02-05 00:18:38 +11:00
Matt Joiner 44e44637bf TODOs and comments 2018-02-04 19:14:07 +11:00
Matt Joiner 89b17c4372 Try to print something useful for MessageType panics 2018-02-02 21:52:57 +11:00