mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 23:04:35 +01:00
jsonrpc: only allow a single command at a time.
There's a DoS if we keep reading commands and don't insist the client read the responses. My initial implementation simply removed the io_duplex, but that doesn't work if we want to inject notifications in the stream (as we will eventually want to do), so we operate it as duplex but have each side wake the other when it's done. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -22,8 +22,6 @@ enum command_mode {
|
||||
/* Context for a command (from JSON, but might outlive the connection!)
|
||||
* You can allocate off this for temporary objects. */
|
||||
struct command {
|
||||
/* Off jcon->commands */
|
||||
struct list_node list;
|
||||
/* The global state */
|
||||
struct lightningd *ld;
|
||||
/* The 'id' which we need to include in the response. */
|
||||
@@ -60,10 +58,10 @@ struct json_connection {
|
||||
/* We've been told to stop. */
|
||||
bool stop;
|
||||
|
||||
/* Current commands. */
|
||||
struct list_head commands;
|
||||
/* Current command. */
|
||||
struct command *command;
|
||||
|
||||
struct list_head output;
|
||||
/* Current command's output. */
|
||||
const char *outbuf;
|
||||
struct io_lock *lock;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user