miguelmota / go-rpc-provider-proxy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-rpc-provider-proxy

A simple Go HTTP server that proxies RPC provider requests.

Getting started

# terminal 1
$ go run cmd/proxy/main.go -proxy-url="https://kovan.infura.io/v3/84842078b09946638c03157f83405213" -proxy-method=POST -port=8000
Proxying POST https://kovan.infura.io/v3/84842078b09946638c03157f83405213
Listening on port 8000

# terminal 2
$ curl http://localhost:8000 -X POST -H "content-type: application/json" -d '{"method":"eth_getCode","params":["0xf2b139bd79e08f9273e6a3dc2702051e1b16cdf8","latest"],"id":13009,"jsonrpc":"2.0"}'

Authorization header example:

# terminal 1
$ go run cmd/proxy/main.go -proxy-url="https://kovan.infura.io/v3/84842078b09946638c03157f83405213" -proxy-method=POST -port=8000 -auth-secret=mysecret

# terminal 2
$ echo -n mysecret | openssl base64
bXlzZWNyZXQ=

$ curl http://localhost:8000 -X POST -H "content-type: application/json" -H "Authorization: Bearer bXlzZWNyZXQ=" -d '{"method":"eth_getCode","params":["0xf2b139bd79e08f9273e6a3dc2702051e1b16cdf8","latest"],"id":13009,"jsonrpc":"2.0"}'

Test

Run load testing script:

make loadtest

Development

Build and push docker image to registry:

make docker-build-and-push

License

MIT

About

License:MIT License


Languages

Language:Go 88.5%Language:Makefile 5.7%Language:Dockerfile 2.6%Language:Lua 2.2%Language:Shell 1.0%