Commit graph

137 commits

Author SHA1 Message Date
Yuxin Wang
f66ba78999 Close the socket after calling _client_closed.
Subclass might use the client's information.
2018-10-01 23:55:02 -04:00
Yuxin Wang
d6a66bb1f7 Move closed error warning into subclasses. 2018-10-01 23:54:01 -04:00
Yuxin Wang
439ed70c6f Stringfy the peer address.
JSON requires that the keys in dict must be strings.
2018-10-01 23:33:03 -04:00
Yuxin Wang
5345ac37e1 Move finally block to the end. 2018-10-01 23:32:06 -04:00
Yuxin Wang
55dde948a9 No need to iterate address. 2018-10-01 22:46:45 -04:00
Yuxin Wang
3cd897ab0f Remove dead code. 2018-10-01 22:46:33 -04:00
Yuxin Wang
441a8fd11a Move the position of the method. 2018-10-01 22:46:26 -04:00
Yuxin Wang
854d1676bb Return boolean value for start method. 2018-10-01 22:30:46 -04:00
Yuxin Wang
97b2a34bef Connect to peers when downloading. 2018-10-01 22:20:04 -04:00
Yuxin Wang
eb3f5c99ae Store peer address instead of IDs. 2018-10-01 22:19:44 -04:00
Yuxin Wang
69c134f96d Use address tuple instead of separate (ip, port). 2018-10-01 22:18:48 -04:00
Yuxin Wang
70136b99c1 Remove log for peers member. 2018-10-01 22:01:18 -04:00
Yuxin Wang
cd89348b1b Simplify REQUEST_REGISTER.
Don't have to know the peer_list when register, only acquire when downloading.
2018-10-01 21:56:36 -04:00
Yuxin Wang
a755f21fd1 Remove peers member.
We don't have to maintain the list of peers since we only connect when needed.
2018-10-01 21:53:07 -04:00
Yuxin Wang
f5776ed9cd Remove _server_started signal. 2018-10-01 21:52:24 -04:00
Yuxin Wang
488987a326 Return True/False for start method. 2018-10-01 21:47:53 -04:00
Yuxin Wang
5fb1142862 Remove PEER_GREET message. 2018-10-01 21:40:36 -04:00
Yuxin Wang
4819f1fb0b Copy a set to prevent changes of set's size. 2018-10-01 20:45:53 -04:00
Yuxin Wang
90095353a2 Add timeout for server socket.
socket.accept() now will timeout in _listen method.
2018-10-01 20:16:00 -04:00
Yuxin Wang
8931aee7d2 Use pip to install codecov. 2018-10-01 16:54:21 -04:00
Yuxin Wang
ca44603284 Manage the threads. 2018-10-01 16:16:10 -04:00
Yuxin Wang
468df73f08 Add timeout to prevent forever waiting. 2018-10-01 15:18:12 -04:00
Yuxin Wang
2450554ffb Start server after test files are created. 2018-10-01 15:17:53 -04:00
Yuxin Wang
8b6dc6a875 Use base class' stop.
The initiative connection is now managed by the base class.
2018-10-01 00:14:59 -04:00
Yuxin Wang
8db86a7ab4 Use with statement. 2018-10-01 00:14:26 -04:00
Yuxin Wang
590e9cd93f Add initiative connections to connection set. 2018-10-01 00:14:16 -04:00
Yuxin Wang
9bd517fd4f Fix exception capture. 2018-10-01 00:13:30 -04:00
Yuxin Wang
6d06b7900c Add more notes. 2018-10-01 00:13:18 -04:00
Yuxin Wang
e6e996abf9 Use set to manage the connections. 2018-10-01 00:12:58 -04:00
Yuxin Wang
54bc2c901a Replace exit with stop. 2018-09-30 14:22:55 -04:00
Yuxin Wang
b777ebb616 Fix peer name. 2018-09-30 13:49:24 -04:00
Yuxin Wang
e01da09179 Exit when test finishes. 2018-09-30 13:32:07 -04:00
Yuxin Wang
430bb51a21 Upload travis config file. 2018-09-30 11:08:48 -04:00
Yuxin Wang
78d4bbb147 BaseServer handles the close of all connections. 2018-09-30 11:00:44 -04:00
Yuxin Wang
b3eaf0c33c Make is_running protected member. 2018-09-30 11:00:11 -04:00
Yuxin Wang
f34e96b077 Add stop method to properly close all connections. 2018-09-30 10:48:54 -04:00
Yuxin Wang
a2c803876a Add return True to exit the cmd loop. 2018-09-30 10:48:27 -04:00
Yuxin Wang
81fb413818 Add simple test. 2018-09-30 10:12:02 -04:00
Yuxin Wang
9b6ddc1940 start listening before accepting clients.
To prevent gaps between calls to start() and clients' connecting.
2018-09-30 10:11:45 -04:00
Yuxin Wang
b161e1dff5 Allow progress fucntion to be none. 2018-09-30 10:10:29 -04:00
Yuxin Wang
d6601b0cec Lazy connection to server for peer. 2018-09-30 10:10:15 -04:00
Yuxin Wang
cc5bbc4701 Initial commit of test module. 2018-09-29 23:42:35 -04:00
Yuxin Wang
f09accc254 Add tox and setup config files. 2018-09-29 23:42:00 -04:00
Yuxin Wang
6f3e3fa1df Add import in __init__ file. 2018-09-29 23:38:54 -04:00
Yuxin Wang
b2bee06af9 Remove unused module. 2018-09-28 00:30:37 -04:00
Yuxin Wang
6e5bf1e4f4 Remove connection lock as it is unnecessary. 2018-09-27 14:30:03 -04:00
Yuxin Wang
90d36db04a Output only ERROR message. 2018-09-27 14:25:31 -04:00
Yuxin Wang
87e84d5f3f Use Peer.CHUNK_SIZE instead of magic number. 2018-09-27 14:25:21 -04:00
Yuxin Wang
4181cfacf3 Abstract CHUNK_SIZE for better management. 2018-09-27 14:20:27 -04:00
Yuxin Wang
9ebf02d2d2 Send fileinfo and chunknum to server.
Server doesn't need to know much detail about the file.
2018-09-27 14:18:57 -04:00