An open API service indexing awesome lists of open source software.

https://github.com/tomusdrw/jsonrpc-proxy

A generic and extensible JSON-RPC proxy, supporting cache and load-balancing.
https://github.com/tomusdrw/jsonrpc-proxy

Last synced: 7 months ago
JSON representation

A generic and extensible JSON-RPC proxy, supporting cache and load-balancing.

Awesome Lists containing this project

README

          

jsonrpc-proxy
=================================
# Status

This library has not been updated in a while and is here just for archive purposes. You might consider looking at https://github.com/AcalaNetwork/subway which is supposed to serve the same purpose and is way more recent.

# Overview

The proxy has a pluggable architecture of middlewares. Each middleware receives every RPC call and can decide to either terminate it (return a response) or pass it forward to the next middleware. Middlewares are also able to modify the response object.

As the last middleware we are using `Upstream` middleware, which is responsible for calling the target node.

Middlewares included in this repo:

- Simple caching middleware
- Simple permissioning middleware
- WebSockets upstream middleware

Similarly pluggable are JSON-RPC transports that the proxy exposes. Currently supported:
- TCP server
- HTTP server
- IPC server
- WebSockets server

![Proxy Overview](./overview.svg)

# Ideas

- [ ] Rate Limitting
- [ ] Fail over
- [ ] Load balancing

# Usage

```
rpc-proxy 0.1
Parity Technologies Ltd
Generic RPC proxy, featuring caching and load balancing.

USAGE:
rpc-proxy [OPTIONS]

FLAGS:
-h, --help Prints help information
-V, --version Prints version information

OPTIONS:
--cached-methods-path
A path to a JSON file containing a list of methods that should be
cached. See examples for the file schema. [default: -]
--http-cors
Specify CORS header for HTTP JSON-RPC API responses.Special options:
"all", "null", "none". [default: none]
--http-cors-max-age
Configures AccessControlMaxAge header value in milliseconds.Informs
the client that the preflight request is not required for the
specified time. Use 0 to disable. [default: 3600000]
--http-hosts
List of allowed Host header values. This option willvalidate the
Host header sent by the browser, it isadditional security against
some attack vectors. Specialoptions: "all", "none". [default: none]
--http-ip
Configures HTTP server interface. [default: 127.0.0.1]

--http-max-payload
Maximal HTTP server payload in Megabytes. [default: 5]

--http-port
Configures HTTP server listening port. [default: 9934]

--http-rest-api
Enables REST -> RPC converter for HTTP server. Allows you tocall RPC
methods with `POST ///`.The "secure"
option requires the `Content-Type: application/json`header to be
sent with the request (even though the payload is ignored)to prevent
accepting POST requests from any website (via form submission).The
"unsecure" option does not require any `Content-Type`.Possible
options: "unsecure", "secure", "disabled". [default: disabled]
--http-threads
Configures HTTP server threads. [default: 4]

--ipc-path
Configures IPC server socket path. [default: ./jsonrpc.ipc]

--ipc-request-separator
Configures TCP server request separator (single byte). If "none" the
parser will try to figure out requests boundaries. [default: none]
--tcp-ip
Configures TCP server interface. [default: 127.0.0.1]

--tcp-port
Configures TCP server listening port. [default: 9955]

--tcp-request-separator
Configures TCP server request separator (single byte). If "none" the
parser will try to figure out requests boundaries. Default is new
line character. [default: 10]
--upstream-ws
Address of the parent WebSockets RPC server that we should connect
to. [default: ws://127.0.0.1:9944]
--websockets-hosts
List of allowed Host header values. This option will validate the
Host header sent by the browser, it is additional security against
some attack vectors. Special options: "all", "none". [default: none]
--websockets-ip
Configures WebSockets server interface. [default: 127.0.0.1]

--websockets-max-connections
Maximum number of allowed concurrent WebSockets JSON-RPC
connections. [default: 100]
--websockets-origins
Specify Origin header values allowed to connect. Special options:
"all", "none". [default: none]
--websockets-port
Configures WebSockets server listening port. [default: 9945]
```