Matt Joiner
2daad6e564
Update fuzz to use new standard library support
2021-09-29 11:51:03 +10:00
Matt Joiner
a9aec0bb79
Simplify bencode.Decoder.parseStringInterface
2021-09-29 09:50:01 +10:00
YenForYang
37455d3c6b
bencode: optimize `(*Decoder).parseStringInterface()` ( #659 )
2021-09-29 09:30:35 +10:00
YenForYang
7b19e81fc6
bencode: get type of `big.Int` without creating instance ( #651 )
...
Nope, it doesn't really matter. But anyway, see c084706c22/cryptobyte/asn1.go (L267)
2021-09-18 12:44:47 +10:00
YenForYang
ed3b3ee5ca
bencode: simplify getting `marshalerType` and `unmarshalerType` ( #652 )
2021-09-18 12:43:53 +10:00
YenForYang
d43769dc15
bencode: Simplify `(*Decoder).parseListInterface()` ( #656 )
...
Preserve as much type as possible (it'll be converted to an `interface{}` anyway, but we can return `[]interface{}` instead of `{}interface` here).
2021-09-18 12:42:20 +10:00
YenForYang
f3a9ea5aa9
Prevent allocation when checking interface ( #649 )
2021-09-18 12:36:25 +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
YenForYang
2203b3bcdf
Cheaper byte to string conversion ( #602 )
...
Revamped https://github.com/anacrolix/torrent/pull/587
2021-09-14 10:41:04 +10:00
Matt Joiner
5cb47021ac
Fix possible misuse of reflect.StringHeader
2021-09-09 22:49:22 +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
901a8b1b36
Don't panic on int parse failures
...
This means for UnmarshalTypeErrors we now include context. There are still some other error types remaining that are thrown up via panic.
2021-08-12 13:46:02 +10:00
Matt Joiner
a76fad32eb
Fix panic unmarshalling bencode dict into unsupported type
2021-08-12 12:16:53 +10:00
Matt Joiner
3b62b0054d
Fix go:build directives
2021-07-14 14:35:52 +10:00
Matt Joiner
364c7d862e
Add to bencode.Unmarshal doc comment
2021-06-21 17:58:04 +10:00
Matt Joiner
047cdbae0d
bencode: Improve support for embedded structs
2021-06-07 13:01:40 +10:00
Matt Joiner
25d2eea12d
bencode: Support anonymous embedded struct pointers
...
More to come if this line of improvement is retained.
2021-06-07 13:01:40 +10:00
Matt Joiner
259356ccd6
Rework bencode decoding so it might support embedded structs
2021-06-07 13:01:40 +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
376ff763fe
Apply staticcheck
2020-02-20 11:09:57 +11:00
Matt Joiner
cf85d70a5c
bencode: Rename string_values->stringValues
2019-12-23 13:39:34 +11:00
Matt Joiner
cb1bf0f413
goimports -local
2019-08-21 20:58:40 +10:00
Matt Joiner
95daebd067
bencode: Decode singleton lists of the expected type
...
Fixes #297 .
2019-06-13 13:07:37 +10:00
Matt Joiner
8e86f45124
Code formatting
2019-06-13 13:06:25 +10:00
Matt Joiner
d4584c2ca6
bencode: Improve UnmarshalTypeError string and list parsing error context
...
Helps with #297 .
2019-06-13 12:35:11 +10:00
Matt Joiner
4ea8a70a05
vgo get -u
2019-03-19 20:43:51 +11:00
Matt Joiner
25cd79aa1c
Fix benchmark not building with changes to krpc.Msg.Token
2019-01-21 22:53:42 +01: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
bf5552ae3c
bencode: Remove a lot of expensive allocations
2018-07-25 13:42:28 +10:00
Matt Joiner
61d5902786
bencode: Avoid an extra getTags call
2018-07-23 11:09:42 +10:00
Matt Joiner
341501bf93
bencode: Cache struct fields
2018-07-23 10:50:58 +10:00
Matt Joiner
2eb98189ff
bencode.Marshal: Get rid of the intermediate buffer
2018-07-23 10:50:18 +10:00
Matt Joiner
ea65ed0c2a
bencode: Add benchmark for krpc.Msg
2018-07-23 10:32:19 +10:00
Matt Joiner
b00711bb68
bencode: Avoid Value.Interface call testing for big.Int
...
Was resulting in significant allocation.
2018-07-17 21:25:15 +10:00
Matt Joiner
a4a123b04e
Don't error on bencode dicts that can't be marshalled
...
Have seen metainfo announce-lists that are lists of dicts. Possibly ignoring type errors with a tag would be smarter but I'm undecided.
2018-07-11 15:33:41 +10:00
Matt Joiner
04fa1b8d4c
Support marshalling bencode strings into byte arrays
2018-07-11 15:22:29 +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
fefeef4ee9
Merge branch 'dev'
2018-06-22 17:43:51 +10:00
Matt Joiner
c5cc570e42
bencode: Remove string allocation when parsing strings
2018-06-17 16:21:04 +10:00
ia
fd7b23e527
all: gofmt
...
Run standard gofmt command on project root.
- go version go1.10.3 darwin/amd64
Signed-off-by: ia <isaac.ardis@gmail.com>
2018-06-17 15:49:58 +10:00
Matt Joiner
d7225aed03
Fix #247
2018-04-13 17:07:19 +10:00
Matt Joiner
319e57d1c6
Rework conns to/and allow multiple DHT servers
...
This will help with #229 , and IPv6 support.
2018-04-12 11:41:07 +10:00
Matt Joiner
33bfa908d2
bencode.Decoder.Decode: Don't assume panic values are type error
2018-02-13 00:55:15 +11:00
Matt Joiner
4b5203851a
bencode: Support unmarshalling strings into slices of kind Uint8
2018-02-13 00:44:05 +11:00
Matt Joiner
dd9244c01d
bencode: Unmarshal now returns an error on unused trailing bytes
2018-02-13 00:21:28 +11:00
Matt Joiner
1f3eace72f
bencode: Add ignore_unmarshal_type_error tag
2018-01-27 14:31:46 +11:00
Matt Joiner
0e32592f78
bencode: Give more descriptive errors when failing to parse dicts
2018-01-25 21:46:50 +11:00
Matt Joiner
eed0743d4e
bencode.scanner.ReadByte returned errors when it shouldn't have
2017-11-10 23:44:24 +11:00
Matt Joiner
74c5d425fb
bencode: Handle encoding big.Ints
2017-11-08 21:34:24 +11:00