Commit Graph

27 Commits

Author SHA1 Message Date
Neil Booth
2a461bd98c Serve sessions in a priority queue.
Add new RPC command requests.
Adjust sessions RPC command to show pending requests.
Only keep first 15 chars in version string.
Set socket timeout
Try more forceful closing of socket
Fixes #67
2016-12-09 22:06:04 +09:00
Neil Booth
1a9e8cdcd4 More work 2016-12-09 08:06:03 +09:00
Neil Booth
cbb1e504cc Cache headers. 2016-12-08 06:31:15 +09:00
Neil Booth
e40db63beb Queue requests, which have a process method. 2016-12-08 00:29:46 +09:00
Neil Booth
4e512343be Fix other JSON bugs introduced in 0.8.5
Further clean up the JSON code.
2016-12-07 19:44:36 +09:00
Shane Moore
e17a9ee2c7 Update RPC client for JSON rework and add missing arg in json_request_text
Fixes #60
2016-12-07 00:25:43 -08:00
Neil Booth
f904ce2f5d Rework the JSON layer
Batch requests are now processed and encoded incrementally.
Their bandwidth usage is also incrementally added, and so overlarge
responses are rejected as soon as they become too large.
JSON text is also more memory efficient than the python data
structures they represent.
2016-12-07 08:11:30 +09:00
Neil Booth
b116040365 Clean up param verification code 2016-12-07 08:11:29 +09:00
Neil Booth
be8adbbcd5 Fix some typos. 2016-12-04 23:41:07 +09:00
Neil Booth
ab9d9f7c07 Reduce bandwith usage over the bandwith interval
So if e.g. your limit is 10MB per hour, then every minute
your cumulative usage will be reduced by 1/6MB.
2016-12-03 23:32:20 +09:00
Neil Booth
c4e7878407 Add session ID for each session
Show it in the logs with each session-specific message.
Show the sessions ID in the sessions list with an L suffix if logging.
Add RPC commands to toggle logging of, and disconnect, a session.
Closes #55
2016-12-03 14:32:09 +09:00
Neil Booth
3d2824218b Close stale sessions
New envvar SESSION_TIMEOUT
A session with no activity is cut off after this time
Fixes #56
2016-12-03 13:06:20 +09:00
Neil Booth
625508f5c6 Send no ID for batch request errors
Fixes #54
2016-12-03 10:56:55 +09:00
Neil Booth
a412531ccb Fix typos in docs 2016-11-30 21:06:25 +09:00
Neil Booth
15a88600eb Upped read buffer limit to 1m bytes
This accomodates large tx sends of up to 500k bytes.
However they are unlikely to be propogated by your daemon as the
default relay limit it imposes is 100K.
2016-11-30 07:26:34 +09:00
Neil Booth
b65bcda504 Add per-session bandwidth limits 2016-11-29 22:19:12 +09:00
Neil Booth
c9a10be5ba Introduce incoming buffer size limit
- incoming buffered network requests limited to 150,000 bytes
  which I believe is ample for a genuine client
- if exceeded, the connection is dropped
- raise outgoing data limit for RPC connections to 5 MB - expect
  sessions calls can be long and connection is implicitly trusted
- similarly raise incoming buffered data limit to 5 MB for RPC
  connections
2016-11-29 20:24:58 +09:00
Neil Booth
b2032b0a66 Fix 2 JSON RPC issues 2016-11-27 21:54:05 +09:00
Neil Booth
292073f2c7 Log large requests and reject them 2016-11-26 09:32:29 +09:00
Neil Booth
42c00d32d2 Rewrite lib/jsonrpc.py to be a useful client too
Use for an improved electrumx_rpc.py, so it now handles responses spread
over several packets.  Also added a timeout of 5 seconds.

Fixes #43
2016-11-25 21:19:43 +09:00
Neil Booth
cebf93cdc3 Handle abuse better
- close connections on any encoding error
- if the connection is closing do not process buffered requests
2016-11-23 11:52:17 +09:00
Neil Booth
11ed1c4cae Don't log decoding errors any more
The can be frequent.
Close connections once they reach 10 errors.
2016-11-22 06:45:22 +09:00
Neil Booth
95bb1588ab Add missing await 2016-11-14 19:15:36 +09:00
Neil Booth
41fb143947 Fix typo 2016-11-13 23:18:04 +09:00
Neil Booth
0c2b4afbdc Remove a debug log 2016-11-13 22:40:26 +09:00
Neil Booth
57dd4ece9c Avoid annoying exception on shutdown 2016-11-13 17:52:08 +09:00
Neil Booth
3b6ab77e47 Break out JSONRPC into own file
- improved handling of JSON 2.0 RPC protocol
- permits batched requests (not yet supported by Electrum client)
2016-11-13 13:39:37 +09:00