Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RPC support for secure connections and HTTP proxies #820

Merged
merged 29 commits into from
Mar 24, 2021

Conversation

thanethomson
Copy link
Member

@thanethomson thanethomson commented Feb 23, 2021

Closes #819

This PR is quite a large one unfortunately, because there's no easy way to test proxied connections or secure connections (or proxied secure connections 😁). I therefore had to:

  1. Add TLS support to the RPC clients (e.g. for when the RPC endpoint's behind a reverse proxy).
  2. Add HTTP/S proxy support.
  3. Introduce a CLI called tendermint-rpc, which provides a simple interface for interacting with RPC clients over http://, https://, ws:// and wss://, as well as HTTP proxies, for testing purposes. This necessitated the development of a parser for subscription queries, because I wanted to test subscriptions from the command line too.

The documentation for the CLI is available here:

📖 Rendered tendermint-rpc CLI README

  • Referenced an issue explaining the need for the change
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG.md

Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
This is unfortunately a big commit. It primarily adds an optional binary
application (behind the "cli" feature flag) that allows you to easily
perform queries against a Tendermint endpoint via several protocols
(http, https, ws, wss).

It only contains support at present for Client queries, and
SubscriptionClient queries (i.e. subscriptions) are planned for
subsequent commits.

Some of the bulk of this commit is due to the fact that we need to be
able to parse queries (e.g. from tx_search), so I added a PEG-based
parser for queries along with some tests.

Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
@thanethomson thanethomson changed the title Add RPC support for secure connections Add RPC support for secure connections and HTTP proxies Feb 26, 2021
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
This commit refactors the RPC interface, while trying to reduce the
amount of downstream impact as far as possible, with the aim of allowing
the user to specify a generic URL as input to the HTTP and WebSocket
clients.

This allows the client to infer whether or not to use a secure
connection based on the supplied URL.

Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
…ring testing

Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
… when a client is enabled

Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
@thanethomson thanethomson marked this pull request as ready for review March 3, 2021 02:36
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Copy link
Member

@romac romac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@tony-iqlusion
Copy link
Collaborator

Note: tested and working on our end for an HTTP CONNECT egress proxy. Thank you! 🎉

@thanethomson thanethomson merged commit 630ca02 into master Mar 24, 2021
@thanethomson thanethomson deleted the thane/819-rpc-tls branch March 24, 2021 22:39
thanethomson added a commit that referenced this pull request Mar 30, 2021
* Refactor to add HTTPS client

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Switch to Rustls

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add TLS support for WebSocket connections

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add support for secure WebSocket connections

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update docs and exports

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update docs to use new link format

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Remove unused file

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add required attributes to WebSocket client markers

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Refactor out constructor common bits

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add tendermint-rpc binary

This is unfortunately a big commit. It primarily adds an optional binary
application (behind the "cli" feature flag) that allows you to easily
perform queries against a Tendermint endpoint via several protocols
(http, https, ws, wss).

It only contains support at present for Client queries, and
SubscriptionClient queries (i.e. subscriptions) are planned for
subsequent commits.

Some of the bulk of this commit is due to the fact that we need to be
able to parse queries (e.g. from tx_search), so I added a PEG-based
parser for queries along with some tests.

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add support for subscription to RPC CLI

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add support for parsing floating point numbers in RPC queries

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add termination option for subscriptions in CLI app

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update docs to describe CLI tool

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Refactor RPC to allow for generic URLs

This commit refactors the RPC interface, while trying to reduce the
amount of downstream impact as far as possible, with the aim of allowing
the user to specify a generic URL as input to the HTTP and WebSocket
clients.

This allows the client to infer whether or not to use a secure
connection based on the supplied URL.

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Fix version requirement of tendermint-proto

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update client usage to show simplified parameters

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Use tracing instead of log to show comprehensive debug information during testing

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update docs

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add query parsing examples to crate docs

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Rename ambiguous module url to rpc_url and ensure it is only exported when a client is enabled

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Improve environment variable handling for proxies

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add examples for using proxy to CLI usage docs

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Fix some README typos

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Export HTTP and WebSocket URL types to surface documentation

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add CHANGELOG entries

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Clarify directory for tendermint-rpc CLI

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add HTTP/2 support for HTTP client

Signed-off-by: Thane Thomson <connect@thanethomson.com>
@thanethomson thanethomson mentioned this pull request Sep 5, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for https proxies in Tendermint RPC
3 participants