Skip to content

Instantly share code, notes, and snippets.

@gnunicorn
Created June 4, 2018 18:33
Show Gist options
  • Save gnunicorn/b7a6410a868e030a5f299aa81a85c0a2 to your computer and use it in GitHub Desktop.
Save gnunicorn/b7a6410a868e030a5f299aa81a85c0a2 to your computer and use it in GitHub Desktop.
testing connection leaking of parity's jsonrpc
[package]
name = "json-rpc-tester"
version = "0.1.0"
authors = ["Benjamin Kampmann <[email protected]>"]
[dependencies]
jsonrpc-ipc-server = { git = "https://github.com/paritytech/jsonrpc.git" }
jsonrpc-pubsub = { git = "https://github.com/paritytech/jsonrpc.git" }
log = "*"
env_logger = "*"
# output of `RUST_LOG=ipc=trace cargo run`
# [...]
Running `target/debug/json-rpc-tester`
TRACE 2018-06-04T18:28:29Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 1
TRACE 2018-06-04T18:28:29Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:29Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 2
TRACE 2018-06-04T18:28:29Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:29Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 3
TRACE 2018-06-04T18:28:29Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:29Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 4
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 5
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 6
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 7
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 8
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 9
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 10
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 11
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 12
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 13
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:30Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 14
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 15
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 16
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 17
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 18
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 19
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 20
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 21
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 22
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:31Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 23
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 24
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 25
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 26
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 27
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 28
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 29
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 30
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 31
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 32
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:32Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 33
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 34
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 35
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 36
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 37
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 38
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 39
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 40
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 41
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 42
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:33Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 43
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 44
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 45
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 46
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 47
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 48
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 49
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 50
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 51
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 52
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:34Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 53
TRACE 2018-06-04T18:28:35Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:35Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 54
TRACE 2018-06-04T18:28:35Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:35Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 55
TRACE 2018-06-04T18:28:35Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:35Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 56
TRACE 2018-06-04T18:28:35Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:35Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 57
TRACE 2018-06-04T18:28:35Z: jsonrpc_ipc_server::server: Peer: service finished
TRACE 2018-06-04T18:28:35Z: jsonrpc_ipc_server::server: Accepted incoming IPC connection: 58
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate jsonrpc_ipc_server;
extern crate jsonrpc_pubsub;
use jsonrpc_ipc_server::ServerBuilder;
use jsonrpc_ipc_server::jsonrpc_core::*;
fn main() {
env_logger::init();
let mut io = IoHandler::new();
io.add_method("say_hello", |_params| {
Ok(Value::String("hello".into()))
});
ServerBuilder::new(io)
.start("/tmp/json-ipc-test.ipc")
.expect("Couldn't open socket")
.wait()
}
#!/bin/sh -e
# run with socket as first CLI param, like so:
# bash test-script.sh /tmp/json-ipc-test.ipc
for i in `seq 0 1000`
do
echo $i
nc -U $1 </dev/null >/dev/null &
pid=$!
sleep 0.1
kill $pid
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment