Jesse Li
8aa4a57933
Add circleci file
2020-01-02 21:42:44 -05:00
Jesse Li
67d6a6808c
Test the client
2020-01-02 21:28:15 -05:00
Jesse Li
b59125b5b7
Rip out reader code
2020-01-02 19:36:25 -05:00
Jesse Li
e9edc62c57
Split client into its own package
2020-01-02 15:34:25 -05:00
Jesse Li
f46d43985a
Test tracker
2020-01-02 13:07:59 -05:00
Jesse Li
0050772d42
Update handshake comments
2020-01-02 12:31:41 -05:00
Jesse Li
669f15ec75
Remove support for MsgPort
2020-01-02 12:30:17 -05:00
Jesse Li
81a6437145
More informative comments for message IDs
2020-01-02 12:29:10 -05:00
Jesse Li
b3beb5ed2a
Check infohash in handshake
2020-01-02 12:26:54 -05:00
Jesse Li
b3ee9f4117
Use clearer names for functions that send messages
2020-01-02 12:23:22 -05:00
Jesse Li
b255ecc574
Fix torrentfile TestOpen
2020-01-02 12:20:41 -05:00
Jesse Li
b3299a6bfa
Simplify download interface
2020-01-02 12:17:45 -05:00
Jesse Li
06b849a44d
Fix bug which produced incorrect piece size
2020-01-02 11:49:08 -05:00
Jesse Li
873008bb96
Caveat that Download stores the file in memory
2020-01-02 10:51:13 -05:00
Jesse Li
22fc59dae3
Small refactor of downloadState
...
Renames the struct to pieceProgress and makes readMessage/readMessages
methods of the struct instead of arguments, to make it a little bit
clearer that they modify the struct in-place.
2020-01-02 10:47:02 -05:00
Jesse Li
d4f6d1265d
Check error in request to client
2020-01-02 10:44:08 -05:00
Jesse Li
70713e028d
Fix race condition
...
The download loop might finish and kill the worker goroutine before it's
done sending HAVE messages. Switching the order of these two lines
trivially fixes the issue (but it's still brittle)
2020-01-02 10:41:24 -05:00
Jesse Li
73a9a5216b
Break p2p.Peer and parsePeers into its own package
2020-01-02 10:39:35 -05:00
Jesse Li
25810161eb
Add timeout to tracker GET request
2020-01-02 10:34:47 -05:00
Jesse Li
17e57b6dd6
Rename getPeers to requestPeers
2020-01-02 10:32:20 -05:00
Jesse Li
cc088e8b79
Only use fmt.Errorf
2020-01-02 10:30:30 -05:00
Jesse Li
4f6a2eb20e
Make peerSize a const
2020-01-02 10:28:58 -05:00
Jesse Li
4fd40f9f0a
Return plain struct from toTorrentFile
2020-01-02 10:27:00 -05:00
Jesse Li
7e8b3413ac
Check error in getPeers
2020-01-02 10:23:18 -05:00
Jesse Li
f746beb9d6
Remove log in torrentfile
2020-01-02 10:22:52 -05:00
Jesse Li
9c6bf79e61
Rename toTorrent to toTorrentFile
2019-12-31 23:36:27 -05:00
Jesse Li
acd4fe9c62
Implement golden file test for torrentfile.Open
2019-12-31 12:18:18 -05:00
Jesse Li
a5e2137e37
Update README.md
2019-12-30 10:56:35 -05:00
Jesse
487337a08a
Add bounds checking to bitfield
...
This way, we don't panic when we get an invalid HAVE message
2019-12-30 10:34:43 -05:00
Jesse
402e4e1665
Correct the size of a piece
...
Previously confused piece vs block
2019-12-30 10:23:15 -05:00
Jesse
928bbfeab4
Simplify download algorithm
2019-12-30 10:21:26 -05:00
Jesse
46b55339aa
Fix unit in comment about block size
2019-12-29 22:47:32 -05:00
Jesse
23f3a144af
Add logging around tracker and number of peers
2019-12-29 21:59:33 -05:00
Jesse
67066ad77c
Set 30 second deadline for pieces to download
2019-12-29 21:44:07 -05:00
Jesse
c4fbd50021
Make MaxBlockSize and MaxBacklog public
2019-12-29 20:59:10 -05:00
Jesse Li
92974b393a
Update README.md
2019-12-29 20:54:51 -05:00
Jesse Li
6d7c786022
Create LICENSE
2019-12-29 20:47:44 -05:00
Jesse
648d87a2d0
Comments for bitfield SetPiece test cases
2019-12-29 20:44:11 -05:00
Jesse
3b7eb1da70
Separate bitfield into its own package
2019-12-29 20:24:06 -05:00
Jesse Li
353d112e4d
Create README.md
2019-12-29 20:08:03 -05:00
Jesse
43d771aa0d
Remove commented out code
2019-12-29 19:56:06 -05:00
Jesse
5a57bde05a
Use slightly more correct handling of choking
2019-12-29 19:51:17 -05:00
Jesse
a8274e966b
Add go mod files
2019-12-29 19:36:24 -05:00
Jesse
97dbe49f57
Increase backlog to 5
2019-12-29 19:32:44 -05:00
Jesse
97f2be0747
Reorder algorithm steps
2019-12-29 19:26:57 -05:00
Jesse
0a5176e4ee
Decrease backlog
2019-12-29 19:14:44 -05:00
Jesse
ff89aa406c
Cleaner algorithm for downloading piece
2019-12-29 19:06:45 -05:00
Jesse
dced33b933
Report more accurate count of workers
2019-12-29 15:15:53 -05:00
Jesse
ffa8c82919
Rename downloadWorker to startDownloadWorker
2019-12-29 15:12:20 -05:00
Jesse
738af57ef1
Move big switch into a function
2019-12-29 15:06:17 -05:00