Commit Graph

84 Commits

Author SHA1 Message Date
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
Matt Joiner 79a0e0f1fd bencode: Tidy import block 2017-11-08 20:58:35 +11:00
Matt Joiner f060f0cb02 Comment on bencode.Decoder.Offset 2017-11-05 15:45:30 +11:00
Matt Joiner edf2495b1f Expose bencode.Decoder.Offset 2017-11-05 15:42:37 +11:00
Matt Joiner fce1fe1661 bencode: Implement unbuffered scanner used by NewDecoder
Minimizes unused reads into the input Reader stream
2017-11-05 15:39:36 +11:00
Matt Joiner 911423307d Add a test for bdecoding consecutive dicts 2017-10-26 14:26:27 +11:00
Matt Joiner e25cfdf6b2 The bencode README is markdown 2017-09-12 18:31:56 +10:00
mh-cbon 54a3090f7e Update README 2017-09-05 16:42:37 +02:00
Matt Joiner 8fd5942722 Make bencode.Bytes work with pointer and nonpointer receivers 2016-08-26 20:29:29 +10:00
Matt Joiner 7b2561cea8 bencode: More renames 2016-08-26 14:51:38 +10:00
Matt Joiner ebdab2d9de Add bencode.Bytes 2016-08-26 14:51:09 +10:00
Matt Joiner f2cbc873a5 bencode: Rename a bunch of slug case stuff 2016-08-26 13:13:30 +10:00
Matt Joiner 727d002e5a bencode.Encoder: Unembed the Writer and wrap it in a minimal interface
I won't remove the bufio.Buffer for Marshal now, it isn't a performance issue as far as I can tell, and I'd have to fake Flush().
2016-06-15 15:09:34 +10:00
Matt Joiner ac3b40ace3 bencode: Remove private types encoder and decoder
Instead the functionality is exposed directly on the public types.
2016-06-15 15:00:51 +10:00
Matt Joiner d9b7e7f297 bencode.Unmarshal: Remove unnecessary intermediate bufio.Reader 2016-06-15 14:54:40 +10:00
Matt Joiner 9d1a33facc bencode: Unembed the Reader type, and minimize the interface surface
Want to remove some unnecessary allocations.
2016-06-15 14:51:58 +10:00
Seth Hoenig 9f4bf70e17 refactor struct identifiers to follow conventional go names 2016-04-18 23:11:11 -05:00
Matt Joiner c0cef5274b bencode: Update some test code 2016-02-23 21:47:00 +11:00
Matt Joiner fd5da294ff bencode tests: Idiomatize identifier naming 2016-02-23 21:43:05 +11:00