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
Matt Joiner
f470f04d8f
bencode: Use the testdata convention in tests
2016-02-23 21:31:15 +11:00
Matt Joiner
ff835db955
Actually fix #41 properly; and several big changes
...
bencode:
* Handle omitempty on non-trivial types.
cmd/dht-ping:
* Handle timeouts in ping transactions.
dht:
* Propagate failed transaction responses properly.
* Msg related tests are moved into their own file.
* In some places, IPs in binary form are shorted to 4 bytes if IPv4.
2015-12-07 03:28:28 +11:00
Matt Joiner
5f4fdfbd3d
bencode: Improve unknown value type error
2015-11-03 23:21:10 +11:00
Matt Joiner
47a2453098
bencode: Can't get zero type of a nil interface
2015-10-23 12:37:30 +11:00
Matt Joiner
837bdd2ccf
bencode: Rethrow non-errors during encoding
2015-10-23 12:36:47 +11:00
Matt Joiner
1fb64de07c
bencode: Encoding nil interfaces are an error except at data root
2015-10-23 12:35:38 +11:00
Matt Joiner
4b539b1f11
bencode: Don't skip encoding nil pointers and interfaces
...
This caused an annoying bug for complex types where dictionary values went missing.
2015-10-19 01:28:36 +11:00
Matt Joiner
ddf7cbbdac
bencode: Use default field name if it isn't given (but options are)
2015-10-19 01:27:15 +11:00
Matt Joiner
644ee0a244
bencode: Tidy up
2015-10-19 01:25:56 +11:00
Matt Joiner
28c1536daf
bencode: When decoding a dict, if the final key is missing its value, don't treat that as an error.
...
I think I'm swayed here by the robustness principle/Postel's Law.
2015-10-02 00:13:43 +10:00
Matt Joiner
87158e594a
Derp
2015-09-20 21:09:55 +10:00
Matt Joiner
8949375bd6
bencode: Decode very large integers as big.Int if they overflow int64
2015-09-20 21:08:42 +10:00
Matt Joiner
a101f9bcbd
bencode: Remove trailing bytes checks, this broke the peer protocol and should be a new API
2015-08-23 19:24:29 +10:00
Matt Joiner
577ea21793
Revert "bencode: Trailing bytes on Unmarshal is an error"
...
This reverts commit ad73a0ea89
.
2015-08-23 19:10:22 +10:00
Matt Joiner
0403d4185d
bencode: Simplify parse_int
2015-08-23 17:51:24 +10:00
Matt Joiner
ad73a0ea89
bencode: Trailing bytes on Unmarshal is an error
2015-08-23 17:47:01 +10:00
Matt Joiner
2ccbaa4e79
bencode: Don't allow extraneous trailing 'e's
2015-08-23 17:45:59 +10:00
Matt Joiner
baf389aa8c
bencode: Add tests for Unmarshalling trailing bytes, and extraneous 'e'
2015-08-23 16:13:30 +10:00
Matt Joiner
4fbbc0dd41
bencode: Fuzz
2015-08-23 15:59:49 +10:00
Matt Joiner
4f293ca75b
Several trivial fixes
2015-06-28 16:39:04 +10:00
Matt Joiner
d3c5a4f92c
bencode: gofmt
2015-04-30 00:36:25 +10:00
Matt Joiner
916c9c822a
Decoding bools has been wrong all along, always set to true
2014-12-01 23:28:47 -06:00
Matt Joiner
cdfba7a1ac
Expose SyntaxError reason with a proper error
2014-11-18 22:08:08 -06:00
Matt Joiner
7e2c384bd5
Fix buffer reuse bug and some formatting.
2014-03-20 01:54:18 +11:00
nsf
d0429086be
Add more comments to the bencode library. Implement UnmarshalerError.
2012-06-30 22:26:20 +06:00
nsf
0b385a409b
Add first bits of "torrent" library (.torrent file manipulation).
...
Add missing testdata for bencode also.
2012-06-28 02:26:56 +06:00
nsf
e553531a10
Fix bugs, implement missing bits. Made a mess, can't describe properly.
2012-06-28 02:21:26 +06:00
nsf
110956d936
Fix Marshaler case.
2012-06-24 17:10:53 +06:00
nsf
69d1e17b80
Add MarshalBencode test.
2012-06-24 17:10:27 +06:00
nsf
8db0c29da9
Add bufio.Writer error handling, move Flush to the internal code.
2012-06-24 16:59:04 +06:00
nsf
27b64a002c
Add a couple of decode tests, fix empty slice bug.
2012-06-22 19:34:26 +06:00
nsf
f8f98eb7cd
Add missing interface definitions.
2012-06-22 19:34:04 +06:00
nsf
57c1403300
Uncomment defer recover statement.
2012-06-20 19:34:10 +06:00
nsf
a68e4a6f5a
Initial commit.
2012-06-20 19:21:32 +06:00