├── rust-toolchain ├── .github ├── CODEOWNERS ├── workflows │ ├── conventional-commits.yml │ ├── lint.yml │ ├── fmt.yml │ ├── test.yml │ └── release.yml ├── CONTRIBUTING.md └── CODE_OF_CONDUCT.md ├── src ├── config │ ├── mod.rs │ ├── dns_canister_rule.rs │ └── dns_canister_config.rs ├── main.rs ├── metrics.rs ├── proxy │ ├── forward.rs │ ├── mod.rs │ └── agent.rs ├── headers.rs ├── logging.rs ├── validate.rs ├── canister_id.rs └── http_client.rs ├── .gitignore ├── README.md ├── .mergify.yml ├── Cargo.toml ├── LICENSE └── Cargo.lock /rust-toolchain: -------------------------------------------------------------------------------- 1 | 1.60.0 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @dfinity/boundary-node 2 | -------------------------------------------------------------------------------- /src/config/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dns_canister_config; 2 | mod dns_canister_rule; 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | .vscode 4 | 5 | /.idea/ 6 | 7 | # will have compiled files and executables 8 | /target/ 9 | 10 | # These are backup files generated by rustfmt 11 | **/*.rs.bk 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `icx-proxy` 2 | A command line tool to serve as a gateway for a Internet Computer replica. 3 | 4 | ## Contributing 5 | Please follow the guidelines in the [CONTRIBUTING.md](.github/CONTRIBUTING.md) document. 6 | 7 | ## Installing `icx-proxy` 8 | One can install `icx-proxy` by running cargo; 9 | 10 | ```bash 11 | cargo install icx-proxy 12 | ``` 13 | 14 | ## Usage 15 | Once installed, using `icx-proxy --help` will show the usage message and all the flags. 16 | 17 | ## Ecosystem 18 | This is similar in principle to `dfx bootstrap`, but is simpler and more configurable. This also can replace a Replica when using the `--network` flag in `dfx`. 19 | -------------------------------------------------------------------------------- /.github/workflows/conventional-commits.yml: -------------------------------------------------------------------------------- 1 | name: Check PR title 2 | on: 3 | pull_request_target: 4 | types: 5 | - opened 6 | - reopened 7 | - edited 8 | - synchronize 9 | 10 | jobs: 11 | check: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: dfinity/conventional-pr-title-action@v2.2.3 15 | with: 16 | success-state: Title follows the specification. 17 | failure-state: Title does not follow the specification. 18 | context-name: conventional-pr-title 19 | preset: conventional-changelog-angular@latest 20 | env: 21 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 22 | -------------------------------------------------------------------------------- /.mergify.yml: -------------------------------------------------------------------------------- 1 | pull_request_rules: 2 | - name: Automatic merge 3 | conditions: 4 | - "#approved-reviews-by>=1" 5 | - "#changes-requested-reviews-by=0" 6 | - status-success=conventional-pr-title 7 | - label=automerge-squash 8 | actions: 9 | merge: 10 | method: squash 11 | strict: smart 12 | commit_message: title+body 13 | delete_head_branch: {} 14 | 15 | - name: Clean up automerge tags 16 | conditions: 17 | - closed 18 | actions: 19 | label: 20 | remove: 21 | - automerge-squash 22 | 23 | - name: Auto-approve auto-PRs 24 | conditions: 25 | - author=dfinity-bot 26 | actions: 27 | review: 28 | type: APPROVE 29 | message: This bot trusts that bot 30 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | test: 7 | name: lint 8 | runs-on: ${{ matrix.os }} 9 | strategy: 10 | matrix: 11 | rust: [ '1.60.0' ] 12 | os: [ ubuntu-latest ] 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - uses: actions/cache@v2 18 | with: 19 | path: | 20 | ~/.cargo/registry 21 | ~/.cargo/git 22 | target 23 | key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} 24 | 25 | - name: Install Rust 26 | run: | 27 | rustup update ${{ matrix.rust }} --no-self-update 28 | rustup component add clippy 29 | rustup default ${{ matrix.rust }} 30 | - name: Run Lint 31 | run: cargo clippy --verbose --tests --benches -- -D clippy::all 32 | env: 33 | RUST_BACKTRACE: 1 34 | -------------------------------------------------------------------------------- /.github/workflows/fmt.yml: -------------------------------------------------------------------------------- 1 | name: Format 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | test: 7 | name: fmt 8 | runs-on: ${{ matrix.os }} 9 | strategy: 10 | matrix: 11 | rust: [ '1.60.0' ] 12 | os: [ ubuntu-latest ] 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - name: Cache Cargo 18 | uses: actions/cache@v2 19 | with: 20 | path: | 21 | ~/.cargo/registry 22 | ~/.cargo/git 23 | target 24 | key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1 25 | 26 | - name: Install Rust 27 | run: | 28 | rustup update ${{ matrix.rust }} --no-self-update 29 | rustup default ${{ matrix.rust }} 30 | rustup component add rustfmt 31 | - name: Run Cargo Fmt 32 | run: cargo fmt --all -- --check 33 | env: 34 | RUST_BACKTRACE: 1 35 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | test: 11 | runs-on: ${{ matrix.os }} 12 | strategy: 13 | matrix: 14 | rust: [ '1.60.0' ] 15 | os: [ ubuntu-latest, macos-latest, windows-latest ] 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | 20 | - uses: actions/cache@v2 21 | with: 22 | path: | 23 | ~/.cargo/registry 24 | ~/.cargo/git 25 | target 26 | key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1 27 | 28 | - name: Install Rust 29 | run: | 30 | rustup update ${{ matrix.rust }} --no-self-update 31 | rustup default ${{ matrix.rust }} 32 | 33 | - name: Run Tests 34 | shell: bash 35 | run: | 36 | # Test all features and no features for each package. 37 | for p in $(cargo metadata --no-deps --format-version 1 | jq -r .packages[].manifest_path); do 38 | pushd $(dirname $p) 39 | cargo test --all-targets --all-features 40 | cargo test --all-targets --no-default-features 41 | popd 42 | done 43 | env: 44 | RUST_BACKTRACE: 1 45 | 46 | - name: Purge for OSX 47 | if: matrix.os == 'macos-latest' 48 | run: | 49 | # There is a bug with BSD tar on macOS where the first 8MB of the file are 50 | # sometimes all NUL bytes. See https://github.com/actions/cache/issues/403 51 | # and https://github.com/rust-lang/cargo/issues/8603 for some more 52 | # information. An alternative solution here is to install GNU tar, but 53 | # flushing the disk cache seems to work, too. 54 | sudo /usr/sbin/purge 55 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "icx-proxy" 3 | version = "0.10.1" 4 | authors = ["DFINITY Stiftung "] 5 | edition = "2018" 6 | description = "CLI tool to create an HTTP proxy to the Internet Computer." 7 | homepage = "https://docs.rs/icx-proxy" 8 | documentation = "https://docs.rs/icx-proxy" 9 | license = "Apache-2.0" 10 | readme = "README.md" 11 | categories = ["command-line-interface", "web-programming::http-server"] 12 | keywords = ["internet-computer", "agent", "icp", "dfinity", "proxy"] 13 | include = ["src", "Cargo.toml", "../LICENSE", "README.md"] 14 | 15 | [[bin]] 16 | name = "icx-proxy" 17 | path = "src/main.rs" 18 | 19 | [dependencies] 20 | anyhow = "1" 21 | axum = "0.5" 22 | base64 = "0.13" 23 | candid = { version = "0.7", features = ["mute_warnings"] } 24 | clap = { version = "4", features = ["cargo", "derive"] } 25 | flate2 = "1" 26 | form_urlencoded = "1" 27 | futures = "0.3" 28 | garcon = { version = "0.2", features = ["async"] } 29 | hex = "0.4" 30 | http-body = "0.4" 31 | hyper = { version = "0.14.11", features = ["client", "http2", "http1"] } 32 | hyper-rustls = { version = "0.23", features = [ "webpki-roots", "http2" ] } 33 | itertools = "0.10" 34 | ic-agent = { version = "0.20.1", default-features = false, features = ["hyper"] } 35 | ic-utils = { version = "0.20.1", features = ["raw"] } 36 | lazy-regex = "2" 37 | opentelemetry = "0.17" 38 | opentelemetry-prometheus = "0.10" 39 | prometheus = "0.13" 40 | rustls = { version = "0.20", features = ["dangerous_configuration"] } 41 | rustls-pemfile = "1" 42 | tower = "0.4" 43 | tower-http = { version = "0.3", features = ["trace"] } 44 | tracing = "0.1" 45 | tracing-subscriber = { version = "0.3", features = ["json"]} 46 | serde = "1" 47 | serde_cbor = "0.11" 48 | serde_json = "1" 49 | sha2 = "0.10" 50 | tokio = { version = "1", features = ["full"] } 51 | webpki-roots = "0.22" 52 | 53 | [features] 54 | skip_body_verification = [] 55 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use clap::{crate_authors, crate_version, Parser}; 2 | use futures::try_join; 3 | use tracing::{error, Instrument}; 4 | 5 | mod canister_id; 6 | mod config; 7 | mod headers; 8 | mod http_client; 9 | mod logging; 10 | mod metrics; 11 | mod proxy; 12 | mod validate; 13 | 14 | use crate::{ 15 | metrics::{MetricParams, WithMetrics}, 16 | validate::Validator, 17 | }; 18 | 19 | #[derive(Parser)] 20 | #[clap( 21 | version = crate_version!(), 22 | author = crate_authors!(), 23 | propagate_version = true, 24 | )] 25 | struct Opts { 26 | /// The options for logging 27 | #[clap(flatten)] 28 | log: logging::Opts, 29 | 30 | /// The options for the HTTP client 31 | #[clap(flatten)] 32 | http_client: http_client::Opts, 33 | 34 | /// The options for metrics 35 | #[clap(flatten)] 36 | metrics: metrics::Opts, 37 | 38 | /// The options for the canister resolver 39 | #[clap(flatten)] 40 | canister_id: canister_id::Opts, 41 | 42 | /// The options for the proxy server 43 | #[clap(flatten)] 44 | proxy: proxy::Opts, 45 | } 46 | 47 | fn main() -> Result<(), anyhow::Error> { 48 | let Opts { 49 | log, 50 | http_client, 51 | metrics, 52 | canister_id, 53 | proxy, 54 | .. 55 | } = Opts::parse(); 56 | 57 | let _span = logging::setup(log); 58 | 59 | let client = http_client::setup(http_client)?; 60 | 61 | let (meter, metrics) = metrics::setup(metrics); 62 | 63 | let resolver = canister_id::setup(canister_id)?; 64 | 65 | let validator = Validator::new(); 66 | let validator = WithMetrics(validator, MetricParams::new(&meter, "validator")); 67 | 68 | let proxy = proxy::setup( 69 | proxy::SetupArgs { 70 | resolver, 71 | validator, 72 | client, 73 | }, 74 | proxy, 75 | )?; 76 | 77 | let rt = tokio::runtime::Builder::new_multi_thread() 78 | .worker_threads(10) 79 | .enable_all() 80 | .build()?; 81 | 82 | rt.block_on( 83 | async move { 84 | let v = try_join!( 85 | metrics.run().in_current_span(), 86 | proxy.run().in_current_span(), 87 | ); 88 | if let Err(v) = v { 89 | error!("Runtime crashed: {v}"); 90 | return Err(v); 91 | } 92 | Ok(()) 93 | } 94 | .in_current_span(), 95 | )?; 96 | 97 | Ok(()) 98 | } 99 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | By participating in this project, you agree to abide by our [Code of Conduct](./CODE_OF_CONDUCT.md). 4 | 5 | As a member of the community, you are invited and encouraged to contribute by submitting issues, offering suggestions for improvements, adding review comments to existing pull requests, or creating new pull requests to fix issues. 6 | 7 | ## Contents of this repository 8 | 9 | This repository contains a collection of libraries and tools for building software around the Internet Computer, in Rust. 10 | 11 | ## Before you contribute 12 | 13 | Before contributing, please take a few minutes to review these contributor guidelines. 14 | The contributor guidelines are intended to make the contribution process easy and effective for everyone involved in addressing your issue, assessing changes, and finalizing your pull requests. 15 | 16 | Before contributing, consider the following: 17 | 18 | - If you want to report an issue, click **Issues**. 19 | 20 | - If you have more general questions related to Motoko and its use, post a message to the [community forum](https://forum.dfinity.org/) or submit a [support request](mailto://support@dfinity.org). 21 | 22 | - If you are reporting a bug, provide as much information about the problem as possible. 23 | 24 | - If you want to contribute directly to this repository, typical fixes might include any of the following: 25 | 26 | - Fixes to resolve bugs or documentation errors 27 | - Code improvements 28 | - Feature requests 29 | 30 | Note that any contribution to this repository must be submitted in the form of a **pull request**. 31 | 32 | - If you are creating a pull request, be sure that the pull request only implements one fix or suggestion. 33 | 34 | If you are new to working with GitHub repositories and creating pull requests, consider exploring [First Contributions](https://github.com/firstcontributions/first-contributions) or [How to Contribute to an Open Source Project on GitHub](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github). 35 | 36 | # How to make a contribution 37 | 38 | Depending on the type of contribution you want to make, you might follow different workflows. 39 | 40 | This section describes the most common workflow scenarios: 41 | 42 | - Reporting an issue 43 | - Submitting a pull request 44 | 45 | ### Reporting an issue 46 | 47 | To open a new issue: 48 | 49 | 1. Click **Issues**. 50 | 51 | 1. Click **New Issue**. 52 | 53 | 1. Click **Open a blank issue**. 54 | 55 | 1. Type a title and description, then click **Submit new issue**. 56 | 57 | Be as clear and descriptive as possible. 58 | 59 | For any problem, describe it in detail, including details about the library, the version of the code you are using, the result 60 | -------------------------------------------------------------------------------- /src/metrics.rs: -------------------------------------------------------------------------------- 1 | use std::{future::Future, net::SocketAddr}; 2 | 3 | use axum::{handler::Handler, routing::get, Extension, Router}; 4 | use clap::Args; 5 | use futures::{future::OptionFuture, FutureExt}; 6 | use ic_agent::{ 7 | agent::http_transport::hyper::{self, Body, Request, Response, StatusCode, Uri}, 8 | ic_types::Principal, 9 | Agent, 10 | }; 11 | use opentelemetry::{ 12 | global, 13 | metrics::{Counter, Meter}, 14 | sdk::Resource, 15 | KeyValue, 16 | }; 17 | use opentelemetry_prometheus::PrometheusExporter; 18 | use prometheus::{Encoder, TextEncoder}; 19 | 20 | use crate::{headers::HeadersData, logging::add_trace_layer, validate::Validate}; 21 | 22 | /// The options for metrics 23 | #[derive(Args)] 24 | pub struct Opts { 25 | /// Address to expose Prometheus metrics on 26 | /// Examples: 127.0.0.1:9090, [::1]:9090 27 | #[clap(long)] 28 | metrics_addr: Option, 29 | } 30 | 31 | pub struct WithMetrics(pub T, pub MetricParams); 32 | 33 | pub struct MetricParams { 34 | pub counter: Counter, 35 | } 36 | 37 | impl MetricParams { 38 | pub fn new(meter: &Meter, name: &str) -> Self { 39 | Self { 40 | counter: meter 41 | .u64_counter(format!("{name}.total")) 42 | .with_description(format!("Counts occurences of {name} calls")) 43 | .init(), 44 | } 45 | } 46 | } 47 | 48 | impl Validate for WithMetrics { 49 | fn validate( 50 | &self, 51 | headers_data: &HeadersData, 52 | canister_id: &Principal, 53 | agent: &Agent, 54 | uri: &Uri, 55 | response_body: &[u8], 56 | ) -> Result<(), String> { 57 | let out = self 58 | .0 59 | .validate(headers_data, canister_id, agent, uri, response_body); 60 | 61 | let mut status = if out.is_ok() { "ok" } else { "fail" }; 62 | if cfg!(feature = "skip_body_verification") { 63 | status = "skip"; 64 | } 65 | 66 | let labels = &[KeyValue::new("status", status)]; 67 | 68 | let MetricParams { counter } = &self.1; 69 | counter.add(1, labels); 70 | 71 | out 72 | } 73 | } 74 | 75 | #[derive(Clone)] 76 | struct HandlerArgs { 77 | exporter: PrometheusExporter, 78 | } 79 | 80 | async fn metrics_handler( 81 | Extension(HandlerArgs { exporter }): Extension, 82 | _: Request, 83 | ) -> Response { 84 | let metric_families = exporter.registry().gather(); 85 | 86 | let encoder = TextEncoder::new(); 87 | 88 | let mut metrics_text = Vec::new(); 89 | if encoder.encode(&metric_families, &mut metrics_text).is_err() { 90 | return Response::builder() 91 | .status(StatusCode::INTERNAL_SERVER_ERROR) 92 | .body("Internal Server Error".into()) 93 | .unwrap(); 94 | }; 95 | 96 | Response::builder() 97 | .status(200) 98 | .body(metrics_text.into()) 99 | .unwrap() 100 | } 101 | pub fn setup(opts: Opts) -> (Meter, Runner) { 102 | let exporter = opentelemetry_prometheus::exporter() 103 | .with_resource(Resource::new(vec![KeyValue::new("service", "prober")])) 104 | .init(); 105 | ( 106 | global::meter("icx-proxy"), 107 | Runner { 108 | exporter, 109 | metrics_addr: opts.metrics_addr, 110 | }, 111 | ) 112 | } 113 | 114 | pub struct Runner { 115 | exporter: PrometheusExporter, 116 | metrics_addr: Option, 117 | } 118 | 119 | impl Runner { 120 | pub fn run(self) -> impl Future, hyper::Error>> { 121 | let exporter = self.exporter; 122 | OptionFuture::from(self.metrics_addr.map(|metrics_addr| { 123 | let metrics_handler = metrics_handler.layer(Extension(HandlerArgs { exporter })); 124 | let metrics_router = Router::new().route("/metrics", get(metrics_handler)); 125 | 126 | axum::Server::bind(&metrics_addr) 127 | .serve(add_trace_layer(metrics_router).into_make_service()) 128 | })) 129 | .map(|v| v.transpose()) 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/proxy/forward.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | net::{IpAddr, SocketAddr}, 3 | sync::{ 4 | atomic::{AtomicUsize, Ordering}, 5 | Arc, 6 | }, 7 | }; 8 | 9 | use axum::{extract::ConnectInfo, Extension}; 10 | use ic_agent::agent::http_transport::hyper::{ 11 | header::{Entry, HeaderValue}, 12 | http::uri::Parts, 13 | HeaderMap, Request, Response, Uri, 14 | }; 15 | use tracing::{info, instrument}; 16 | 17 | use crate::{ 18 | http_client::{Body, HyperService}, 19 | proxy::HandleError, 20 | }; 21 | 22 | pub struct ArgsInner { 23 | pub debug: bool, 24 | pub counter: AtomicUsize, 25 | pub proxy_urls: Vec, 26 | pub client: C, 27 | } 28 | pub struct Args { 29 | args: Arc>, 30 | current: usize, 31 | } 32 | impl From> for Args { 33 | fn from(args: ArgsInner) -> Self { 34 | Args { 35 | args: Arc::new(args), 36 | current: 0, 37 | } 38 | } 39 | } 40 | impl Clone for Args { 41 | fn clone(&self) -> Self { 42 | let args = self.args.clone(); 43 | Args { 44 | current: args.counter.fetch_add(1, Ordering::Relaxed) % args.proxy_urls.len(), 45 | args, 46 | } 47 | } 48 | } 49 | impl Args { 50 | fn proxy_url(&self) -> &Uri { 51 | &self.args.proxy_urls[self.current] 52 | } 53 | } 54 | 55 | #[instrument(level = "info", skip_all, fields(addr = display(addr)))] 56 | pub async fn handler>( 57 | Extension(args): Extension>>, 58 | ConnectInfo(addr): ConnectInfo, 59 | request: Request, 60 | ) -> Response { 61 | let proxy_url = args.proxy_url(); 62 | let args = &args.args; 63 | 64 | async { 65 | info!("forwarding"); 66 | let proxied_request = create_proxied_request(&addr.ip(), proxy_url.clone(), request)?; 67 | let response = args.client.clone().call(proxied_request).await?; 68 | Ok(response) 69 | } 70 | .await 71 | .handle_error(args.debug) 72 | .map(|b| b.into()) 73 | } 74 | 75 | fn create_proxied_request( 76 | client_ip: &IpAddr, 77 | proxy_url: Uri, 78 | mut request: Request, 79 | ) -> Result, anyhow::Error> { 80 | *request.headers_mut() = remove_hop_headers(request.headers()); 81 | *request.uri_mut() = forward_uri(proxy_url, &request)?; 82 | 83 | let x_forwarded_for_header_name = "x-forwarded-for"; 84 | 85 | // Add forwarding information in the headers 86 | match request.headers_mut().entry(x_forwarded_for_header_name) { 87 | Entry::Vacant(entry) => { 88 | entry.insert(client_ip.to_string().parse()?); 89 | } 90 | 91 | Entry::Occupied(mut entry) => { 92 | let addr = format!("{}, {}", entry.get().to_str()?, client_ip); 93 | entry.insert(addr.parse()?); 94 | } 95 | } 96 | 97 | Ok(request) 98 | } 99 | 100 | fn is_hop_header(name: &str) -> bool { 101 | name.eq_ignore_ascii_case("connection") 102 | || name.eq_ignore_ascii_case("keep-alive") 103 | || name.eq_ignore_ascii_case("proxy-authenticate") 104 | || name.eq_ignore_ascii_case("proxy-authorization") 105 | || name.eq_ignore_ascii_case("te") 106 | || name.eq_ignore_ascii_case("trailers") 107 | || name.eq_ignore_ascii_case("transfer-encoding") 108 | || name.eq_ignore_ascii_case("upgrade") 109 | } 110 | 111 | /// Returns a clone of the headers without the [hop-by-hop headers]. 112 | /// 113 | /// [hop-by-hop headers]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html 114 | fn remove_hop_headers(headers: &HeaderMap) -> HeaderMap { 115 | let mut result = HeaderMap::new(); 116 | for (k, v) in headers.iter() { 117 | if !is_hop_header(k.as_str()) { 118 | result.insert(k.clone(), v.clone()); 119 | } 120 | } 121 | result 122 | } 123 | 124 | fn forward_uri(proxy_url: Uri, req: &Request) -> Result { 125 | let mut parts = Parts::from(proxy_url); 126 | parts.path_and_query = req.uri().path_and_query().cloned(); 127 | Ok(Uri::from_parts(parts)?) 128 | } 129 | -------------------------------------------------------------------------------- /src/headers.rs: -------------------------------------------------------------------------------- 1 | use ic_utils::interfaces::http_request::HeaderField; 2 | use lazy_regex::regex_captures; 3 | use tracing::{trace, warn}; 4 | 5 | const MAX_LOG_CERT_NAME_SIZE: usize = 100; 6 | const MAX_LOG_CERT_B64_SIZE: usize = 2000; 7 | 8 | #[derive(Debug, PartialEq)] 9 | pub struct HeadersData { 10 | pub certificate: Option, ()>>, 11 | pub tree: Option, ()>>, 12 | pub encoding: Option, 13 | } 14 | 15 | pub fn extract_headers_data(headers: &[HeaderField]) -> HeadersData { 16 | let mut headers_data = HeadersData { 17 | certificate: None, 18 | tree: None, 19 | encoding: None, 20 | }; 21 | 22 | for HeaderField(name, value) in headers { 23 | if name.eq_ignore_ascii_case("Ic-Certificate") { 24 | for field in value.split(',') { 25 | if let Some((_, name, b64_value)) = regex_captures!("^(.*)=:(.*):$", field.trim()) { 26 | trace!( 27 | ">> certificate {:.l1$}: {:.l2$}", 28 | name, 29 | b64_value, 30 | l1 = MAX_LOG_CERT_NAME_SIZE, 31 | l2 = MAX_LOG_CERT_B64_SIZE 32 | ); 33 | let bytes = decode_hash_tree(name, Some(b64_value.to_string())); 34 | if name == "certificate" { 35 | headers_data.certificate = Some(match (headers_data.certificate, bytes) { 36 | (None, bytes) => bytes, 37 | (Some(Ok(certificate)), Ok(bytes)) => { 38 | warn!("duplicate certificate field: {:?}", bytes); 39 | Ok(certificate) 40 | } 41 | (Some(Ok(certificate)), Err(_)) => { 42 | warn!("duplicate certificate field (failed to decode)"); 43 | Ok(certificate) 44 | } 45 | (Some(Err(_)), bytes) => { 46 | warn!("duplicate certificate field (failed to decode)"); 47 | bytes 48 | } 49 | }); 50 | } else if name == "tree" { 51 | headers_data.tree = Some(match (headers_data.tree, bytes) { 52 | (None, bytes) => bytes, 53 | (Some(Ok(tree)), Ok(bytes)) => { 54 | warn!("duplicate tree field: {:?}", bytes); 55 | Ok(tree) 56 | } 57 | (Some(Ok(tree)), Err(_)) => { 58 | warn!("duplicate tree field (failed to decode)"); 59 | Ok(tree) 60 | } 61 | (Some(Err(_)), bytes) => { 62 | warn!("duplicate tree field (failed to decode)"); 63 | bytes 64 | } 65 | }); 66 | } 67 | } 68 | } 69 | } else if name.eq_ignore_ascii_case("Content-Encoding") { 70 | let enc = value.trim().to_string(); 71 | headers_data.encoding = Some(enc); 72 | } 73 | } 74 | 75 | headers_data 76 | } 77 | 78 | fn decode_hash_tree(name: &str, value: Option) -> Result, ()> { 79 | match value { 80 | Some(tree) => base64::decode(tree).map_err(|e| { 81 | warn!("Unable to decode {} from base64: {}", name, e); 82 | }), 83 | _ => Err(()), 84 | } 85 | } 86 | 87 | #[cfg(test)] 88 | mod tests { 89 | use ic_utils::interfaces::http_request::HeaderField; 90 | 91 | use super::{extract_headers_data, HeadersData}; 92 | 93 | #[test] 94 | fn extract_headers_data_simple() { 95 | let headers: Vec = vec![]; 96 | 97 | let out = extract_headers_data(&headers); 98 | 99 | assert_eq!( 100 | out, 101 | HeadersData { 102 | certificate: None, 103 | tree: None, 104 | encoding: None, 105 | } 106 | ); 107 | } 108 | 109 | #[test] 110 | fn extract_headers_data_content_encoding() { 111 | let headers: Vec = vec![HeaderField("Content-Encoding".into(), "test".into())]; 112 | 113 | let out = extract_headers_data(&headers); 114 | 115 | assert_eq!( 116 | out, 117 | HeadersData { 118 | certificate: None, 119 | tree: None, 120 | encoding: Some(String::from("test")), 121 | } 122 | ); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | DFINITY. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /src/logging.rs: -------------------------------------------------------------------------------- 1 | use std::{fs::File, io::stderr, path::PathBuf}; 2 | 3 | use axum::Router; 4 | use clap::{crate_version, ArgAction::Count, Args, ValueEnum}; 5 | use tower_http::trace::TraceLayer; 6 | use tracing::{ 7 | info, info_span, level_filters::LevelFilter, span::EnteredSpan, subscriber::set_global_default, 8 | Span, 9 | }; 10 | use tracing_subscriber::{fmt::layer, layer::SubscriberExt, Registry}; 11 | 12 | #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)] 13 | pub(crate) enum OptMode { 14 | StdErr, 15 | Tee, 16 | File, 17 | } 18 | 19 | #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)] 20 | pub(crate) enum OptFormat { 21 | Default, 22 | Compact, 23 | Full, 24 | Json, 25 | } 26 | 27 | /// The options for logging 28 | #[derive(Args)] 29 | pub struct Opts { 30 | /// Verbose level. By default, INFO will be used. Add a single `-v` to upgrade to 31 | /// DEBUG, and another `-v` to upgrade to TRACE. 32 | #[clap(long, short('v'), action = Count)] 33 | verbose: u64, 34 | 35 | /// Quiet level. The opposite of verbose. A single `-q` will drop the logging to 36 | /// WARN only, then another one to ERR, and finally another one for FATAL. Another 37 | /// `-q` will silence ALL logs. 38 | #[clap(long, short('q'), action = Count)] 39 | quiet: u64, 40 | 41 | /// Mode to use the logging. "stderr" will output logs in STDERR, "file" will output 42 | /// logs in a file, and "tee" will do both. 43 | #[clap(value_enum, long("log"), default_value_t = OptMode::StdErr)] 44 | logmode: OptMode, 45 | 46 | /// Formatting to use the logging. "stderr" will output logs in STDERR, "file" will output 47 | /// logs in a file, and "tee" will do both. 48 | #[clap(value_enum, long("logformat"), default_value_t = OptFormat::Default)] 49 | logformat: OptFormat, 50 | 51 | /// File to output the log to, when using logmode=tee or logmode=file. 52 | #[clap(long)] 53 | logfile: Option, 54 | } 55 | 56 | /// A helper to add tracing with nice spans to `Router`s 57 | pub fn add_trace_layer(r: Router) -> Router { 58 | r.layer(TraceLayer::new_for_http().make_span_with(Span::current())) 59 | } 60 | 61 | pub fn setup(opts: Opts) -> EnteredSpan { 62 | let filter = match opts.verbose as i64 - opts.quiet as i64 { 63 | -2 => LevelFilter::ERROR, 64 | -1 => LevelFilter::WARN, 65 | 0 => LevelFilter::INFO, 66 | 1 => LevelFilter::DEBUG, 67 | x if x >= 2 => LevelFilter::TRACE, 68 | // Silent. 69 | _ => LevelFilter::OFF, 70 | }; 71 | 72 | fn create_file(path: Option) -> File { 73 | File::create(path.unwrap_or_else(|| "log.txt".into())).expect("Couldn't open log file") 74 | } 75 | 76 | // The `layer_format` macro is used to uniformly customize the the format specific options for a layer 77 | // (e.g. all json should be flattened) 78 | macro_rules! layer_format { 79 | (json, $writer:expr) => { 80 | layer() 81 | .json() 82 | .flatten_event(true) 83 | .with_current_span(false) 84 | .with_writer($writer) 85 | }; 86 | (full, $writer:expr) => { 87 | layer().with_writer($writer) 88 | }; 89 | (compact, $writer:expr) => { 90 | layer().compact().with_writer($writer) 91 | }; 92 | } 93 | // The `writer` macro is used to uniformly customize the the writer specific options for a layer 94 | // (e.g. files don't use ANSI terminal colors) 95 | macro_rules! writer { 96 | (file, $format:ident) => { 97 | layer_format!($format, create_file(opts.logfile)).with_ansi(false) 98 | }; 99 | (stderr, $format:ident) => { 100 | layer_format!($format, stderr) 101 | }; 102 | } 103 | // The `layer` macro is used to uniformly customize the the writer-format specific options for a layer 104 | // (e.g. file-json includes the current span [we don't actually do this, it's just an hypothetical example]) 105 | macro_rules! layer { 106 | ($writer:ident, $format:ident) => { 107 | writer!($writer, $format) 108 | }; 109 | } 110 | 111 | // The `install` macro filters to the specified level and adds all the layers to the global subscriber 112 | macro_rules! install { 113 | ($($layer:expr),+) => { 114 | set_global_default(Registry::default().with(filter)$(.with($layer))+) 115 | } 116 | } 117 | 118 | match (opts.logmode, opts.logformat) { 119 | (OptMode::Tee, OptFormat::Default) => { 120 | install!(layer!(stderr, compact), layer!(file, full)) 121 | } 122 | (OptMode::Tee, OptFormat::Compact) => { 123 | install!(layer!(stderr, compact), layer!(file, compact)) 124 | } 125 | (OptMode::Tee, OptFormat::Full) => install!(layer!(stderr, full), layer!(file, full)), 126 | (OptMode::Tee, OptFormat::Json) => install!(layer!(stderr, json), layer!(file, json)), 127 | (OptMode::File, OptFormat::Default | OptFormat::Full) => { 128 | install!(layer!(file, full)) 129 | } 130 | (OptMode::File, OptFormat::Compact) => { 131 | install!(layer!(file, compact)) 132 | } 133 | (OptMode::File, OptFormat::Json) => install!(layer!(file, json)), 134 | (OptMode::StdErr, OptFormat::Default | OptFormat::Compact) => { 135 | install!(layer!(stderr, compact)) 136 | } 137 | (OptMode::StdErr, OptFormat::Full) => install!(layer!(stderr, full)), 138 | (OptMode::StdErr, OptFormat::Json) => install!(layer!(stderr, json)), 139 | } 140 | .expect("Failed to setup tracing."); 141 | 142 | let span = info_span!(target: "icx_proxy", "icx-proxy", version = crate_version!()).entered(); 143 | info!(target: "icx_proxy", "Log Level: {filter}"); 144 | span 145 | } 146 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | # We have to use gtar on macOS because apple's tar is literally broken. 4 | # Yes, I know how stupid that sounds. But it's true: 5 | # https://github.com/actions/virtual-environments/issues/2619 6 | 7 | on: 8 | workflow_dispatch: 9 | push: 10 | branches: 11 | - main 12 | 13 | jobs: 14 | build: 15 | runs-on: ${{ matrix.os }} 16 | strategy: 17 | fail-fast: false 18 | matrix: 19 | rust: [ '1.60.0' ] 20 | target: [ x86_64-apple-darwin, x86_64-unknown-linux-musl, x86_64-unknown-linux-gnu ] 21 | include: 22 | - os: macos-latest 23 | target: x86_64-apple-darwin 24 | binary_path: target/release 25 | name: macos 26 | tar: gtar 27 | - os: ubuntu-latest 28 | target: x86_64-unknown-linux-musl 29 | binary_path: target/x86_64-unknown-linux-musl/release 30 | name: linux 31 | tar: tar 32 | - os: ubuntu-latest 33 | target: x86_64-unknown-linux-gnu 34 | binary_path: target/x86_64-unknown-linux-gnu/release 35 | name: linux-gnu 36 | tar: tar 37 | steps: 38 | - uses: actions/checkout@v2 39 | 40 | - name: Setup environment variables 41 | run: | 42 | echo "SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV 43 | echo "OPENSSL_STATIC=yes" >> $GITHUB_ENV 44 | echo ICX_VERSION=$(cargo metadata | jq -r '.["packages"][] | select(.name == "icx-proxy")["version"]') >> $GITHUB_ENV 45 | 46 | - name: Install Rust toolchain 47 | uses: actions-rs/toolchain@v1 48 | with: 49 | profile: minimal 50 | toolchain: ${{ matrix.rust }} 51 | override: true 52 | if: contains(matrix.os, 'macos') 53 | 54 | - name: Linux build (musl) 55 | uses: dfinity/rust-musl-action@master 56 | with: 57 | args: | 58 | cargo install cargo-deb --target x86_64-unknown-linux-musl 59 | rustup target add x86_64-unknown-linux-musl 60 | RUSTFLAGS="--remap-path-prefix=${GITHUB_WORKSPACE}=/builds/dfinity" cargo deb --target x86_64-unknown-linux-musl -- --locked --features=skip_body_verification 61 | if: contains(matrix.target, 'linux-musl') 62 | 63 | - name: Linux build (gnu) 64 | env: 65 | RUSTFLAGS: --remap-path-prefix=${GITHUB_WORKSPACE}=/builds/dfinity 66 | run: | 67 | cargo build --locked --release --target x86_64-unknown-linux-gnu --features=skip_body_verification 68 | cd ${{ matrix.binary_path }} 69 | ldd icx-proxy 70 | if: contains(matrix.target, 'linux-gnu') 71 | 72 | - name: macOS build 73 | env: 74 | RUSTFLAGS: --remap-path-prefix=${GITHUB_WORKSPACE}=/builds/dfinity 75 | run: | 76 | cargo build --locked --release --features=skip_body_verification 77 | cd target/release 78 | otool -L icx-proxy 79 | if: contains(matrix.os, 'macos') 80 | 81 | - name: Create tarball of binaries 82 | run: ${{ matrix.tar }} -zcC ${{ matrix.binary_path }} -f binaries.tar.gz icx-proxy 83 | 84 | - name: Inspect input binary and tarball contents 85 | run: | 86 | hexdump -C ${{ matrix.binary_path }}/icx-proxy | head 87 | hexdump -C ${{ matrix.binary_path }}/icx-proxy | tail 88 | ${{ matrix.binary_path }}/icx-proxy --help 89 | 90 | ARCHIVE="$(pwd)/binaries.tar.gz" 91 | cd "$(mktemp -d)" 92 | ${{ matrix.tar }} --version 93 | ${{ matrix.tar }} -xzvf "$ARCHIVE" 94 | ls -l icx-proxy 95 | hexdump -C icx-proxy | head 96 | hexdump -C icx-proxy | tail 97 | ./icx-proxy --help 98 | 99 | - name: Upload tarball artifact 100 | uses: actions/upload-artifact@v2 101 | with: 102 | name: tarball-${{ matrix.name }} 103 | path: binaries.tar.gz 104 | - name: Copy deb artifact 105 | run: cp target/x86_64-unknown-linux-musl/debian/icx-proxy_${{ env.ICX_VERSION }}_amd64.deb icx-proxy.deb 106 | if: contains(matrix.target, 'linux-musl') 107 | - name: Upload deb artifact 108 | uses: actions/upload-artifact@v2 109 | with: 110 | name: deb-${{ matrix.name }} 111 | path: icx-proxy.deb 112 | if: contains(matrix.target, 'linux-musl') 113 | 114 | upload: 115 | runs-on: ${{ matrix.os }} 116 | needs: [ build ] 117 | strategy: 118 | fail-fast: false 119 | matrix: 120 | rust: [ '1.60.0' ] 121 | target: [ x86_64-apple-darwin, x86_64-unknown-linux-musl, x86_64-unknown-linux-gnu ] 122 | include: 123 | - os: macos-latest 124 | target: x86_64-apple-darwin 125 | name: macos 126 | - os: ubuntu-latest 127 | target: x86_64-unknown-linux-musl 128 | name: linux 129 | - os: ubuntu-latest 130 | target: x86_64-unknown-linux-gnu 131 | name: linux-gnu 132 | steps: 133 | - name: Setup environment variables 134 | run: echo "SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV 135 | 136 | - name: Download tarball artifact 137 | uses: actions/download-artifact@v2 138 | with: 139 | name: tarball-${{ matrix.name }} 140 | - name: Download deb artifact 141 | uses: actions/download-artifact@v2 142 | with: 143 | name: deb-${{ matrix.name }} 144 | if: contains(matrix.target, 'linux-musl') 145 | 146 | - name: Upload tarball 147 | uses: svenstaro/upload-release-action@v2 148 | with: 149 | repo_token: ${{ secrets.GITHUB_TOKEN }} 150 | file: binaries.tar.gz 151 | asset_name: binaries-${{ matrix.name }}.tar.gz 152 | tag: rev-${{ env.SHA_SHORT }} 153 | 154 | - name: Upload deb 155 | uses: svenstaro/upload-release-action@v2 156 | with: 157 | repo_token: ${{ secrets.GITHUB_TOKEN }} 158 | file: icx-proxy.deb 159 | tag: rev-${{ env.SHA_SHORT }} 160 | if: contains(matrix.target, 'linux-musl') 161 | -------------------------------------------------------------------------------- /src/proxy/mod.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | future::Future, 3 | net::SocketAddr, 4 | sync::{atomic::AtomicUsize, Arc}, 5 | }; 6 | 7 | use anyhow::{bail, Context}; 8 | use axum::{handler::Handler, routing::any, Extension, Router}; 9 | use clap::Args; 10 | use ic_agent::agent::http_transport::{ 11 | hyper::{self, Response, StatusCode, Uri}, 12 | HyperReplicaV2Transport, 13 | }; 14 | use ic_agent::Agent; 15 | use tracing::{error, info}; 16 | 17 | use crate::{ 18 | canister_id::Resolver as CanisterIdResolver, 19 | http_client::{Body, HyperService}, 20 | logging::add_trace_layer, 21 | validate::Validate, 22 | }; 23 | 24 | const KB: usize = 1024; 25 | const MB: usize = 1024 * KB; 26 | 27 | const REQUEST_BODY_SIZE_LIMIT: usize = 10 * MB; 28 | const RESPONSE_BODY_SIZE_LIMIT: usize = 10 * MB; 29 | 30 | /// The options for the proxy server 31 | #[derive(Args)] 32 | pub struct Opts { 33 | /// The address to bind to. 34 | #[clap(long, default_value = "127.0.0.1:3000")] 35 | address: SocketAddr, 36 | 37 | /// A replica to use as backend. Locally, this should be a local instance or the 38 | /// boundary node. Multiple replicas can be passed and they'll be used round-robin. 39 | #[clap(long, default_value = "http://localhost:8000/")] 40 | replica: Vec, 41 | 42 | /// An address to forward any requests from /_/ 43 | #[clap(long)] 44 | proxy: Option, 45 | 46 | /// Whether or not this is run in a debug context (e.g. errors returned in responses 47 | /// should show full stack and error details). 48 | #[clap(long)] 49 | debug: bool, 50 | 51 | /// Whether or not to fetch the root key from the replica back end. Do not use this when 52 | /// talking to the Internet Computer blockchain mainnet as it is unsecure. 53 | #[clap(long)] 54 | fetch_root_key: bool, 55 | } 56 | 57 | mod agent; 58 | mod forward; 59 | 60 | use agent::{handler as agent_handler, Args as AgentArgs, ArgsInner as AgentArgsInner}; 61 | use forward::{handler as forward_handler, Args as ForwardArgs, ArgsInner as ForwardArgsInner}; 62 | 63 | trait HandleError { 64 | type B; 65 | fn handle_error(self, debug: bool) -> Response; 66 | } 67 | impl HandleError for Result, anyhow::Error> 68 | where 69 | String: Into, 70 | &'static str: Into, 71 | { 72 | type B = B; 73 | fn handle_error(self, debug: bool) -> Response { 74 | match self { 75 | Err(err) => { 76 | error!("Internal Error during request:\n{}", err); 77 | Response::builder() 78 | .status(StatusCode::INTERNAL_SERVER_ERROR) 79 | .body(if debug { 80 | format!("Internal Error: {:?}", err).into() 81 | } else { 82 | "Internal Server Error".into() 83 | }) 84 | .unwrap() 85 | } 86 | Ok(v) => v, 87 | } 88 | } 89 | } 90 | 91 | pub struct SetupArgs { 92 | pub validator: V, 93 | pub resolver: R, 94 | pub client: C, 95 | } 96 | 97 | pub fn setup>( 98 | args: SetupArgs, 99 | opts: Opts, 100 | ) -> Result { 101 | let client = args.client; 102 | 103 | let agent_args = Extension(AgentArgs::from(AgentArgsInner { 104 | validator: Box::new(args.validator), 105 | resolver: Box::new(args.resolver), 106 | counter: AtomicUsize::new(0), 107 | replicas: opts 108 | .replica 109 | .iter() 110 | .map(|replica_url| { 111 | let transport = HyperReplicaV2Transport::create_with_service( 112 | replica_url.clone(), 113 | client.clone(), 114 | ) 115 | .context("failed to create transport")? 116 | .with_max_response_body_size(RESPONSE_BODY_SIZE_LIMIT); 117 | 118 | let agent = Agent::builder() 119 | .with_transport(transport) 120 | .build() 121 | .context("Could not create agent...")?; 122 | Ok((agent, replica_url.clone())) 123 | }) 124 | .collect::>()?, 125 | debug: opts.debug, 126 | fetch_root_key: opts.fetch_root_key, 127 | })); 128 | 129 | let agent_service = agent_handler.layer(agent_args).into_service(); 130 | 131 | let router = Router::new(); 132 | // Setup `/_/` proxy for dfx if requested 133 | let router = if let Some(proxy_url) = opts.proxy { 134 | info!("Setting up `/_/` proxy to `{proxy_url}`"); 135 | if proxy_url.scheme().is_none() { 136 | bail!("No schema found on `proxy_url`"); 137 | } 138 | let forward_args = Extension(Arc::new(ForwardArgs::from(ForwardArgsInner { 139 | client: client.clone(), 140 | counter: AtomicUsize::new(0), 141 | proxy_urls: vec![proxy_url], 142 | debug: opts.debug, 143 | }))); 144 | let forward_to_replica = Extension(Arc::new(ForwardArgs::from(ForwardArgsInner { 145 | client, 146 | counter: AtomicUsize::new(0), 147 | proxy_urls: opts.replica, 148 | debug: opts.debug, 149 | }))); 150 | let forward_service = any(forward_handler::.layer(forward_args)); 151 | let forward_to_replica_service = any(forward_handler::.layer(forward_to_replica)); 152 | router 153 | // Exclude `/_/raw` from the proxy 154 | .route("/_/raw", agent_service.clone()) 155 | .route("/_/raw/*path", agent_service.clone()) 156 | // Proxy `/api` to the replica 157 | .route("/api", forward_to_replica_service.clone()) 158 | .route("/api/*path", forward_to_replica_service) 159 | // Proxy everything else under `/_` to the `proxy_url` 160 | .route("/_", forward_service.clone()) 161 | .route("/_/", forward_service.clone()) 162 | .route("/_/:not_raw", forward_service.clone()) 163 | .route("/_/:not_raw/*path", forward_service) 164 | } else { 165 | router 166 | }; 167 | Ok(Runner { 168 | router: add_trace_layer(router.fallback(agent_service)), 169 | address: opts.address, 170 | }) 171 | } 172 | 173 | pub struct Runner { 174 | router: Router, 175 | address: SocketAddr, 176 | } 177 | impl Runner { 178 | pub fn run(self) -> impl Future> { 179 | info!("Starting server. Listening on http://{}/", self.address); 180 | axum::Server::bind(&self.address).serve( 181 | self.router 182 | .into_make_service_with_connect_info::(), 183 | ) 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /src/config/dns_canister_rule.rs: -------------------------------------------------------------------------------- 1 | use ic_agent::ic_types::Principal; 2 | 3 | use anyhow::anyhow; 4 | 5 | const DNS_ALIAS_FORMAT_HELP: &str = "Format is dns.alias:principal-id"; 6 | 7 | #[derive(Clone, Debug)] 8 | enum PrincipalDeterminationStrategy { 9 | // A domain name which matches the suffix is an alias for this specific Principal. 10 | Alias(Principal), 11 | 12 | // The subdomain to the immediate left of the suffix is the Principal, 13 | // if it parses as a valid Principal. 14 | PrecedingDomainName, 15 | } 16 | 17 | /// A mapping from a domain name to a Principal. The domain name must 18 | /// match the last portion, as split by '.', of the host specified in the request. 19 | #[derive(Clone, Debug)] 20 | pub struct DnsCanisterRule { 21 | /// The hostname parts that must match the right-hand side of the domain name. Lower case. 22 | dns_suffix: Vec, 23 | 24 | strategy: PrincipalDeterminationStrategy, 25 | } 26 | 27 | impl DnsCanisterRule { 28 | /// Create a rule for a domain name alias with form dns.alias:canister-id 29 | pub fn new_alias(dns_alias: &str) -> anyhow::Result { 30 | let (domain_name, principal) = split_dns_alias(dns_alias)?; 31 | let dns_suffix = split_hostname_lowercase(&domain_name); 32 | Ok(DnsCanisterRule { 33 | dns_suffix, 34 | strategy: PrincipalDeterminationStrategy::Alias(principal), 35 | }) 36 | } 37 | 38 | /// Create a rule which for domain names that match the specified suffix, 39 | /// if the preceding subdomain parses as a principal, return that principal. 40 | pub fn new_suffix(suffix: &str) -> DnsCanisterRule { 41 | let dns_suffix: Vec = split_hostname_lowercase(suffix); 42 | DnsCanisterRule { 43 | dns_suffix, 44 | strategy: PrincipalDeterminationStrategy::PrecedingDomainName, 45 | } 46 | } 47 | 48 | /// Return the associated principal if this rule applies to the domain name. 49 | pub fn lookup(&self, split_hostname: I) -> Option 50 | where 51 | T: AsRef, 52 | I: IntoIterator, 53 | I::IntoIter: DoubleEndedIterator, 54 | { 55 | fn extend_with_none(i: impl Iterator) -> impl Iterator> { 56 | i.map(Some).chain(std::iter::once(None)) 57 | } 58 | fn eq(a: impl AsRef, b: &str) -> bool { 59 | a.as_ref().eq_ignore_ascii_case(b) 60 | } 61 | 62 | use PrincipalDeterminationStrategy::{Alias, PrecedingDomainName}; 63 | 64 | let split_hostname = split_hostname.into_iter().rev(); 65 | let dns_suffix = self.dns_suffix().iter().rev(); 66 | match (&self.strategy, split_hostname.size_hint()) { 67 | (Alias(_), (_, Some(len))) if len < self.dns_suffix().len() => None, 68 | (Alias(principal), _) => { 69 | // Extend `split_hostname` with `None` 70 | if extend_with_none(split_hostname) 71 | .zip(dns_suffix) 72 | // Loop through `split_hostname` and `dns_suffix`. 73 | // 74 | // If we reach the end of `split_hostname` (aka the `None` we extended) before 75 | // we reach the end of `dns_suffix`, then short circuit with `false`. 76 | .all(|(host, dns)| host.map(|host| eq(host, dns)).unwrap_or(false)) 77 | { 78 | Some(*principal) 79 | } else { 80 | None 81 | } 82 | } 83 | (PrecedingDomainName, (_, Some(len))) if len <= self.dns_suffix().len() => None, 84 | (PrecedingDomainName, _) => split_hostname 85 | // Extend `dns_suffix` with `None` 86 | .zip(extend_with_none(dns_suffix)) 87 | // Loop through `split_hostname` and `dns_suffix`. 88 | // 89 | // Once we reach the end of `dns_suffix` (aka the `None` we extended) we know 90 | // we're at the subdomain of `split_hostname`, so extract that. 91 | .map_while(|(host, dns)| match dns { 92 | Some(dns) if eq(&host, dns) => Some(None), 93 | Some(_) => None, 94 | None => Principal::from_text(host.as_ref()).ok().map(Some), 95 | }) 96 | .find_map(|x| x), 97 | } 98 | } 99 | 100 | pub fn dns_suffix(&self) -> &Vec { 101 | &self.dns_suffix 102 | } 103 | } 104 | 105 | fn split_hostname_lowercase(hostname: &str) -> Vec { 106 | hostname 107 | .split('.') 108 | .map(|s| s.to_ascii_lowercase()) 109 | .collect() 110 | } 111 | 112 | fn split_dns_alias(alias: &str) -> Result<(String, Principal), anyhow::Error> { 113 | match alias.find(':') { 114 | Some(0) => Err(anyhow!( 115 | r#"No domain specifed in DNS alias "{}". {}"#, 116 | alias.to_string(), 117 | DNS_ALIAS_FORMAT_HELP 118 | )), 119 | Some(index) if index == alias.len() - 1 => Err(anyhow!( 120 | r#"No canister ID specifed in DNS alias "{}". {}"#, 121 | alias.to_string(), 122 | DNS_ALIAS_FORMAT_HELP 123 | )), 124 | Some(index) => { 125 | let (domain_name, principal) = alias.split_at(index); 126 | let principal = &principal[1..]; 127 | let principal = Principal::from_text(principal)?; 128 | Ok((domain_name.to_string(), principal)) 129 | } 130 | None => Err(anyhow!( 131 | r#"Unrecognized DNS alias "{}". {}"#, 132 | alias.to_string(), 133 | DNS_ALIAS_FORMAT_HELP, 134 | )), 135 | } 136 | } 137 | 138 | #[cfg(test)] 139 | mod tests { 140 | use crate::config::dns_canister_rule::DnsCanisterRule; 141 | 142 | #[test] 143 | fn parse_error_no_colon() { 144 | let e = parse_dns_alias("happy.little.domain.name!r7inp-6aaaa-aaaaa-aaabq-cai") 145 | .expect_err("expected failure due to missing colon"); 146 | assert_eq!( 147 | e.to_string(), 148 | r#"Unrecognized DNS alias "happy.little.domain.name!r7inp-6aaaa-aaaaa-aaabq-cai". Format is dns.alias:principal-id"# 149 | ) 150 | } 151 | 152 | #[test] 153 | fn parse_error_nothing_after_colon() { 154 | let e = parse_dns_alias("happy.little.domain.name:") 155 | .expect_err("expected failure due to nothing after colon"); 156 | assert_eq!( 157 | e.to_string(), 158 | r#"No canister ID specifed in DNS alias "happy.little.domain.name:". Format is dns.alias:principal-id"# 159 | ) 160 | } 161 | 162 | #[test] 163 | fn parse_error_nothing_before_colon() { 164 | let e = parse_dns_alias(":r7inp-6aaaa-aaaaa-aaabq-cai") 165 | .expect_err("expected failure due to nothing after colon"); 166 | assert_eq!( 167 | e.to_string(), 168 | r#"No domain specifed in DNS alias ":r7inp-6aaaa-aaaaa-aaabq-cai". Format is dns.alias:principal-id"# 169 | ) 170 | } 171 | 172 | fn parse_dns_alias(alias: &str) -> anyhow::Result { 173 | DnsCanisterRule::new_alias(alias) 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /src/validate.rs: -------------------------------------------------------------------------------- 1 | use std::io::Read; 2 | 3 | use flate2::read::{DeflateDecoder, GzDecoder}; 4 | use ic_agent::{ 5 | agent::http_transport::hyper::Uri, 6 | hash_tree::LookupResult, 7 | ic_types::{HashTree, Principal}, 8 | lookup_value, Agent, AgentError, Certificate, 9 | }; 10 | use sha2::{Digest, Sha256}; 11 | use tracing::trace; 12 | 13 | use crate::headers::HeadersData; 14 | 15 | // The limit of a buffer we should decompress ~10mb. 16 | const MAX_CHUNK_SIZE_TO_DECOMPRESS: usize = 1024; 17 | const MAX_CHUNKS_TO_DECOMPRESS: u64 = 10_240; 18 | 19 | pub trait Validate: Sync + Send { 20 | fn validate( 21 | &self, 22 | headers_data: &HeadersData, 23 | canister_id: &Principal, 24 | agent: &Agent, 25 | uri: &Uri, 26 | response_body: &[u8], 27 | ) -> Result<(), String>; 28 | } 29 | 30 | pub struct Validator {} 31 | 32 | impl Validator { 33 | pub fn new() -> Self { 34 | Self {} 35 | } 36 | } 37 | 38 | impl Validate for Validator { 39 | fn validate( 40 | &self, 41 | headers_data: &HeadersData, 42 | canister_id: &Principal, 43 | agent: &Agent, 44 | uri: &Uri, 45 | response_body: &[u8], 46 | ) -> Result<(), String> { 47 | let body_sha = if let Some(body_sha) = 48 | decode_body_to_sha256(response_body, headers_data.encoding.clone()) 49 | { 50 | body_sha 51 | } else { 52 | return Err("Body could not be decoded".into()); 53 | }; 54 | 55 | let body_valid = match ( 56 | headers_data.certificate.as_ref(), 57 | headers_data.tree.as_ref(), 58 | ) { 59 | (Some(Ok(certificate)), Some(Ok(tree))) => match validate_body( 60 | Certificates { certificate, tree }, 61 | canister_id, 62 | agent, 63 | uri, 64 | &body_sha, 65 | ) { 66 | Ok(true) => Ok(()), 67 | Ok(false) => Err("Body does not pass verification".to_string()), 68 | Err(e) => Err(format!("Certificate validation failed: {}", e)), 69 | }, 70 | (Some(_), _) | (_, Some(_)) => Err("Body does not pass verification".to_string()), 71 | 72 | // TODO: Remove this (FOLLOW-483) 73 | // Canisters don't have to provide certified variables 74 | // This should change in the future, grandfathering in current implementations 75 | (None, None) => Ok(()), 76 | }; 77 | 78 | if cfg!(feature = "skip_body_verification") { 79 | return Ok(()); 80 | } 81 | 82 | body_valid 83 | } 84 | } 85 | 86 | struct Certificates<'a> { 87 | certificate: &'a Vec, 88 | tree: &'a Vec, 89 | } 90 | 91 | fn decode_body_to_sha256(body: &[u8], encoding: Option) -> Option<[u8; 32]> { 92 | let mut sha256 = Sha256::new(); 93 | let mut decoded = [0u8; MAX_CHUNK_SIZE_TO_DECOMPRESS]; 94 | match encoding.as_deref() { 95 | Some("gzip") => { 96 | let mut decoder = GzDecoder::new(body); 97 | for _ in 0..MAX_CHUNKS_TO_DECOMPRESS { 98 | let bytes = decoder.read(&mut decoded).ok()?; 99 | if bytes == 0 { 100 | return Some(sha256.finalize().into()); 101 | } 102 | sha256.update(&decoded[0..bytes]); 103 | } 104 | if decoder.bytes().next().is_some() { 105 | return None; 106 | } 107 | } 108 | Some("deflate") => { 109 | let mut decoder = DeflateDecoder::new(body); 110 | for _ in 0..MAX_CHUNKS_TO_DECOMPRESS { 111 | let bytes = decoder.read(&mut decoded).ok()?; 112 | if bytes == 0 { 113 | return Some(sha256.finalize().into()); 114 | } 115 | sha256.update(&decoded[0..bytes]); 116 | } 117 | if decoder.bytes().next().is_some() { 118 | return None; 119 | } 120 | } 121 | _ => sha256.update(body), 122 | }; 123 | Some(sha256.finalize().into()) 124 | } 125 | 126 | fn validate_body( 127 | certificates: Certificates, 128 | canister_id: &Principal, 129 | agent: &Agent, 130 | uri: &Uri, 131 | body_sha: &[u8; 32], 132 | ) -> anyhow::Result { 133 | let cert: Certificate = 134 | serde_cbor::from_slice(certificates.certificate).map_err(AgentError::InvalidCborData)?; 135 | let tree: HashTree = 136 | serde_cbor::from_slice(certificates.tree).map_err(AgentError::InvalidCborData)?; 137 | 138 | if let Err(e) = agent.verify(&cert, *canister_id, false) { 139 | trace!(">> certificate failed verification: {}", e); 140 | return Ok(false); 141 | } 142 | 143 | let certified_data_path = vec![ 144 | "canister".into(), 145 | canister_id.into(), 146 | "certified_data".into(), 147 | ]; 148 | let witness = match lookup_value(&cert, certified_data_path) { 149 | Ok(witness) => witness, 150 | Err(e) => { 151 | trace!( 152 | ">> Could not find certified data for this canister in the certificate: {}", 153 | e 154 | ); 155 | return Ok(false); 156 | } 157 | }; 158 | let digest = tree.digest(); 159 | 160 | if witness != digest { 161 | trace!( 162 | ">> witness ({}) did not match digest ({})", 163 | hex::encode(witness), 164 | hex::encode(digest) 165 | ); 166 | 167 | return Ok(false); 168 | } 169 | 170 | let path = ["http_assets".into(), uri.path().into()]; 171 | let tree_sha = match tree.lookup_path(&path) { 172 | LookupResult::Found(v) => v, 173 | _ => match tree.lookup_path(&["http_assets".into(), "/index.html".into()]) { 174 | LookupResult::Found(v) => v, 175 | _ => { 176 | trace!( 177 | ">> Invalid Tree in the header. Does not contain path {:?}", 178 | path 179 | ); 180 | return Ok(false); 181 | } 182 | }, 183 | }; 184 | 185 | Ok(body_sha == tree_sha) 186 | } 187 | 188 | #[cfg(test)] 189 | mod tests { 190 | use ic_agent::{ 191 | agent::http_transport::{ 192 | hyper::{Body, Uri}, 193 | HyperReplicaV2Transport, 194 | }, 195 | ic_types::Principal, 196 | Agent, 197 | }; 198 | 199 | use crate::{ 200 | headers::HeadersData, 201 | validate::{Validate, Validator}, 202 | }; 203 | 204 | #[test] 205 | fn validate_nop() { 206 | let headers = HeadersData { 207 | certificate: None, 208 | encoding: None, 209 | tree: None, 210 | }; 211 | 212 | let canister_id = Principal::from_text("wwc2m-2qaaa-aaaac-qaaaa-cai").unwrap(); 213 | let uri = Uri::from_static("http://www.example.com"); 214 | let transport = HyperReplicaV2Transport::::create(uri.clone()).unwrap(); 215 | let agent = Agent::builder().with_transport(transport).build().unwrap(); 216 | let body = vec![]; 217 | 218 | let validator = Validator::new(); 219 | 220 | let out = validator.validate(&headers, &canister_id, &agent, &uri, &body); 221 | 222 | assert_eq!(out, Ok(())); 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /src/canister_id.rs: -------------------------------------------------------------------------------- 1 | use anyhow::Context; 2 | use clap::Args; 3 | use ic_agent::{ 4 | agent::http_transport::hyper::{header::HOST, http::request::Parts, Uri}, 5 | export::Principal, 6 | }; 7 | use tracing::error; 8 | 9 | use crate::config::dns_canister_config::DnsCanisterConfig; 10 | 11 | /// The options for the canister resolver 12 | #[derive(Args)] 13 | pub struct Opts { 14 | /// A map of domain names to canister IDs. 15 | /// Format: domain.name:canister-id 16 | #[clap(long)] 17 | dns_alias: Vec, 18 | 19 | /// A list of domain name suffixes. If found, the next (to the left) subdomain 20 | /// is used as the Principal, if it parses as a Principal. 21 | #[clap(long, default_value = "localhost")] 22 | dns_suffix: Vec, 23 | 24 | /// Whether or not to ignore `canisterId=` when locating the canister. 25 | #[clap(long)] 26 | ignore_url_canister_param: bool, 27 | } 28 | 29 | /// A resolver for `Principal`s from a `Uri`. 30 | trait UriResolver: Sync + Send { 31 | fn resolve(&self, uri: &Uri) -> Option; 32 | } 33 | 34 | impl UriResolver for &T { 35 | fn resolve(&self, uri: &Uri) -> Option { 36 | T::resolve(self, uri) 37 | } 38 | } 39 | struct UriParameterResolver; 40 | 41 | impl UriResolver for UriParameterResolver { 42 | fn resolve(&self, uri: &Uri) -> Option { 43 | form_urlencoded::parse(uri.query()?.as_bytes()) 44 | .find(|(name, _)| name == "canisterId") 45 | .and_then(|(_, canister_id)| Principal::from_text(canister_id.as_ref()).ok()) 46 | } 47 | } 48 | 49 | impl UriResolver for DnsCanisterConfig { 50 | fn resolve(&self, uri: &Uri) -> Option { 51 | self.resolve_canister_id(uri.host()?) 52 | } 53 | } 54 | 55 | /// A resolver for `Principal`s from a `Request`. 56 | pub trait Resolver: Sync + Send { 57 | fn resolve(&self, request: &Parts) -> Option; 58 | } 59 | 60 | impl Resolver for &T { 61 | fn resolve(&self, request: &Parts) -> Option { 62 | T::resolve(self, request) 63 | } 64 | } 65 | 66 | struct RequestUriResolver(pub T); 67 | 68 | impl Resolver for RequestUriResolver { 69 | fn resolve(&self, request: &Parts) -> Option { 70 | self.0.resolve(&request.uri) 71 | } 72 | } 73 | 74 | struct RequestHostResolver(pub T); 75 | 76 | impl Resolver for RequestHostResolver { 77 | fn resolve(&self, request: &Parts) -> Option { 78 | self.0.resolve( 79 | &Uri::builder() 80 | .authority(request.headers.get(HOST)?.as_bytes()) 81 | .build() 82 | .ok()?, 83 | ) 84 | } 85 | } 86 | 87 | /// The default canister id resolver 88 | pub struct DefaultResolver { 89 | pub dns: DnsCanisterConfig, 90 | pub check_params: bool, 91 | } 92 | 93 | impl Resolver for DefaultResolver { 94 | fn resolve(&self, request: &Parts) -> Option { 95 | if let Some(v) = RequestHostResolver(&self.dns).resolve(request) { 96 | return Some(v); 97 | } 98 | if let Some(v) = RequestUriResolver(&self.dns).resolve(request) { 99 | return Some(v); 100 | } 101 | if self.check_params { 102 | if let Some(v) = RequestUriResolver(UriParameterResolver).resolve(request) { 103 | return Some(v); 104 | } 105 | } 106 | None 107 | } 108 | } 109 | 110 | pub fn setup(opts: Opts) -> Result { 111 | let dns = DnsCanisterConfig::new(&opts.dns_alias, &opts.dns_suffix) 112 | .context("Failed to configure canister resolver DNS"); 113 | let dns = match dns { 114 | Err(e) => { 115 | error!("{e}"); 116 | Err(e) 117 | } 118 | Ok(v) => Ok(v), 119 | }?; 120 | Ok(DefaultResolver { 121 | dns, 122 | check_params: !opts.ignore_url_canister_param, 123 | }) 124 | } 125 | 126 | #[cfg(test)] 127 | mod tests { 128 | use ic_agent::{ 129 | agent::http_transport::hyper::{header::HOST, http::request::Parts, Request}, 130 | export::Principal, 131 | }; 132 | 133 | use super::{DefaultResolver, Resolver}; 134 | use crate::config::dns_canister_config::DnsCanisterConfig; 135 | 136 | #[test] 137 | fn simple_resolve() { 138 | let dns = parse_config( 139 | vec!["happy.little.domain.name:r7inp-6aaaa-aaaaa-aaabq-cai"], 140 | vec!["little.domain.name"], 141 | ); 142 | 143 | let resolver = DefaultResolver { 144 | dns, 145 | check_params: false, 146 | }; 147 | 148 | let req = build_req( 149 | Some("happy.little.domain.name"), 150 | "https://happy.little.domain.name/rrkah-fqaaa-aaaaa-aaaaq-cai", 151 | ); 152 | 153 | assert_eq!( 154 | resolver.resolve(&req), 155 | Some(principal("r7inp-6aaaa-aaaaa-aaabq-cai")) 156 | ); 157 | 158 | let req = build_req( 159 | Some("rrkah-fqaaa-aaaaa-aaaaq-cai.little.domain.name"), 160 | "/r7inp-6aaaa-aaaaa-aaabq-cai", 161 | ); 162 | 163 | assert_eq!( 164 | resolver.resolve(&req), 165 | Some(principal("rrkah-fqaaa-aaaaa-aaaaq-cai")) 166 | ); 167 | } 168 | 169 | #[test] 170 | fn prod() { 171 | let dns = parse_config( 172 | vec![ 173 | "personhood.ic0.app:g3wsl-eqaaa-aaaan-aaaaa-cai", 174 | "personhood.raw.ic0.app:g3wsl-eqaaa-aaaan-aaaaa-cai", 175 | "identity.ic0.app:rdmx6-jaaaa-aaaaa-aaadq-cai", 176 | "identity.raw.ic0.app:rdmx6-jaaaa-aaaaa-aaadq-cai", 177 | "nns.ic0.app:qoctq-giaaa-aaaaa-aaaea-cai", 178 | "nns.raw.ic0.app:qoctq-giaaa-aaaaa-aaaea-cai", 179 | "dscvr.ic0.app:h5aet-waaaa-aaaab-qaamq-cai", 180 | "dscvr.raw.ic0.app:h5aet-waaaa-aaaab-qaamq-cai", 181 | ], 182 | vec!["raw.ic0.app", "ic0.app"], 183 | ); 184 | 185 | let resolver = DefaultResolver { 186 | dns, 187 | check_params: false, 188 | }; 189 | 190 | let req = build_req(Some("nns.ic0.app"), "/about"); 191 | assert_eq!( 192 | resolver.resolve(&req), 193 | Some(principal("qoctq-giaaa-aaaaa-aaaea-cai")) 194 | ); 195 | 196 | let req = build_req(Some("nns.ic0.app"), "https://nns.ic0.app/about"); 197 | assert_eq!( 198 | resolver.resolve(&req), 199 | Some(principal("qoctq-giaaa-aaaaa-aaaea-cai")) 200 | ); 201 | 202 | let req = build_req(None, "https://nns.ic0.app/about"); 203 | assert_eq!( 204 | resolver.resolve(&req), 205 | Some(principal("qoctq-giaaa-aaaaa-aaaea-cai")) 206 | ); 207 | 208 | let req = build_req(None, "https://rrkah-fqaaa-aaaaa-aaaaq-cai.ic0.app/about"); 209 | assert_eq!( 210 | resolver.resolve(&req), 211 | Some(principal("rrkah-fqaaa-aaaaa-aaaaq-cai")) 212 | ); 213 | 214 | let req = build_req( 215 | Some("rrkah-fqaaa-aaaaa-aaaaq-cai.ic0.app"), 216 | "https://rrkah-fqaaa-aaaaa-aaaaq-cai.ic0.app/about", 217 | ); 218 | assert_eq!( 219 | resolver.resolve(&req), 220 | Some(principal("rrkah-fqaaa-aaaaa-aaaaq-cai")) 221 | ); 222 | 223 | let req = build_req(Some("rrkah-fqaaa-aaaaa-aaaaq-cai.ic0.app"), "/about"); 224 | assert_eq!( 225 | resolver.resolve(&req), 226 | Some(principal("rrkah-fqaaa-aaaaa-aaaaq-cai")) 227 | ); 228 | 229 | let req = build_req(Some("rrkah-fqaaa-aaaaa-aaaaq-cai.raw.ic0.app"), "/about"); 230 | assert_eq!( 231 | resolver.resolve(&req), 232 | Some(principal("rrkah-fqaaa-aaaaa-aaaaq-cai")) 233 | ); 234 | 235 | let req = build_req( 236 | Some("rrkah-fqaaa-aaaaa-aaaaq-cai.foo.raw.ic0.app"), 237 | "/about", 238 | ); 239 | assert_eq!(resolver.resolve(&req), None); 240 | } 241 | 242 | #[test] 243 | fn dfx() { 244 | let dns = parse_config(vec![], vec!["localhost"]); 245 | 246 | let resolver = DefaultResolver { 247 | dns, 248 | check_params: true, 249 | }; 250 | 251 | let req = build_req(Some("rrkah-fqaaa-aaaaa-aaaaq-cai.localhost"), "/about"); 252 | assert_eq!( 253 | resolver.resolve(&req), 254 | Some(principal("rrkah-fqaaa-aaaaa-aaaaq-cai")) 255 | ); 256 | let req = build_req( 257 | Some("localhost"), 258 | "/about?canisterId=rrkah-fqaaa-aaaaa-aaaaq-cai", 259 | ); 260 | assert_eq!( 261 | resolver.resolve(&req), 262 | Some(principal("rrkah-fqaaa-aaaaa-aaaaq-cai")) 263 | ); 264 | } 265 | 266 | fn parse_config(aliases: Vec<&str>, suffixes: Vec<&str>) -> DnsCanisterConfig { 267 | let aliases: Vec = aliases.iter().map(|&s| String::from(s)).collect(); 268 | let suffixes: Vec = suffixes.iter().map(|&s| String::from(s)).collect(); 269 | DnsCanisterConfig::new(&aliases, &suffixes).unwrap() 270 | } 271 | 272 | fn build_req(host: Option<&str>, uri: &str) -> Parts { 273 | let req = Request::builder().uri(uri); 274 | if let Some(host) = host { 275 | req.header(HOST, host) 276 | } else { 277 | req 278 | } 279 | .body(()) 280 | .unwrap() 281 | .into_parts() 282 | .0 283 | } 284 | 285 | fn principal(v: &str) -> Principal { 286 | Principal::from_text(v).unwrap() 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /src/http_client.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | borrow::Cow, 3 | collections::HashMap, 4 | fs::File, 5 | hash::{Hash, Hasher}, 6 | io::{Cursor, Read}, 7 | iter, 8 | net::SocketAddr, 9 | path::PathBuf, 10 | str::FromStr, 11 | sync::Arc, 12 | }; 13 | 14 | use anyhow::Context; 15 | use clap::Args; 16 | use hyper_rustls::HttpsConnectorBuilder; 17 | use itertools::Either; 18 | use tracing::error; 19 | 20 | use ic_agent::agent::http_transport::{ 21 | self, 22 | hyper::{ 23 | self, 24 | body::Bytes, 25 | client::{ 26 | connect::dns::{GaiResolver, Name}, 27 | HttpConnector, 28 | }, 29 | service::Service, 30 | Client, 31 | }, 32 | }; 33 | 34 | /// DNS resolve overrides 35 | /// `ic0.app=[::1]:9090` 36 | 37 | #[derive(Clone)] 38 | struct OptResolve { 39 | domain: String, 40 | addr: SocketAddr, 41 | } 42 | 43 | impl FromStr for OptResolve { 44 | type Err = anyhow::Error; 45 | fn from_str(s: &str) -> Result { 46 | let (domain, addr) = s 47 | .split_once('=') 48 | .ok_or_else(|| anyhow::Error::msg("missing '='"))?; 49 | Ok(OptResolve { 50 | domain: domain.into(), 51 | addr: addr.parse()?, 52 | }) 53 | } 54 | } 55 | 56 | /// The options for the HTTP client 57 | #[derive(Args)] 58 | pub struct Opts { 59 | /// The list of custom root HTTPS certificates to use to talk to the replica. This can be used 60 | /// to connect to an IC that has a self-signed certificate, for example. Do not use this when 61 | /// talking to the Internet Computer blockchain mainnet as it is unsecure. 62 | #[clap(long)] 63 | ssl_root_certificate: Vec, 64 | 65 | /// Allows HTTPS connection to replicas with invalid HTTPS certificates. This can be used to 66 | /// connect to an IC that has a self-signed certificate, for example. Do not use this when 67 | /// talking to the Internet Computer blockchain mainnet as it is *VERY* unsecure. 68 | #[clap(long)] 69 | danger_accept_invalid_ssl: bool, 70 | 71 | /// Override DNS resolution for specific replica domains to particular IP addresses. 72 | /// Examples: ic0.app=[::1]:9090 73 | #[clap(long, value_name("DOMAIN=IP_PORT"))] 74 | replica_resolve: Vec, 75 | } 76 | 77 | pub type Body = hyper::Body; 78 | 79 | pub trait HyperBody: 80 | http_transport::HyperBody 81 | + From<&'static [u8]> 82 | + From<&'static str> 83 | + From 84 | + From> 85 | + From> 86 | + From 87 | + From 88 | + Into 89 | { 90 | } 91 | 92 | impl HyperBody for B where 93 | B: http_transport::HyperBody 94 | + From<&'static [u8]> 95 | + From<&'static str> 96 | + From 97 | + From> 98 | + From> 99 | + From 100 | + From 101 | + Into 102 | { 103 | } 104 | 105 | /// Trait representing the contraints on [`Service`] that [`HyperReplicaV2Transport`] requires. 106 | pub trait HyperService: 107 | http_transport::HyperService 108 | { 109 | /// Values yielded in the `Body` of the `Response`. 110 | type ResponseBody2: HyperBody; 111 | } 112 | 113 | impl HyperService for S 114 | where 115 | B1: HyperBody, 116 | B2: HyperBody, 117 | S: http_transport::HyperService, 118 | { 119 | type ResponseBody2 = B2; 120 | } 121 | 122 | pub fn setup(opts: Opts) -> Result, anyhow::Error> { 123 | let Opts { 124 | danger_accept_invalid_ssl, 125 | ssl_root_certificate, 126 | replica_resolve, 127 | } = opts; 128 | let builder = rustls::ClientConfig::builder().with_safe_defaults(); 129 | let tls_config = if !danger_accept_invalid_ssl { 130 | use rustls::{Certificate, RootCertStore}; 131 | 132 | let mut root_cert_store = RootCertStore::empty(); 133 | for cert_path in ssl_root_certificate { 134 | let mut buf = Vec::new(); 135 | if let Err(e) = File::open(&cert_path).and_then(|mut v| v.read_to_end(&mut buf)) { 136 | tracing::warn!("Could not load cert `{}`: {}", cert_path.display(), e); 137 | continue; 138 | } 139 | match cert_path.extension() { 140 | Some(v) if v == "pem" => { 141 | tracing::info!( 142 | "adding PEM cert `{}` to root certificates", 143 | cert_path.display() 144 | ); 145 | let mut pem = Cursor::new(buf); 146 | let certs = match rustls_pemfile::certs(&mut pem) { 147 | Ok(v) => v, 148 | Err(e) => { 149 | tracing::warn!( 150 | "No valid certificate was found `{}`: {}", 151 | cert_path.display(), 152 | e 153 | ); 154 | continue; 155 | } 156 | }; 157 | for c in certs { 158 | if let Err(e) = root_cert_store.add(&rustls::Certificate(c)) { 159 | tracing::warn!( 160 | "Could not add part of cert `{}`: {}", 161 | cert_path.display(), 162 | e 163 | ); 164 | } 165 | } 166 | } 167 | Some(v) if v == "der" => { 168 | tracing::info!( 169 | "adding DER cert `{}` to root certificates", 170 | cert_path.display() 171 | ); 172 | if let Err(e) = root_cert_store.add(&Certificate(buf)) { 173 | tracing::warn!("Could not add cert `{}`: {}", cert_path.display(), e); 174 | } 175 | } 176 | _ => tracing::warn!( 177 | "Could not load cert `{}`: unknown extension", 178 | cert_path.display() 179 | ), 180 | } 181 | } 182 | 183 | use rustls::OwnedTrustAnchor; 184 | let trust_anchors = webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|trust_anchor| { 185 | OwnedTrustAnchor::from_subject_spki_name_constraints( 186 | trust_anchor.subject, 187 | trust_anchor.spki, 188 | trust_anchor.name_constraints, 189 | ) 190 | }); 191 | root_cert_store.add_server_trust_anchors(trust_anchors); 192 | 193 | builder 194 | .with_root_certificates(root_cert_store) 195 | .with_no_client_auth() 196 | } else { 197 | use rustls::{ 198 | client::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier, ServerName}, 199 | internal::msgs::handshake::DigitallySignedStruct, 200 | }; 201 | 202 | tracing::warn!("Allowing invalid certs. THIS VERY IS INSECURE."); 203 | struct NoVerifier; 204 | 205 | impl ServerCertVerifier for NoVerifier { 206 | fn verify_server_cert( 207 | &self, 208 | _end_entity: &rustls::Certificate, 209 | _intermediates: &[rustls::Certificate], 210 | _server_name: &ServerName, 211 | _scts: &mut dyn Iterator, 212 | _ocsp_response: &[u8], 213 | _now: std::time::SystemTime, 214 | ) -> Result { 215 | Ok(ServerCertVerified::assertion()) 216 | } 217 | 218 | fn verify_tls12_signature( 219 | &self, 220 | _message: &[u8], 221 | _cert: &rustls::Certificate, 222 | _dss: &DigitallySignedStruct, 223 | ) -> Result { 224 | Ok(HandshakeSignatureValid::assertion()) 225 | } 226 | 227 | fn verify_tls13_signature( 228 | &self, 229 | _message: &[u8], 230 | _cert: &rustls::Certificate, 231 | _dss: &DigitallySignedStruct, 232 | ) -> Result { 233 | Ok(HandshakeSignatureValid::assertion()) 234 | } 235 | } 236 | builder 237 | .with_custom_certificate_verifier(Arc::new(NoVerifier)) 238 | .with_no_client_auth() 239 | }; 240 | 241 | // Advertise support for HTTP/2 242 | //tls_config.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()]; 243 | 244 | #[derive(Debug, Eq)] 245 | struct Uncased(Name); 246 | impl PartialEq for Uncased { 247 | fn eq(&self, v: &Uncased) -> bool { 248 | self.0.as_str().eq_ignore_ascii_case(v.0.as_str()) 249 | } 250 | } 251 | impl Hash for Uncased { 252 | fn hash(&self, state: &mut H) { 253 | self.0.as_str().len().hash(state); 254 | for b in self.0.as_str().as_bytes() { 255 | state.write_u8(b.to_ascii_lowercase()); 256 | } 257 | } 258 | } 259 | 260 | let mapped = replica_resolve 261 | .into_iter() 262 | .map(|v| Ok((Uncased(Name::from_str(&v.domain)?), v.addr))) 263 | .collect::, anyhow::Error>>() 264 | .context("Invalid domain in `replica-resolve` flag"); 265 | // TODO: inspect_err 266 | let _ = mapped.as_ref().map_err(|e| error!("{}", e)); 267 | let mapped = Arc::new(mapped?); 268 | let resolver = tower::service_fn(move |name: Name| { 269 | let mapped = mapped.clone(); 270 | async move { 271 | let name = Uncased(name); 272 | if let Some(v) = mapped.get(&name) { 273 | Ok(Either::Left(iter::once(*v))) 274 | } else { 275 | GaiResolver::new().call(name.0).await.map(Either::Right) 276 | } 277 | } 278 | }); 279 | let mut connector = HttpConnector::new_with_resolver(resolver); 280 | connector.enforce_http(false); 281 | let connector = HttpsConnectorBuilder::new() 282 | .with_tls_config(tls_config) 283 | .https_or_http() 284 | .enable_http1() 285 | .enable_http2() 286 | .wrap_connector(connector); 287 | let client: Client<_, Body> = Client::builder().build(connector); 288 | Ok(client) 289 | } 290 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2020 DFINITY LLC. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /src/proxy/agent.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | net::SocketAddr, 3 | sync::{ 4 | atomic::{AtomicUsize, Ordering}, 5 | Arc, 6 | }, 7 | time::Duration, 8 | }; 9 | 10 | use anyhow::bail; 11 | use axum::{extract::ConnectInfo, Extension}; 12 | use futures::StreamExt; 13 | use http_body::{LengthLimitError, Limited}; 14 | use ic_agent::{ 15 | agent::http_transport::hyper::{ 16 | body, http::header::CONTENT_TYPE, Body, Request, Response, StatusCode, Uri, 17 | }, 18 | agent_error::HttpErrorPayload, 19 | Agent, AgentError, 20 | }; 21 | use ic_utils::{ 22 | call::{AsyncCall, SyncCall}, 23 | interfaces::http_request::{ 24 | HeaderField, HttpRequestCanister, HttpRequestStreamingCallbackAny, HttpResponse, 25 | StreamingCallbackHttpResponse, StreamingStrategy, Token, 26 | }, 27 | }; 28 | use tracing::{enabled, instrument, trace, warn, Level}; 29 | 30 | use crate::{ 31 | canister_id::Resolver as CanisterIdResolver, 32 | headers::extract_headers_data, 33 | proxy::{HandleError, REQUEST_BODY_SIZE_LIMIT}, 34 | validate::Validate, 35 | }; 36 | 37 | type HttpResponseAny = HttpResponse; 38 | 39 | // Limit the total number of calls to an HTTP Request loop to 1000 for now. 40 | const MAX_HTTP_REQUEST_STREAM_CALLBACK_CALL_COUNT: usize = 1000; 41 | 42 | // Limit the number of Stream Callbacks buffered 43 | const STREAM_CALLBACK_BUFFFER: usize = 2; 44 | 45 | // The maximum length of a body we should log as tracing. 46 | const MAX_LOG_BODY_SIZE: usize = 100; 47 | 48 | /// https://internetcomputer.org/docs/current/references/ic-interface-spec#reject-codes 49 | struct ReplicaErrorCodes; 50 | impl ReplicaErrorCodes { 51 | const DESTINATION_INVALID: u64 = 3; 52 | } 53 | 54 | pub struct ArgsInner { 55 | pub validator: Box, 56 | pub resolver: Box, 57 | pub counter: AtomicUsize, 58 | pub replicas: Vec<(Agent, Uri)>, 59 | pub debug: bool, 60 | pub fetch_root_key: bool, 61 | } 62 | 63 | pub struct Args { 64 | args: Arc, 65 | current: usize, 66 | } 67 | 68 | impl Clone for Args { 69 | fn clone(&self) -> Self { 70 | let args = self.args.clone(); 71 | Args { 72 | current: args.counter.fetch_add(1, Ordering::Relaxed) % args.replicas.len(), 73 | args, 74 | } 75 | } 76 | } 77 | 78 | impl From for Args { 79 | fn from(args: ArgsInner) -> Self { 80 | Args { 81 | args: Arc::new(args), 82 | current: 0, 83 | } 84 | } 85 | } 86 | impl Args { 87 | fn replica(&self) -> (&Agent, &Uri) { 88 | let v = &self.args.replicas[self.current]; 89 | (&v.0, &v.1) 90 | } 91 | } 92 | 93 | #[instrument(level = "info", skip_all, fields(addr = display(addr), replica = display(args.replica().1)))] 94 | pub async fn handler( 95 | Extension(args): Extension, 96 | ConnectInfo(addr): ConnectInfo, 97 | request: Request, 98 | ) -> Response { 99 | let agent = args.replica().0; 100 | let args = &args.args; 101 | async { 102 | if args.fetch_root_key && agent.fetch_root_key().await.is_err() { 103 | unable_to_fetch_root_key() 104 | } else { 105 | process_request_inner( 106 | request, 107 | agent, 108 | args.resolver.as_ref(), 109 | args.validator.as_ref(), 110 | ) 111 | .await 112 | } 113 | } 114 | .await 115 | .handle_error(args.debug) 116 | } 117 | 118 | fn unable_to_fetch_root_key() -> Result, anyhow::Error> { 119 | Ok(Response::builder() 120 | .status(StatusCode::INTERNAL_SERVER_ERROR) 121 | .body("Unable to fetch root key".into())?) 122 | } 123 | 124 | async fn process_request_inner( 125 | request: Request, 126 | agent: &Agent, 127 | resolver: &dyn CanisterIdResolver, 128 | validator: &dyn Validate, 129 | ) -> Result, anyhow::Error> { 130 | let (parts, body) = request.into_parts(); 131 | 132 | let canister_id = match resolver.resolve(&parts) { 133 | None => { 134 | return Ok(Response::builder() 135 | .status(StatusCode::BAD_REQUEST) 136 | .body("Could not find a canister id to forward to.".into()) 137 | .unwrap()) 138 | } 139 | Some(x) => x, 140 | }; 141 | 142 | trace!("<< {} {} {:?}", parts.method, parts.uri, parts.version); 143 | 144 | let method = parts.method; 145 | let uri = parts.uri.to_string(); 146 | let headers = parts 147 | .headers 148 | .iter() 149 | .filter_map(|(name, value)| { 150 | Some(HeaderField( 151 | name.as_str().into(), 152 | value.to_str().ok()?.into(), 153 | )) 154 | }) 155 | .inspect(|HeaderField(name, value)| { 156 | trace!("<< {}: {}", name, value); 157 | }) 158 | .collect::>(); 159 | 160 | // Limit request body size 161 | let body = Limited::new(body, REQUEST_BODY_SIZE_LIMIT); 162 | let entire_body = match body::to_bytes(body).await { 163 | Ok(data) => data, 164 | Err(err) => { 165 | if err.downcast_ref::().is_some() { 166 | return Ok(Response::builder() 167 | .status(StatusCode::PAYLOAD_TOO_LARGE) 168 | .body(Body::from("Request size exceeds limit"))?); 169 | } 170 | bail!("Failed to read body: {err}"); 171 | } 172 | } 173 | .to_vec(); 174 | 175 | trace!("<<"); 176 | if enabled!(Level::TRACE) { 177 | let body = String::from_utf8_lossy( 178 | &entire_body[0..usize::min(entire_body.len(), MAX_LOG_BODY_SIZE)], 179 | ); 180 | trace!( 181 | "<< \"{}\"{}", 182 | &body.escape_default(), 183 | if body.len() > MAX_LOG_BODY_SIZE { 184 | format!("... {} bytes total", body.len()) 185 | } else { 186 | String::new() 187 | } 188 | ); 189 | } 190 | 191 | let canister = HttpRequestCanister::create(agent, canister_id); 192 | let query_result = canister 193 | .http_request_custom( 194 | method.as_str(), 195 | uri.as_str(), 196 | headers.iter().cloned(), 197 | &entire_body, 198 | ) 199 | .call() 200 | .await; 201 | 202 | fn handle_result( 203 | result: Result<(HttpResponseAny,), AgentError>, 204 | ) -> Result, anyhow::Error>> { 205 | // If the result is a Replica error, returns the 500 code and message. There is no information 206 | // leak here because a user could use `dfx` to get the same reply. 207 | match result { 208 | Ok((http_response,)) => Ok(http_response), 209 | 210 | Err(AgentError::ReplicaError { 211 | reject_code: ReplicaErrorCodes::DESTINATION_INVALID, 212 | reject_message, 213 | }) => Err(Ok(Response::builder() 214 | .status(StatusCode::NOT_FOUND) 215 | .body(reject_message.into()) 216 | .unwrap())), 217 | 218 | Err(AgentError::ReplicaError { 219 | reject_code, 220 | reject_message, 221 | }) => Err(Ok(Response::builder() 222 | .status(StatusCode::BAD_GATEWAY) 223 | .body(format!(r#"Replica Error ({}): "{}""#, reject_code, reject_message).into()) 224 | .unwrap())), 225 | 226 | Err(AgentError::HttpError(HttpErrorPayload { 227 | status: 451, 228 | content_type, 229 | content, 230 | })) => Err(Ok(content_type 231 | .into_iter() 232 | .fold(Response::builder(), |r, c| r.header(CONTENT_TYPE, c)) 233 | .status(451) 234 | .body(content.into()) 235 | .unwrap())), 236 | 237 | Err(AgentError::ResponseSizeExceededLimit()) => Err(Ok(Response::builder() 238 | .status(StatusCode::INSUFFICIENT_STORAGE) 239 | .body("Response size exceeds limit".into()) 240 | .unwrap())), 241 | 242 | Err(e) => Err(Err(e.into())), 243 | } 244 | } 245 | 246 | let http_response = match handle_result(query_result) { 247 | Ok(http_response) => http_response, 248 | Err(response_or_error) => return response_or_error, 249 | }; 250 | 251 | let http_response = if http_response.upgrade == Some(true) { 252 | let waiter = garcon::Delay::builder() 253 | .throttle(Duration::from_millis(500)) 254 | .timeout(Duration::from_secs(15)) 255 | .build(); 256 | let update_result = canister 257 | .http_request_update_custom( 258 | method.as_str(), 259 | uri.as_str(), 260 | headers.iter().cloned(), 261 | &entire_body, 262 | ) 263 | .call_and_wait(waiter) 264 | .await; 265 | match handle_result(update_result) { 266 | Ok(http_response) => http_response, 267 | Err(response_or_error) => return response_or_error, 268 | } 269 | } else { 270 | http_response 271 | }; 272 | 273 | let mut builder = Response::builder().status(StatusCode::from_u16(http_response.status_code)?); 274 | for HeaderField(name, value) in &http_response.headers { 275 | builder = builder.header(name.as_ref(), value.as_ref()); 276 | } 277 | 278 | let headers_data = extract_headers_data(&http_response.headers); 279 | let body = if enabled!(Level::TRACE) { 280 | Some(http_response.body.clone()) 281 | } else { 282 | None 283 | }; 284 | let is_streaming = http_response.streaming_strategy.is_some(); 285 | let response = if let Some(streaming_strategy) = http_response.streaming_strategy { 286 | let body = http_response.body; 287 | let body = futures::stream::once(async move { Ok(body) }); 288 | let body = match streaming_strategy { 289 | StreamingStrategy::Callback(callback) => body::Body::wrap_stream( 290 | body.chain(futures::stream::try_unfold( 291 | (agent.clone(), callback.callback.0, Some(callback.token)), 292 | move |(agent, callback, callback_token)| async move { 293 | let callback_token = match callback_token { 294 | Some(callback_token) => callback_token, 295 | None => return Ok(None), 296 | }; 297 | 298 | let canister = HttpRequestCanister::create(&agent, callback.principal); 299 | match canister 300 | .http_request_stream_callback(&callback.method, callback_token) 301 | .call() 302 | .await 303 | { 304 | Ok((StreamingCallbackHttpResponse { body, token },)) => { 305 | Ok(Some((body, (agent, callback, token)))) 306 | } 307 | Err(e) => { 308 | warn!("Error happened during streaming: {}", e); 309 | Err(e) 310 | } 311 | } 312 | }, 313 | )) 314 | .take(MAX_HTTP_REQUEST_STREAM_CALLBACK_CALL_COUNT) 315 | .map(|x| async move { x }) 316 | .buffered(STREAM_CALLBACK_BUFFFER), 317 | ), 318 | }; 319 | 320 | builder.body(body)? 321 | } else { 322 | let body_valid = validator.validate( 323 | &headers_data, 324 | &canister_id, 325 | agent, 326 | &parts.uri, 327 | &http_response.body, 328 | ); 329 | if body_valid.is_err() { 330 | return Ok(Response::builder() 331 | .status(StatusCode::INTERNAL_SERVER_ERROR) 332 | .body(body_valid.unwrap_err().into()) 333 | .unwrap()); 334 | } 335 | builder.body(http_response.body.into())? 336 | }; 337 | 338 | if enabled!(Level::TRACE) { 339 | trace!( 340 | ">> {:?} {} {}", 341 | &response.version(), 342 | response.status().as_u16(), 343 | response.status().to_string() 344 | ); 345 | 346 | for (name, value) in response.headers() { 347 | let value = String::from_utf8_lossy(value.as_bytes()); 348 | trace!(">> {}: {}", name, value); 349 | } 350 | 351 | let body = body.unwrap_or_else(|| b"... streaming ...".to_vec()); 352 | 353 | trace!(">>"); 354 | trace!( 355 | ">> \"{}\"{}", 356 | String::from_utf8_lossy(&body[..usize::min(MAX_LOG_BODY_SIZE, body.len())]) 357 | .escape_default(), 358 | if is_streaming { 359 | "... streaming".to_string() 360 | } else if body.len() > MAX_LOG_BODY_SIZE { 361 | format!("... {} bytes total", body.len()) 362 | } else { 363 | String::new() 364 | } 365 | ); 366 | } 367 | 368 | Ok(response) 369 | } 370 | -------------------------------------------------------------------------------- /src/config/dns_canister_config.rs: -------------------------------------------------------------------------------- 1 | use std::cmp::Reverse; 2 | 3 | use ic_agent::ic_types::Principal; 4 | 5 | use crate::config::dns_canister_rule::DnsCanisterRule; 6 | 7 | /// Configuration for determination of Domain Name to Principal 8 | #[derive(Clone, Debug)] 9 | pub struct DnsCanisterConfig { 10 | rules: Vec, 11 | } 12 | 13 | impl DnsCanisterConfig { 14 | /// Create a DnsCanisterConfig instance from command-line configuration. 15 | /// dns_aliases: 0 or more entries of the form of dns.alias:canister-id 16 | /// dns_suffixes: 0 or more domain names which will match as a suffix 17 | pub fn new( 18 | dns_aliases: &[String], 19 | dns_suffixes: &[String], 20 | ) -> anyhow::Result { 21 | let mut rules = vec![]; 22 | for suffix in dns_suffixes { 23 | rules.push(DnsCanisterRule::new_suffix(suffix)); 24 | } 25 | for alias in dns_aliases { 26 | rules.push(DnsCanisterRule::new_alias(alias)?); 27 | } 28 | // Check suffixes first (via stable sort), because they will only match 29 | // if actually preceded by a canister id. 30 | rules.sort_by_key(|x| Reverse(x.dns_suffix().len())); 31 | Ok(DnsCanisterConfig { rules }) 32 | } 33 | 34 | /// Return the Principal of the canister that matches the hostname. 35 | /// 36 | /// `hostname` may contain uppercase or lowercase characters. 37 | pub fn resolve_canister_id(&self, hostname: &str) -> Option { 38 | self.rules 39 | .iter() 40 | .find_map(|rule| rule.lookup(hostname.split('.'))) 41 | } 42 | } 43 | 44 | #[cfg(test)] 45 | mod tests { 46 | use crate::config::dns_canister_config::DnsCanisterConfig; 47 | use ic_agent::ic_types::Principal; 48 | 49 | #[test] 50 | fn matches_whole_hostname() { 51 | let dns_aliases = 52 | parse_dns_aliases(vec!["happy.little.domain.name:r7inp-6aaaa-aaaaa-aaabq-cai"]) 53 | .unwrap(); 54 | 55 | assert_eq!( 56 | dns_aliases.resolve_canister_id("happy.little.domain.name"), 57 | Some(Principal::from_text("r7inp-6aaaa-aaaaa-aaabq-cai").unwrap()) 58 | ) 59 | } 60 | 61 | #[test] 62 | fn matches_partial_hostname() { 63 | let dns_aliases = 64 | parse_dns_aliases(vec!["little.domain.name:r7inp-6aaaa-aaaaa-aaabq-cai"]).unwrap(); 65 | 66 | assert_eq!( 67 | dns_aliases.resolve_canister_id("happy.little.domain.name"), 68 | Some(Principal::from_text("r7inp-6aaaa-aaaaa-aaabq-cai").unwrap()) 69 | ) 70 | } 71 | 72 | #[test] 73 | fn extraneous_does_not_match() { 74 | let dns_aliases = parse_dns_aliases(vec![ 75 | "very.happy.little.domain.name:r7inp-6aaaa-aaaaa-aaabq-cai", 76 | ]) 77 | .unwrap(); 78 | 79 | assert_eq!( 80 | dns_aliases.resolve_canister_id("happy.little.domain.name"), 81 | None 82 | ) 83 | } 84 | 85 | #[test] 86 | fn case_insensitive_match() { 87 | let dns_aliases = 88 | parse_dns_aliases(vec!["lItTlE.doMain.nAMe:r7inp-6aaaa-aaaaa-aaabq-cai"]).unwrap(); 89 | 90 | assert_eq!( 91 | dns_aliases.resolve_canister_id("happy.little.domain.name"), 92 | Some(Principal::from_text("r7inp-6aaaa-aaaaa-aaabq-cai").unwrap()) 93 | ) 94 | } 95 | 96 | #[test] 97 | fn chooses_among_many() { 98 | let dns_aliases = parse_dns_aliases(vec![ 99 | "happy.little.domain.name:r7inp-6aaaa-aaaaa-aaabq-cai", 100 | "ecstatic.domain.name:rrkah-fqaaa-aaaaa-aaaaq-cai", 101 | ]) 102 | .unwrap(); 103 | 104 | assert_eq!( 105 | dns_aliases.resolve_canister_id("happy.little.domain.name"), 106 | Some(Principal::from_text("r7inp-6aaaa-aaaaa-aaabq-cai").unwrap()) 107 | ); 108 | 109 | assert_eq!( 110 | dns_aliases.resolve_canister_id("ecstatic.domain.name"), 111 | Some(Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai").unwrap()) 112 | ); 113 | 114 | assert_eq!( 115 | dns_aliases.resolve_canister_id("super.ecstatic.domain.name"), 116 | Some(Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai").unwrap()) 117 | ) 118 | } 119 | 120 | #[test] 121 | fn chooses_first_match() { 122 | let dns_aliases = parse_dns_aliases(vec![ 123 | "specific.of.many:r7inp-6aaaa-aaaaa-aaabq-cai", 124 | "of.many:rrkah-fqaaa-aaaaa-aaaaq-cai", 125 | ]) 126 | .unwrap(); 127 | 128 | assert_eq!( 129 | dns_aliases.resolve_canister_id("specific.of.many"), 130 | Some(Principal::from_text("r7inp-6aaaa-aaaaa-aaabq-cai").unwrap()) 131 | ); 132 | assert_eq!( 133 | dns_aliases.resolve_canister_id("more.specific.of.many"), 134 | Some(Principal::from_text("r7inp-6aaaa-aaaaa-aaabq-cai").unwrap()) 135 | ); 136 | 137 | assert_eq!( 138 | dns_aliases.resolve_canister_id("another.of.many"), 139 | Some(Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai").unwrap()) 140 | ) 141 | } 142 | 143 | #[test] 144 | fn searches_longest_to_shortest() { 145 | // If we checked these in the order passed, a.b.c would erroneously resolve 146 | // to the canister id associated with b.c 147 | let dns_aliases = parse_dns_aliases(vec![ 148 | "b.c:rrkah-fqaaa-aaaaa-aaaaq-cai", 149 | "a.b.c:r7inp-6aaaa-aaaaa-aaabq-cai", 150 | ]) 151 | .unwrap(); 152 | 153 | assert_eq!( 154 | dns_aliases.resolve_canister_id("a.b.c"), 155 | Some(Principal::from_text("r7inp-6aaaa-aaaaa-aaabq-cai").unwrap()) 156 | ); 157 | assert_eq!( 158 | dns_aliases.resolve_canister_id("d.b.c"), 159 | Some(Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai").unwrap()) 160 | ); 161 | } 162 | 163 | #[test] 164 | fn searches_longest_to_shortest_even_if_already_ordered() { 165 | // Similar to searches_longest_to_shortest, just to ensure that 166 | // we do the right thing no matter which order they are passed. 167 | let dns_aliases = parse_dns_aliases(vec![ 168 | "a.b.c:r7inp-6aaaa-aaaaa-aaabq-cai", 169 | "b.c:rrkah-fqaaa-aaaaa-aaaaq-cai", 170 | ]) 171 | .unwrap(); 172 | 173 | assert_eq!( 174 | dns_aliases.resolve_canister_id("a.b.c"), 175 | Some(Principal::from_text("r7inp-6aaaa-aaaaa-aaabq-cai").unwrap()) 176 | ); 177 | assert_eq!( 178 | dns_aliases.resolve_canister_id("d.b.c"), 179 | Some(Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai").unwrap()) 180 | ); 181 | } 182 | 183 | #[test] 184 | fn searches_longest_to_shortest_not_alpha() { 185 | // Similar to searches_longest_to_shortest, but make sure we 186 | // don't happen to get there by sorting alphabetically 187 | let dns_aliases = parse_dns_aliases(vec![ 188 | "x.c:rrkah-fqaaa-aaaaa-aaaaq-cai", 189 | "a.x.c:r7inp-6aaaa-aaaaa-aaabq-cai", 190 | ]) 191 | .unwrap(); 192 | 193 | assert_eq!( 194 | dns_aliases.resolve_canister_id("a.x.c"), 195 | Some(Principal::from_text("r7inp-6aaaa-aaaaa-aaabq-cai").unwrap()) 196 | ); 197 | assert_eq!( 198 | dns_aliases.resolve_canister_id("d.x.c"), 199 | Some(Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai").unwrap()) 200 | ); 201 | } 202 | 203 | #[test] 204 | fn searches_longest_to_shortest_not_alpha_reversed() { 205 | // Similar to searches_longest_to_shortest, but make sure we 206 | // don't happen to get there by sorting alphabetically/reversed 207 | let dns_aliases = parse_dns_aliases(vec![ 208 | "a.c:rrkah-fqaaa-aaaaa-aaaaq-cai", 209 | "x.a.c:r7inp-6aaaa-aaaaa-aaabq-cai", 210 | ]) 211 | .unwrap(); 212 | 213 | assert_eq!( 214 | dns_aliases.resolve_canister_id("x.a.c"), 215 | Some(Principal::from_text("r7inp-6aaaa-aaaaa-aaabq-cai").unwrap()) 216 | ); 217 | assert_eq!( 218 | dns_aliases.resolve_canister_id("d.a.c"), 219 | Some(Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai").unwrap()) 220 | ); 221 | } 222 | 223 | #[test] 224 | fn dns_suffix_localhost_canister_found() { 225 | let config = parse_config(vec![], vec!["localhost"]).unwrap(); 226 | 227 | assert_eq!( 228 | config.resolve_canister_id("rrkah-fqaaa-aaaaa-aaaaq-cai.localhost"), 229 | Some(Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai").unwrap()) 230 | ); 231 | assert_eq!( 232 | config.resolve_canister_id("r7inp-6aaaa-aaaaa-aaabq-cai.localhost"), 233 | Some(Principal::from_text("r7inp-6aaaa-aaaaa-aaabq-cai").unwrap()) 234 | ) 235 | } 236 | 237 | #[test] 238 | fn dns_suffix_localhost_more_domain_names_ok() { 239 | let config = parse_config(vec![], vec!["localhost"]).unwrap(); 240 | 241 | assert_eq!( 242 | config.resolve_canister_id("more.rrkah-fqaaa-aaaaa-aaaaq-cai.localhost"), 243 | Some(Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai").unwrap()) 244 | ); 245 | assert_eq!( 246 | config.resolve_canister_id("even.more.r7inp-6aaaa-aaaaa-aaabq-cai.localhost"), 247 | Some(Principal::from_text("r7inp-6aaaa-aaaaa-aaabq-cai").unwrap()) 248 | ) 249 | } 250 | 251 | #[test] 252 | fn dns_suffix_must_immediately_precede_suffix() { 253 | let config = parse_config(vec![], vec!["localhost"]).unwrap(); 254 | 255 | assert_eq!( 256 | config.resolve_canister_id("rrkah-fqaaa-aaaaa-aaaaq-cai.nope.localhost"), 257 | None 258 | ); 259 | } 260 | 261 | #[test] 262 | fn dns_suffix_longer_suffix_ok() { 263 | let config = parse_config(vec![], vec!["a.b.c"]).unwrap(); 264 | 265 | assert_eq!( 266 | config.resolve_canister_id("rrkah-fqaaa-aaaaa-aaaaq-cai.a.b.c"), 267 | Some(Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai").unwrap()) 268 | ); 269 | } 270 | 271 | #[test] 272 | fn dns_suffix_longer_suffix_still_requires_exact_positionok() { 273 | let config = parse_config(vec![], vec!["a.b.c"]).unwrap(); 274 | 275 | assert_eq!( 276 | config.resolve_canister_id("rrkah-fqaaa-aaaaa-aaaaq-cai.no.a.b.c"), 277 | None 278 | ); 279 | } 280 | 281 | #[test] 282 | fn dns_suffix_longer_suffix_can_be_preceded_by_more() { 283 | let config = parse_config(vec![], vec!["a.b.c"]).unwrap(); 284 | 285 | assert_eq!( 286 | config.resolve_canister_id("yes.rrkah-fqaaa-aaaaa-aaaaq-cai.a.b.c"), 287 | Some(Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai").unwrap()) 288 | ); 289 | } 290 | 291 | #[test] 292 | fn dns_suffix_ignores_earlier_canister_ids() { 293 | let config = parse_config(vec![], vec!["a.b.c"]).unwrap(); 294 | 295 | assert_eq!( 296 | config.resolve_canister_id( 297 | "r7inp-6aaaa-aaaaa-aaabq-cai.rrkah-fqaaa-aaaaa-aaaaq-cai.a.b.c" 298 | ), 299 | Some(Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai").unwrap()) 300 | ); 301 | } 302 | 303 | #[test] 304 | fn aliases_and_suffixes() { 305 | let config = parse_config( 306 | vec![ 307 | "a.b.c:r7inp-6aaaa-aaaaa-aaabq-cai", 308 | "d.e:rrkah-fqaaa-aaaaa-aaaaq-cai", 309 | ], 310 | vec!["g.h.i"], 311 | ) 312 | .unwrap(); 313 | 314 | assert_eq!( 315 | config.resolve_canister_id("a.b.c"), 316 | Some(Principal::from_text("r7inp-6aaaa-aaaaa-aaabq-cai").unwrap()) 317 | ); 318 | assert_eq!( 319 | config.resolve_canister_id("d.e"), 320 | Some(Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai").unwrap()) 321 | ); 322 | assert_eq!( 323 | config.resolve_canister_id("ryjl3-tyaaa-aaaaa-aaaba-cai.g.h.i"), 324 | Some(Principal::from_text("ryjl3-tyaaa-aaaaa-aaaba-cai").unwrap()) 325 | ); 326 | } 327 | 328 | #[test] 329 | fn same_alias_and_suffix_prefers_alias() { 330 | // because the suffix will only match if preceded by a canister id 331 | let config = 332 | parse_config(vec!["a.b.c:r7inp-6aaaa-aaaaa-aaabq-cai"], vec!["a.b.c"]).unwrap(); 333 | 334 | assert_eq!( 335 | config.resolve_canister_id("a.b.c"), 336 | Some(Principal::from_text("r7inp-6aaaa-aaaaa-aaabq-cai").unwrap()) 337 | ); 338 | assert_eq!( 339 | config.resolve_canister_id("ryjl3-tyaaa-aaaaa-aaaba-cai.a.b.c"), 340 | Some(Principal::from_text("ryjl3-tyaaa-aaaaa-aaaba-cai").unwrap()) 341 | ); 342 | } 343 | 344 | fn parse_dns_aliases(aliases: Vec<&str>) -> anyhow::Result { 345 | parse_config(aliases, vec![]) 346 | } 347 | 348 | fn parse_config(aliases: Vec<&str>, suffixes: Vec<&str>) -> anyhow::Result { 349 | let aliases: Vec = aliases.iter().map(|&s| String::from(s)).collect(); 350 | let suffixes: Vec = suffixes.iter().map(|&s| String::from(s)).collect(); 351 | DnsCanisterConfig::new(&aliases, &suffixes) 352 | } 353 | } 354 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "adler" 7 | version = "1.0.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 10 | 11 | [[package]] 12 | name = "aho-corasick" 13 | version = "0.7.18" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" 16 | dependencies = [ 17 | "memchr", 18 | ] 19 | 20 | [[package]] 21 | name = "ansi_term" 22 | version = "0.12.1" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" 25 | dependencies = [ 26 | "winapi", 27 | ] 28 | 29 | [[package]] 30 | name = "anyhow" 31 | version = "1.0.56" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" 34 | 35 | [[package]] 36 | name = "arrayvec" 37 | version = "0.5.2" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" 40 | 41 | [[package]] 42 | name = "ascii-canvas" 43 | version = "3.0.0" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" 46 | dependencies = [ 47 | "term", 48 | ] 49 | 50 | [[package]] 51 | name = "async-trait" 52 | version = "0.1.53" 53 | source = "registry+https://github.com/rust-lang/crates.io-index" 54 | checksum = "ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600" 55 | dependencies = [ 56 | "proc-macro2", 57 | "quote", 58 | "syn", 59 | ] 60 | 61 | [[package]] 62 | name = "atty" 63 | version = "0.2.14" 64 | source = "registry+https://github.com/rust-lang/crates.io-index" 65 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 66 | dependencies = [ 67 | "hermit-abi", 68 | "libc", 69 | "winapi", 70 | ] 71 | 72 | [[package]] 73 | name = "autocfg" 74 | version = "1.1.0" 75 | source = "registry+https://github.com/rust-lang/crates.io-index" 76 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 77 | 78 | [[package]] 79 | name = "axum" 80 | version = "0.5.13" 81 | source = "registry+https://github.com/rust-lang/crates.io-index" 82 | checksum = "6b9496f0c1d1afb7a2af4338bbe1d969cddfead41d87a9fb3aaa6d0bbc7af648" 83 | dependencies = [ 84 | "async-trait", 85 | "axum-core", 86 | "bitflags", 87 | "bytes", 88 | "futures-util", 89 | "http", 90 | "http-body", 91 | "hyper", 92 | "itoa", 93 | "matchit", 94 | "memchr", 95 | "mime", 96 | "percent-encoding", 97 | "pin-project-lite", 98 | "serde", 99 | "serde_json", 100 | "serde_urlencoded", 101 | "sync_wrapper", 102 | "tokio", 103 | "tower", 104 | "tower-http", 105 | "tower-layer", 106 | "tower-service", 107 | ] 108 | 109 | [[package]] 110 | name = "axum-core" 111 | version = "0.2.8" 112 | source = "registry+https://github.com/rust-lang/crates.io-index" 113 | checksum = "d9f0c0a60006f2a293d82d571f635042a72edf927539b7685bd62d361963839b" 114 | dependencies = [ 115 | "async-trait", 116 | "bytes", 117 | "futures-util", 118 | "http", 119 | "http-body", 120 | "mime", 121 | "tower-layer", 122 | "tower-service", 123 | ] 124 | 125 | [[package]] 126 | name = "base16ct" 127 | version = "0.1.1" 128 | source = "registry+https://github.com/rust-lang/crates.io-index" 129 | checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" 130 | 131 | [[package]] 132 | name = "base32" 133 | version = "0.4.0" 134 | source = "registry+https://github.com/rust-lang/crates.io-index" 135 | checksum = "23ce669cd6c8588f79e15cf450314f9638f967fc5770ff1c7c1deb0925ea7cfa" 136 | 137 | [[package]] 138 | name = "base64" 139 | version = "0.13.0" 140 | source = "registry+https://github.com/rust-lang/crates.io-index" 141 | checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" 142 | 143 | [[package]] 144 | name = "base64ct" 145 | version = "1.5.0" 146 | source = "registry+https://github.com/rust-lang/crates.io-index" 147 | checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" 148 | 149 | [[package]] 150 | name = "beef" 151 | version = "0.5.1" 152 | source = "registry+https://github.com/rust-lang/crates.io-index" 153 | checksum = "bed554bd50246729a1ec158d08aa3235d1b69d94ad120ebe187e28894787e736" 154 | 155 | [[package]] 156 | name = "binread" 157 | version = "2.2.0" 158 | source = "registry+https://github.com/rust-lang/crates.io-index" 159 | checksum = "16598dfc8e6578e9b597d9910ba2e73618385dc9f4b1d43dd92c349d6be6418f" 160 | dependencies = [ 161 | "binread_derive", 162 | "lazy_static", 163 | "rustversion", 164 | ] 165 | 166 | [[package]] 167 | name = "binread_derive" 168 | version = "2.1.0" 169 | source = "registry+https://github.com/rust-lang/crates.io-index" 170 | checksum = "1d9672209df1714ee804b1f4d4f68c8eb2a90b1f7a07acf472f88ce198ef1fed" 171 | dependencies = [ 172 | "either", 173 | "proc-macro2", 174 | "quote", 175 | "syn", 176 | ] 177 | 178 | [[package]] 179 | name = "bit-set" 180 | version = "0.5.2" 181 | source = "registry+https://github.com/rust-lang/crates.io-index" 182 | checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" 183 | dependencies = [ 184 | "bit-vec", 185 | ] 186 | 187 | [[package]] 188 | name = "bit-vec" 189 | version = "0.6.3" 190 | source = "registry+https://github.com/rust-lang/crates.io-index" 191 | checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" 192 | 193 | [[package]] 194 | name = "bitflags" 195 | version = "1.3.2" 196 | source = "registry+https://github.com/rust-lang/crates.io-index" 197 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 198 | 199 | [[package]] 200 | name = "block-buffer" 201 | version = "0.9.0" 202 | source = "registry+https://github.com/rust-lang/crates.io-index" 203 | checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" 204 | dependencies = [ 205 | "generic-array", 206 | ] 207 | 208 | [[package]] 209 | name = "block-buffer" 210 | version = "0.10.2" 211 | source = "registry+https://github.com/rust-lang/crates.io-index" 212 | checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" 213 | dependencies = [ 214 | "generic-array", 215 | ] 216 | 217 | [[package]] 218 | name = "bls12_381" 219 | version = "0.7.0" 220 | source = "registry+https://github.com/rust-lang/crates.io-index" 221 | checksum = "62250ece575fa9b22068b3a8d59586f01d426dd7785522efd97632959e71c986" 222 | dependencies = [ 223 | "digest 0.9.0", 224 | "ff", 225 | "group", 226 | "pairing", 227 | "rand_core", 228 | "subtle", 229 | ] 230 | 231 | [[package]] 232 | name = "bumpalo" 233 | version = "3.9.1" 234 | source = "registry+https://github.com/rust-lang/crates.io-index" 235 | checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" 236 | 237 | [[package]] 238 | name = "byteorder" 239 | version = "1.4.3" 240 | source = "registry+https://github.com/rust-lang/crates.io-index" 241 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 242 | 243 | [[package]] 244 | name = "bytes" 245 | version = "1.1.0" 246 | source = "registry+https://github.com/rust-lang/crates.io-index" 247 | checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" 248 | 249 | [[package]] 250 | name = "candid" 251 | version = "0.7.18" 252 | source = "registry+https://github.com/rust-lang/crates.io-index" 253 | checksum = "d510cc32b8b991acc955dd3d5e0cb6f404069d1dccd9203ee90f5865557c9165" 254 | dependencies = [ 255 | "anyhow", 256 | "binread", 257 | "byteorder", 258 | "candid_derive", 259 | "codespan-reporting", 260 | "hex", 261 | "ic-types", 262 | "lalrpop", 263 | "lalrpop-util", 264 | "leb128", 265 | "logos", 266 | "num-bigint", 267 | "num-traits", 268 | "num_enum", 269 | "paste", 270 | "pretty", 271 | "serde", 272 | "serde_bytes", 273 | "thiserror", 274 | ] 275 | 276 | [[package]] 277 | name = "candid_derive" 278 | version = "0.4.5" 279 | source = "registry+https://github.com/rust-lang/crates.io-index" 280 | checksum = "2e02c03c4d547674a3f3f3109538fb49871fbe636216daa019f06a62faca9061" 281 | dependencies = [ 282 | "lazy_static", 283 | "proc-macro2", 284 | "quote", 285 | "syn", 286 | ] 287 | 288 | [[package]] 289 | name = "cc" 290 | version = "1.0.73" 291 | source = "registry+https://github.com/rust-lang/crates.io-index" 292 | checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" 293 | 294 | [[package]] 295 | name = "cfg-if" 296 | version = "1.0.0" 297 | source = "registry+https://github.com/rust-lang/crates.io-index" 298 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 299 | 300 | [[package]] 301 | name = "clap" 302 | version = "4.0.4" 303 | source = "registry+https://github.com/rust-lang/crates.io-index" 304 | checksum = "7f78ad8e84aa8e8aa3e821857be40eb4b925ff232de430d4dd2ae6aa058cbd92" 305 | dependencies = [ 306 | "atty", 307 | "bitflags", 308 | "clap_derive", 309 | "clap_lex", 310 | "once_cell", 311 | "strsim", 312 | "termcolor", 313 | ] 314 | 315 | [[package]] 316 | name = "clap_derive" 317 | version = "4.0.1" 318 | source = "registry+https://github.com/rust-lang/crates.io-index" 319 | checksum = "ca689d7434ce44517a12a89456b2be4d1ea1cafcd8f581978c03d45f5a5c12a7" 320 | dependencies = [ 321 | "heck", 322 | "proc-macro-error", 323 | "proc-macro2", 324 | "quote", 325 | "syn", 326 | ] 327 | 328 | [[package]] 329 | name = "clap_lex" 330 | version = "0.3.0" 331 | source = "registry+https://github.com/rust-lang/crates.io-index" 332 | checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" 333 | dependencies = [ 334 | "os_str_bytes", 335 | ] 336 | 337 | [[package]] 338 | name = "codespan-reporting" 339 | version = "0.11.1" 340 | source = "registry+https://github.com/rust-lang/crates.io-index" 341 | checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" 342 | dependencies = [ 343 | "termcolor", 344 | "unicode-width", 345 | ] 346 | 347 | [[package]] 348 | name = "const-oid" 349 | version = "0.9.0" 350 | source = "registry+https://github.com/rust-lang/crates.io-index" 351 | checksum = "722e23542a15cea1f65d4a1419c4cfd7a26706c70871a13a04238ca3f40f1661" 352 | 353 | [[package]] 354 | name = "core-foundation" 355 | version = "0.9.3" 356 | source = "registry+https://github.com/rust-lang/crates.io-index" 357 | checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" 358 | dependencies = [ 359 | "core-foundation-sys", 360 | "libc", 361 | ] 362 | 363 | [[package]] 364 | name = "core-foundation-sys" 365 | version = "0.8.3" 366 | source = "registry+https://github.com/rust-lang/crates.io-index" 367 | checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" 368 | 369 | [[package]] 370 | name = "cpufeatures" 371 | version = "0.2.1" 372 | source = "registry+https://github.com/rust-lang/crates.io-index" 373 | checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" 374 | dependencies = [ 375 | "libc", 376 | ] 377 | 378 | [[package]] 379 | name = "crc32fast" 380 | version = "1.3.2" 381 | source = "registry+https://github.com/rust-lang/crates.io-index" 382 | checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" 383 | dependencies = [ 384 | "cfg-if", 385 | ] 386 | 387 | [[package]] 388 | name = "crossbeam-channel" 389 | version = "0.5.3" 390 | source = "registry+https://github.com/rust-lang/crates.io-index" 391 | checksum = "fdbfe11fe19ff083c48923cf179540e8cd0535903dc35e178a1fdeeb59aef51f" 392 | dependencies = [ 393 | "cfg-if", 394 | "crossbeam-utils", 395 | ] 396 | 397 | [[package]] 398 | name = "crossbeam-utils" 399 | version = "0.8.8" 400 | source = "registry+https://github.com/rust-lang/crates.io-index" 401 | checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" 402 | dependencies = [ 403 | "cfg-if", 404 | "lazy_static", 405 | ] 406 | 407 | [[package]] 408 | name = "crunchy" 409 | version = "0.2.2" 410 | source = "registry+https://github.com/rust-lang/crates.io-index" 411 | checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" 412 | 413 | [[package]] 414 | name = "crypto-bigint" 415 | version = "0.4.4" 416 | source = "registry+https://github.com/rust-lang/crates.io-index" 417 | checksum = "40997c4145fd5570180f579db9fcea452c91a2b72411da899efb1fb041136eae" 418 | dependencies = [ 419 | "generic-array", 420 | "rand_core", 421 | "subtle", 422 | "zeroize", 423 | ] 424 | 425 | [[package]] 426 | name = "crypto-common" 427 | version = "0.1.3" 428 | source = "registry+https://github.com/rust-lang/crates.io-index" 429 | checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" 430 | dependencies = [ 431 | "generic-array", 432 | "typenum", 433 | ] 434 | 435 | [[package]] 436 | name = "dashmap" 437 | version = "4.0.2" 438 | source = "registry+https://github.com/rust-lang/crates.io-index" 439 | checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" 440 | dependencies = [ 441 | "cfg-if", 442 | "num_cpus", 443 | ] 444 | 445 | [[package]] 446 | name = "data-encoding" 447 | version = "2.3.2" 448 | source = "registry+https://github.com/rust-lang/crates.io-index" 449 | checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" 450 | 451 | [[package]] 452 | name = "der" 453 | version = "0.6.0" 454 | source = "registry+https://github.com/rust-lang/crates.io-index" 455 | checksum = "13dd2ae565c0a381dde7fade45fce95984c568bdcb4700a4fdbe3175e0380b2f" 456 | dependencies = [ 457 | "const-oid", 458 | "pem-rfc7468", 459 | "zeroize", 460 | ] 461 | 462 | [[package]] 463 | name = "diff" 464 | version = "0.1.12" 465 | source = "registry+https://github.com/rust-lang/crates.io-index" 466 | checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" 467 | 468 | [[package]] 469 | name = "digest" 470 | version = "0.9.0" 471 | source = "registry+https://github.com/rust-lang/crates.io-index" 472 | checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" 473 | dependencies = [ 474 | "generic-array", 475 | ] 476 | 477 | [[package]] 478 | name = "digest" 479 | version = "0.10.3" 480 | source = "registry+https://github.com/rust-lang/crates.io-index" 481 | checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" 482 | dependencies = [ 483 | "block-buffer 0.10.2", 484 | "crypto-common", 485 | "subtle", 486 | ] 487 | 488 | [[package]] 489 | name = "dirs-next" 490 | version = "2.0.0" 491 | source = "registry+https://github.com/rust-lang/crates.io-index" 492 | checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" 493 | dependencies = [ 494 | "cfg-if", 495 | "dirs-sys-next", 496 | ] 497 | 498 | [[package]] 499 | name = "dirs-sys-next" 500 | version = "0.1.2" 501 | source = "registry+https://github.com/rust-lang/crates.io-index" 502 | checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" 503 | dependencies = [ 504 | "libc", 505 | "redox_users", 506 | "winapi", 507 | ] 508 | 509 | [[package]] 510 | name = "ecdsa" 511 | version = "0.14.1" 512 | source = "registry+https://github.com/rust-lang/crates.io-index" 513 | checksum = "e1e737f9eebb44576f3ee654141a789464071eb369d02c4397b32b6a79790112" 514 | dependencies = [ 515 | "der", 516 | "elliptic-curve", 517 | "rfc6979", 518 | "signature", 519 | ] 520 | 521 | [[package]] 522 | name = "either" 523 | version = "1.6.1" 524 | source = "registry+https://github.com/rust-lang/crates.io-index" 525 | checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" 526 | 527 | [[package]] 528 | name = "elliptic-curve" 529 | version = "0.12.0" 530 | source = "registry+https://github.com/rust-lang/crates.io-index" 531 | checksum = "bdd8c93ccd534d6a9790f4455cd71e7adb53a12e9af7dd54d1e258473f100cea" 532 | dependencies = [ 533 | "base16ct", 534 | "crypto-bigint", 535 | "der", 536 | "digest 0.10.3", 537 | "ff", 538 | "generic-array", 539 | "group", 540 | "pem-rfc7468", 541 | "pkcs8", 542 | "rand_core", 543 | "sec1", 544 | "subtle", 545 | "zeroize", 546 | ] 547 | 548 | [[package]] 549 | name = "ena" 550 | version = "0.14.0" 551 | source = "registry+https://github.com/rust-lang/crates.io-index" 552 | checksum = "d7402b94a93c24e742487327a7cd839dc9d36fec9de9fb25b09f2dae459f36c3" 553 | dependencies = [ 554 | "log", 555 | ] 556 | 557 | [[package]] 558 | name = "ff" 559 | version = "0.12.0" 560 | source = "registry+https://github.com/rust-lang/crates.io-index" 561 | checksum = "df689201f395c6b90dfe87127685f8dbfc083a5e779e613575d8bd7314300c3e" 562 | dependencies = [ 563 | "rand_core", 564 | "subtle", 565 | ] 566 | 567 | [[package]] 568 | name = "fixedbitset" 569 | version = "0.2.0" 570 | source = "registry+https://github.com/rust-lang/crates.io-index" 571 | checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" 572 | 573 | [[package]] 574 | name = "flate2" 575 | version = "1.0.22" 576 | source = "registry+https://github.com/rust-lang/crates.io-index" 577 | checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" 578 | dependencies = [ 579 | "cfg-if", 580 | "crc32fast", 581 | "libc", 582 | "miniz_oxide", 583 | ] 584 | 585 | [[package]] 586 | name = "fnv" 587 | version = "1.0.7" 588 | source = "registry+https://github.com/rust-lang/crates.io-index" 589 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 590 | 591 | [[package]] 592 | name = "form_urlencoded" 593 | version = "1.0.1" 594 | source = "registry+https://github.com/rust-lang/crates.io-index" 595 | checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" 596 | dependencies = [ 597 | "matches", 598 | "percent-encoding", 599 | ] 600 | 601 | [[package]] 602 | name = "futures" 603 | version = "0.3.21" 604 | source = "registry+https://github.com/rust-lang/crates.io-index" 605 | checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" 606 | dependencies = [ 607 | "futures-channel", 608 | "futures-core", 609 | "futures-executor", 610 | "futures-io", 611 | "futures-sink", 612 | "futures-task", 613 | "futures-util", 614 | ] 615 | 616 | [[package]] 617 | name = "futures-channel" 618 | version = "0.3.21" 619 | source = "registry+https://github.com/rust-lang/crates.io-index" 620 | checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" 621 | dependencies = [ 622 | "futures-core", 623 | "futures-sink", 624 | ] 625 | 626 | [[package]] 627 | name = "futures-core" 628 | version = "0.3.21" 629 | source = "registry+https://github.com/rust-lang/crates.io-index" 630 | checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" 631 | 632 | [[package]] 633 | name = "futures-executor" 634 | version = "0.3.21" 635 | source = "registry+https://github.com/rust-lang/crates.io-index" 636 | checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" 637 | dependencies = [ 638 | "futures-core", 639 | "futures-task", 640 | "futures-util", 641 | ] 642 | 643 | [[package]] 644 | name = "futures-io" 645 | version = "0.3.21" 646 | source = "registry+https://github.com/rust-lang/crates.io-index" 647 | checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" 648 | 649 | [[package]] 650 | name = "futures-macro" 651 | version = "0.3.21" 652 | source = "registry+https://github.com/rust-lang/crates.io-index" 653 | checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" 654 | dependencies = [ 655 | "proc-macro2", 656 | "quote", 657 | "syn", 658 | ] 659 | 660 | [[package]] 661 | name = "futures-sink" 662 | version = "0.3.21" 663 | source = "registry+https://github.com/rust-lang/crates.io-index" 664 | checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" 665 | 666 | [[package]] 667 | name = "futures-task" 668 | version = "0.3.21" 669 | source = "registry+https://github.com/rust-lang/crates.io-index" 670 | checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" 671 | 672 | [[package]] 673 | name = "futures-util" 674 | version = "0.3.21" 675 | source = "registry+https://github.com/rust-lang/crates.io-index" 676 | checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" 677 | dependencies = [ 678 | "futures-channel", 679 | "futures-core", 680 | "futures-io", 681 | "futures-macro", 682 | "futures-sink", 683 | "futures-task", 684 | "memchr", 685 | "pin-project-lite", 686 | "pin-utils", 687 | "slab", 688 | ] 689 | 690 | [[package]] 691 | name = "garcon" 692 | version = "0.2.3" 693 | source = "registry+https://github.com/rust-lang/crates.io-index" 694 | checksum = "e83fb8961dcd3c26123863998521ae4d07e5e5aa8fb50b503380448f2e0ea069" 695 | dependencies = [ 696 | "futures-util", 697 | ] 698 | 699 | [[package]] 700 | name = "generic-array" 701 | version = "0.14.5" 702 | source = "registry+https://github.com/rust-lang/crates.io-index" 703 | checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" 704 | dependencies = [ 705 | "typenum", 706 | "version_check", 707 | ] 708 | 709 | [[package]] 710 | name = "getrandom" 711 | version = "0.2.7" 712 | source = "registry+https://github.com/rust-lang/crates.io-index" 713 | checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" 714 | dependencies = [ 715 | "cfg-if", 716 | "libc", 717 | "wasi", 718 | ] 719 | 720 | [[package]] 721 | name = "group" 722 | version = "0.12.0" 723 | source = "registry+https://github.com/rust-lang/crates.io-index" 724 | checksum = "7391856def869c1c81063a03457c676fbcd419709c3dfb33d8d319de484b154d" 725 | dependencies = [ 726 | "byteorder", 727 | "ff", 728 | "rand_core", 729 | "subtle", 730 | ] 731 | 732 | [[package]] 733 | name = "h2" 734 | version = "0.3.13" 735 | source = "registry+https://github.com/rust-lang/crates.io-index" 736 | checksum = "37a82c6d637fc9515a4694bbf1cb2457b79d81ce52b3108bdeea58b07dd34a57" 737 | dependencies = [ 738 | "bytes", 739 | "fnv", 740 | "futures-core", 741 | "futures-sink", 742 | "futures-util", 743 | "http", 744 | "indexmap", 745 | "slab", 746 | "tokio", 747 | "tokio-util", 748 | "tracing", 749 | ] 750 | 751 | [[package]] 752 | name = "half" 753 | version = "1.8.2" 754 | source = "registry+https://github.com/rust-lang/crates.io-index" 755 | checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" 756 | 757 | [[package]] 758 | name = "hashbrown" 759 | version = "0.11.2" 760 | source = "registry+https://github.com/rust-lang/crates.io-index" 761 | checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" 762 | 763 | [[package]] 764 | name = "heck" 765 | version = "0.4.0" 766 | source = "registry+https://github.com/rust-lang/crates.io-index" 767 | checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" 768 | 769 | [[package]] 770 | name = "hermit-abi" 771 | version = "0.1.19" 772 | source = "registry+https://github.com/rust-lang/crates.io-index" 773 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 774 | dependencies = [ 775 | "libc", 776 | ] 777 | 778 | [[package]] 779 | name = "hex" 780 | version = "0.4.3" 781 | source = "registry+https://github.com/rust-lang/crates.io-index" 782 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 783 | 784 | [[package]] 785 | name = "hmac" 786 | version = "0.12.1" 787 | source = "registry+https://github.com/rust-lang/crates.io-index" 788 | checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" 789 | dependencies = [ 790 | "digest 0.10.3", 791 | ] 792 | 793 | [[package]] 794 | name = "http" 795 | version = "0.2.8" 796 | source = "registry+https://github.com/rust-lang/crates.io-index" 797 | checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" 798 | dependencies = [ 799 | "bytes", 800 | "fnv", 801 | "itoa", 802 | ] 803 | 804 | [[package]] 805 | name = "http-body" 806 | version = "0.4.5" 807 | source = "registry+https://github.com/rust-lang/crates.io-index" 808 | checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" 809 | dependencies = [ 810 | "bytes", 811 | "http", 812 | "pin-project-lite", 813 | ] 814 | 815 | [[package]] 816 | name = "http-range-header" 817 | version = "0.3.0" 818 | source = "registry+https://github.com/rust-lang/crates.io-index" 819 | checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" 820 | 821 | [[package]] 822 | name = "httparse" 823 | version = "1.6.0" 824 | source = "registry+https://github.com/rust-lang/crates.io-index" 825 | checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" 826 | 827 | [[package]] 828 | name = "httpdate" 829 | version = "1.0.2" 830 | source = "registry+https://github.com/rust-lang/crates.io-index" 831 | checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" 832 | 833 | [[package]] 834 | name = "hyper" 835 | version = "0.14.18" 836 | source = "registry+https://github.com/rust-lang/crates.io-index" 837 | checksum = "b26ae0a80afebe130861d90abf98e3814a4f28a4c6ffeb5ab8ebb2be311e0ef2" 838 | dependencies = [ 839 | "bytes", 840 | "futures-channel", 841 | "futures-core", 842 | "futures-util", 843 | "h2", 844 | "http", 845 | "http-body", 846 | "httparse", 847 | "httpdate", 848 | "itoa", 849 | "pin-project-lite", 850 | "socket2", 851 | "tokio", 852 | "tower-service", 853 | "tracing", 854 | "want", 855 | ] 856 | 857 | [[package]] 858 | name = "hyper-rustls" 859 | version = "0.23.0" 860 | source = "registry+https://github.com/rust-lang/crates.io-index" 861 | checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac" 862 | dependencies = [ 863 | "http", 864 | "hyper", 865 | "log", 866 | "rustls", 867 | "rustls-native-certs", 868 | "tokio", 869 | "tokio-rustls", 870 | "webpki-roots", 871 | ] 872 | 873 | [[package]] 874 | name = "ic-agent" 875 | version = "0.20.1" 876 | source = "registry+https://github.com/rust-lang/crates.io-index" 877 | checksum = "39ad753f11bed278d7d40b551bdb57090eedb301267019db576a168a53d12dd6" 878 | dependencies = [ 879 | "async-trait", 880 | "base32", 881 | "base64", 882 | "byteorder", 883 | "futures-util", 884 | "garcon", 885 | "hex", 886 | "http", 887 | "http-body", 888 | "hyper", 889 | "hyper-rustls", 890 | "ic-types", 891 | "ic-verify-bls-signature", 892 | "k256", 893 | "leb128", 894 | "mime", 895 | "pkcs8", 896 | "rand", 897 | "ring", 898 | "rustls", 899 | "sec1", 900 | "serde", 901 | "serde_bytes", 902 | "serde_cbor", 903 | "sha2 0.10.2", 904 | "simple_asn1", 905 | "thiserror", 906 | "url", 907 | ] 908 | 909 | [[package]] 910 | name = "ic-types" 911 | version = "0.5.0" 912 | source = "registry+https://github.com/rust-lang/crates.io-index" 913 | checksum = "79a17269dff0ec6ca4c3d04e18fca97d018ff53d809e6d92348fc22f9588e1a5" 914 | dependencies = [ 915 | "crc32fast", 916 | "data-encoding", 917 | "hex", 918 | "serde", 919 | "serde_bytes", 920 | "sha2 0.10.2", 921 | "thiserror", 922 | ] 923 | 924 | [[package]] 925 | name = "ic-utils" 926 | version = "0.20.1" 927 | source = "registry+https://github.com/rust-lang/crates.io-index" 928 | checksum = "a4700bacf90be57c3bcd94ecacdc01cedf38e5dad51da42994b8b6989441eff8" 929 | dependencies = [ 930 | "async-trait", 931 | "candid", 932 | "garcon", 933 | "ic-agent", 934 | "leb128", 935 | "num-bigint", 936 | "once_cell", 937 | "paste", 938 | "semver", 939 | "serde", 940 | "serde_bytes", 941 | "strum", 942 | "strum_macros", 943 | "thiserror", 944 | ] 945 | 946 | [[package]] 947 | name = "ic-verify-bls-signature" 948 | version = "0.1.0" 949 | source = "registry+https://github.com/rust-lang/crates.io-index" 950 | checksum = "583b1c03380cf86059160cc6c91dcbf56c7b5f141bf3a4f06bc79762d775fac4" 951 | dependencies = [ 952 | "bls12_381", 953 | "lazy_static", 954 | "pairing", 955 | "sha2 0.9.9", 956 | ] 957 | 958 | [[package]] 959 | name = "icx-proxy" 960 | version = "0.10.1" 961 | dependencies = [ 962 | "anyhow", 963 | "axum", 964 | "base64", 965 | "candid", 966 | "clap", 967 | "flate2", 968 | "form_urlencoded", 969 | "futures", 970 | "garcon", 971 | "hex", 972 | "http-body", 973 | "hyper", 974 | "hyper-rustls", 975 | "ic-agent", 976 | "ic-utils", 977 | "itertools", 978 | "lazy-regex", 979 | "opentelemetry", 980 | "opentelemetry-prometheus", 981 | "prometheus", 982 | "rustls", 983 | "rustls-pemfile", 984 | "serde", 985 | "serde_cbor", 986 | "serde_json", 987 | "sha2 0.10.2", 988 | "tokio", 989 | "tower", 990 | "tower-http", 991 | "tracing", 992 | "tracing-subscriber", 993 | "webpki-roots", 994 | ] 995 | 996 | [[package]] 997 | name = "idna" 998 | version = "0.2.3" 999 | source = "registry+https://github.com/rust-lang/crates.io-index" 1000 | checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" 1001 | dependencies = [ 1002 | "matches", 1003 | "unicode-bidi", 1004 | "unicode-normalization", 1005 | ] 1006 | 1007 | [[package]] 1008 | name = "indexmap" 1009 | version = "1.8.0" 1010 | source = "registry+https://github.com/rust-lang/crates.io-index" 1011 | checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" 1012 | dependencies = [ 1013 | "autocfg", 1014 | "hashbrown", 1015 | ] 1016 | 1017 | [[package]] 1018 | name = "itertools" 1019 | version = "0.10.3" 1020 | source = "registry+https://github.com/rust-lang/crates.io-index" 1021 | checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" 1022 | dependencies = [ 1023 | "either", 1024 | ] 1025 | 1026 | [[package]] 1027 | name = "itoa" 1028 | version = "1.0.1" 1029 | source = "registry+https://github.com/rust-lang/crates.io-index" 1030 | checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" 1031 | 1032 | [[package]] 1033 | name = "js-sys" 1034 | version = "0.3.56" 1035 | source = "registry+https://github.com/rust-lang/crates.io-index" 1036 | checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" 1037 | dependencies = [ 1038 | "wasm-bindgen", 1039 | ] 1040 | 1041 | [[package]] 1042 | name = "k256" 1043 | version = "0.11.2" 1044 | source = "registry+https://github.com/rust-lang/crates.io-index" 1045 | checksum = "b953594f084668b4138b8b2fa63ed9776b476c58aa507d575c5206e8bfe5dc4a" 1046 | dependencies = [ 1047 | "cfg-if", 1048 | "ecdsa", 1049 | "elliptic-curve", 1050 | "sha2 0.10.2", 1051 | ] 1052 | 1053 | [[package]] 1054 | name = "lalrpop" 1055 | version = "0.19.7" 1056 | source = "registry+https://github.com/rust-lang/crates.io-index" 1057 | checksum = "852b75a095da6b69da8c5557731c3afd06525d4f655a4fc1c799e2ec8bc4dce4" 1058 | dependencies = [ 1059 | "ascii-canvas", 1060 | "atty", 1061 | "bit-set", 1062 | "diff", 1063 | "ena", 1064 | "itertools", 1065 | "lalrpop-util", 1066 | "petgraph", 1067 | "pico-args", 1068 | "regex", 1069 | "regex-syntax", 1070 | "string_cache", 1071 | "term", 1072 | "tiny-keccak", 1073 | "unicode-xid", 1074 | ] 1075 | 1076 | [[package]] 1077 | name = "lalrpop-util" 1078 | version = "0.19.7" 1079 | source = "registry+https://github.com/rust-lang/crates.io-index" 1080 | checksum = "d6d265705249fe209280676d8f68887859fa42e1d34f342fc05bd47726a5e188" 1081 | dependencies = [ 1082 | "regex", 1083 | ] 1084 | 1085 | [[package]] 1086 | name = "lazy-regex" 1087 | version = "2.2.2" 1088 | source = "registry+https://github.com/rust-lang/crates.io-index" 1089 | checksum = "919a16773ebf2de27e95fc58460110932e55bb0780e23aa51fa5a6b59c9e2b3d" 1090 | dependencies = [ 1091 | "lazy-regex-proc_macros", 1092 | "once_cell", 1093 | "regex", 1094 | ] 1095 | 1096 | [[package]] 1097 | name = "lazy-regex-proc_macros" 1098 | version = "2.3.0" 1099 | source = "registry+https://github.com/rust-lang/crates.io-index" 1100 | checksum = "f2496e5264069bc726ccf37eb76b9cd89406ae110d836c3f76729f99c8a23293" 1101 | dependencies = [ 1102 | "proc-macro2", 1103 | "quote", 1104 | "regex", 1105 | "syn", 1106 | ] 1107 | 1108 | [[package]] 1109 | name = "lazy_static" 1110 | version = "1.4.0" 1111 | source = "registry+https://github.com/rust-lang/crates.io-index" 1112 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 1113 | 1114 | [[package]] 1115 | name = "leb128" 1116 | version = "0.2.5" 1117 | source = "registry+https://github.com/rust-lang/crates.io-index" 1118 | checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" 1119 | 1120 | [[package]] 1121 | name = "libc" 1122 | version = "0.2.120" 1123 | source = "registry+https://github.com/rust-lang/crates.io-index" 1124 | checksum = "ad5c14e80759d0939d013e6ca49930e59fc53dd8e5009132f76240c179380c09" 1125 | 1126 | [[package]] 1127 | name = "lock_api" 1128 | version = "0.4.6" 1129 | source = "registry+https://github.com/rust-lang/crates.io-index" 1130 | checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" 1131 | dependencies = [ 1132 | "scopeguard", 1133 | ] 1134 | 1135 | [[package]] 1136 | name = "log" 1137 | version = "0.4.14" 1138 | source = "registry+https://github.com/rust-lang/crates.io-index" 1139 | checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" 1140 | dependencies = [ 1141 | "cfg-if", 1142 | ] 1143 | 1144 | [[package]] 1145 | name = "logos" 1146 | version = "0.12.0" 1147 | source = "registry+https://github.com/rust-lang/crates.io-index" 1148 | checksum = "427e2abca5be13136da9afdbf874e6b34ad9001dd70f2b103b083a85daa7b345" 1149 | dependencies = [ 1150 | "logos-derive", 1151 | ] 1152 | 1153 | [[package]] 1154 | name = "logos-derive" 1155 | version = "0.12.0" 1156 | source = "registry+https://github.com/rust-lang/crates.io-index" 1157 | checksum = "56a7d287fd2ac3f75b11f19a1c8a874a7d55744bd91f7a1b3e7cf87d4343c36d" 1158 | dependencies = [ 1159 | "beef", 1160 | "fnv", 1161 | "proc-macro2", 1162 | "quote", 1163 | "regex-syntax", 1164 | "syn", 1165 | "utf8-ranges", 1166 | ] 1167 | 1168 | [[package]] 1169 | name = "matches" 1170 | version = "0.1.9" 1171 | source = "registry+https://github.com/rust-lang/crates.io-index" 1172 | checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" 1173 | 1174 | [[package]] 1175 | name = "matchit" 1176 | version = "0.5.0" 1177 | source = "registry+https://github.com/rust-lang/crates.io-index" 1178 | checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb" 1179 | 1180 | [[package]] 1181 | name = "memchr" 1182 | version = "2.4.1" 1183 | source = "registry+https://github.com/rust-lang/crates.io-index" 1184 | checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" 1185 | 1186 | [[package]] 1187 | name = "mime" 1188 | version = "0.3.16" 1189 | source = "registry+https://github.com/rust-lang/crates.io-index" 1190 | checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" 1191 | 1192 | [[package]] 1193 | name = "miniz_oxide" 1194 | version = "0.4.4" 1195 | source = "registry+https://github.com/rust-lang/crates.io-index" 1196 | checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" 1197 | dependencies = [ 1198 | "adler", 1199 | "autocfg", 1200 | ] 1201 | 1202 | [[package]] 1203 | name = "mio" 1204 | version = "0.8.1" 1205 | source = "registry+https://github.com/rust-lang/crates.io-index" 1206 | checksum = "7ba42135c6a5917b9db9cd7b293e5409e1c6b041e6f9825e92e55a894c63b6f8" 1207 | dependencies = [ 1208 | "libc", 1209 | "log", 1210 | "miow", 1211 | "ntapi", 1212 | "wasi", 1213 | "winapi", 1214 | ] 1215 | 1216 | [[package]] 1217 | name = "miow" 1218 | version = "0.3.7" 1219 | source = "registry+https://github.com/rust-lang/crates.io-index" 1220 | checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" 1221 | dependencies = [ 1222 | "winapi", 1223 | ] 1224 | 1225 | [[package]] 1226 | name = "new_debug_unreachable" 1227 | version = "1.0.4" 1228 | source = "registry+https://github.com/rust-lang/crates.io-index" 1229 | checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" 1230 | 1231 | [[package]] 1232 | name = "ntapi" 1233 | version = "0.3.7" 1234 | source = "registry+https://github.com/rust-lang/crates.io-index" 1235 | checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" 1236 | dependencies = [ 1237 | "winapi", 1238 | ] 1239 | 1240 | [[package]] 1241 | name = "num-bigint" 1242 | version = "0.4.3" 1243 | source = "registry+https://github.com/rust-lang/crates.io-index" 1244 | checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" 1245 | dependencies = [ 1246 | "autocfg", 1247 | "num-integer", 1248 | "num-traits", 1249 | "serde", 1250 | ] 1251 | 1252 | [[package]] 1253 | name = "num-integer" 1254 | version = "0.1.44" 1255 | source = "registry+https://github.com/rust-lang/crates.io-index" 1256 | checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" 1257 | dependencies = [ 1258 | "autocfg", 1259 | "num-traits", 1260 | ] 1261 | 1262 | [[package]] 1263 | name = "num-traits" 1264 | version = "0.2.14" 1265 | source = "registry+https://github.com/rust-lang/crates.io-index" 1266 | checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" 1267 | dependencies = [ 1268 | "autocfg", 1269 | ] 1270 | 1271 | [[package]] 1272 | name = "num_cpus" 1273 | version = "1.13.1" 1274 | source = "registry+https://github.com/rust-lang/crates.io-index" 1275 | checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" 1276 | dependencies = [ 1277 | "hermit-abi", 1278 | "libc", 1279 | ] 1280 | 1281 | [[package]] 1282 | name = "num_enum" 1283 | version = "0.5.7" 1284 | source = "registry+https://github.com/rust-lang/crates.io-index" 1285 | checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9" 1286 | dependencies = [ 1287 | "num_enum_derive", 1288 | ] 1289 | 1290 | [[package]] 1291 | name = "num_enum_derive" 1292 | version = "0.5.7" 1293 | source = "registry+https://github.com/rust-lang/crates.io-index" 1294 | checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce" 1295 | dependencies = [ 1296 | "proc-macro-crate", 1297 | "proc-macro2", 1298 | "quote", 1299 | "syn", 1300 | ] 1301 | 1302 | [[package]] 1303 | name = "num_threads" 1304 | version = "0.1.4" 1305 | source = "registry+https://github.com/rust-lang/crates.io-index" 1306 | checksum = "c539a50b93a303167eded6e8dff5220cd39447409fb659f4cd24b1f72fe4f133" 1307 | dependencies = [ 1308 | "libc", 1309 | ] 1310 | 1311 | [[package]] 1312 | name = "once_cell" 1313 | version = "1.15.0" 1314 | source = "registry+https://github.com/rust-lang/crates.io-index" 1315 | checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" 1316 | 1317 | [[package]] 1318 | name = "opaque-debug" 1319 | version = "0.3.0" 1320 | source = "registry+https://github.com/rust-lang/crates.io-index" 1321 | checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" 1322 | 1323 | [[package]] 1324 | name = "openssl-probe" 1325 | version = "0.1.5" 1326 | source = "registry+https://github.com/rust-lang/crates.io-index" 1327 | checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" 1328 | 1329 | [[package]] 1330 | name = "opentelemetry" 1331 | version = "0.17.0" 1332 | source = "registry+https://github.com/rust-lang/crates.io-index" 1333 | checksum = "6105e89802af13fdf48c49d7646d3b533a70e536d818aae7e78ba0433d01acb8" 1334 | dependencies = [ 1335 | "async-trait", 1336 | "crossbeam-channel", 1337 | "dashmap", 1338 | "fnv", 1339 | "futures-channel", 1340 | "futures-executor", 1341 | "futures-util", 1342 | "js-sys", 1343 | "lazy_static", 1344 | "percent-encoding", 1345 | "pin-project", 1346 | "rand", 1347 | "thiserror", 1348 | ] 1349 | 1350 | [[package]] 1351 | name = "opentelemetry-prometheus" 1352 | version = "0.10.0" 1353 | source = "registry+https://github.com/rust-lang/crates.io-index" 1354 | checksum = "9328977e479cebe12ce0d3fcecdaea4721d234895a9440c5b5dfd113f0594ac6" 1355 | dependencies = [ 1356 | "opentelemetry", 1357 | "prometheus", 1358 | "protobuf", 1359 | ] 1360 | 1361 | [[package]] 1362 | name = "os_str_bytes" 1363 | version = "6.0.0" 1364 | source = "registry+https://github.com/rust-lang/crates.io-index" 1365 | checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" 1366 | 1367 | [[package]] 1368 | name = "pairing" 1369 | version = "0.22.0" 1370 | source = "registry+https://github.com/rust-lang/crates.io-index" 1371 | checksum = "135590d8bdba2b31346f9cd1fb2a912329f5135e832a4f422942eb6ead8b6b3b" 1372 | dependencies = [ 1373 | "group", 1374 | ] 1375 | 1376 | [[package]] 1377 | name = "parking_lot" 1378 | version = "0.12.0" 1379 | source = "registry+https://github.com/rust-lang/crates.io-index" 1380 | checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" 1381 | dependencies = [ 1382 | "lock_api", 1383 | "parking_lot_core", 1384 | ] 1385 | 1386 | [[package]] 1387 | name = "parking_lot_core" 1388 | version = "0.9.1" 1389 | source = "registry+https://github.com/rust-lang/crates.io-index" 1390 | checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" 1391 | dependencies = [ 1392 | "cfg-if", 1393 | "libc", 1394 | "redox_syscall", 1395 | "smallvec", 1396 | "windows-sys", 1397 | ] 1398 | 1399 | [[package]] 1400 | name = "paste" 1401 | version = "1.0.6" 1402 | source = "registry+https://github.com/rust-lang/crates.io-index" 1403 | checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5" 1404 | 1405 | [[package]] 1406 | name = "pem-rfc7468" 1407 | version = "0.6.0" 1408 | source = "registry+https://github.com/rust-lang/crates.io-index" 1409 | checksum = "24d159833a9105500e0398934e205e0773f0b27529557134ecfc51c27646adac" 1410 | dependencies = [ 1411 | "base64ct", 1412 | ] 1413 | 1414 | [[package]] 1415 | name = "percent-encoding" 1416 | version = "2.1.0" 1417 | source = "registry+https://github.com/rust-lang/crates.io-index" 1418 | checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" 1419 | 1420 | [[package]] 1421 | name = "petgraph" 1422 | version = "0.5.1" 1423 | source = "registry+https://github.com/rust-lang/crates.io-index" 1424 | checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" 1425 | dependencies = [ 1426 | "fixedbitset", 1427 | "indexmap", 1428 | ] 1429 | 1430 | [[package]] 1431 | name = "phf_shared" 1432 | version = "0.10.0" 1433 | source = "registry+https://github.com/rust-lang/crates.io-index" 1434 | checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" 1435 | dependencies = [ 1436 | "siphasher", 1437 | ] 1438 | 1439 | [[package]] 1440 | name = "pico-args" 1441 | version = "0.4.2" 1442 | source = "registry+https://github.com/rust-lang/crates.io-index" 1443 | checksum = "db8bcd96cb740d03149cbad5518db9fd87126a10ab519c011893b1754134c468" 1444 | 1445 | [[package]] 1446 | name = "pin-project" 1447 | version = "1.0.10" 1448 | source = "registry+https://github.com/rust-lang/crates.io-index" 1449 | checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" 1450 | dependencies = [ 1451 | "pin-project-internal", 1452 | ] 1453 | 1454 | [[package]] 1455 | name = "pin-project-internal" 1456 | version = "1.0.10" 1457 | source = "registry+https://github.com/rust-lang/crates.io-index" 1458 | checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" 1459 | dependencies = [ 1460 | "proc-macro2", 1461 | "quote", 1462 | "syn", 1463 | ] 1464 | 1465 | [[package]] 1466 | name = "pin-project-lite" 1467 | version = "0.2.8" 1468 | source = "registry+https://github.com/rust-lang/crates.io-index" 1469 | checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" 1470 | 1471 | [[package]] 1472 | name = "pin-utils" 1473 | version = "0.1.0" 1474 | source = "registry+https://github.com/rust-lang/crates.io-index" 1475 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 1476 | 1477 | [[package]] 1478 | name = "pkcs8" 1479 | version = "0.9.0" 1480 | source = "registry+https://github.com/rust-lang/crates.io-index" 1481 | checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" 1482 | dependencies = [ 1483 | "der", 1484 | "spki", 1485 | ] 1486 | 1487 | [[package]] 1488 | name = "ppv-lite86" 1489 | version = "0.2.16" 1490 | source = "registry+https://github.com/rust-lang/crates.io-index" 1491 | checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" 1492 | 1493 | [[package]] 1494 | name = "precomputed-hash" 1495 | version = "0.1.1" 1496 | source = "registry+https://github.com/rust-lang/crates.io-index" 1497 | checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" 1498 | 1499 | [[package]] 1500 | name = "pretty" 1501 | version = "0.10.0" 1502 | source = "registry+https://github.com/rust-lang/crates.io-index" 1503 | checksum = "ad9940b913ee56ddd94aec2d3cd179dd47068236f42a1a6415ccf9d880ce2a61" 1504 | dependencies = [ 1505 | "arrayvec", 1506 | "typed-arena", 1507 | ] 1508 | 1509 | [[package]] 1510 | name = "proc-macro-crate" 1511 | version = "1.1.3" 1512 | source = "registry+https://github.com/rust-lang/crates.io-index" 1513 | checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" 1514 | dependencies = [ 1515 | "thiserror", 1516 | "toml", 1517 | ] 1518 | 1519 | [[package]] 1520 | name = "proc-macro-error" 1521 | version = "1.0.4" 1522 | source = "registry+https://github.com/rust-lang/crates.io-index" 1523 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 1524 | dependencies = [ 1525 | "proc-macro-error-attr", 1526 | "proc-macro2", 1527 | "quote", 1528 | "syn", 1529 | "version_check", 1530 | ] 1531 | 1532 | [[package]] 1533 | name = "proc-macro-error-attr" 1534 | version = "1.0.4" 1535 | source = "registry+https://github.com/rust-lang/crates.io-index" 1536 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 1537 | dependencies = [ 1538 | "proc-macro2", 1539 | "quote", 1540 | "version_check", 1541 | ] 1542 | 1543 | [[package]] 1544 | name = "proc-macro2" 1545 | version = "1.0.46" 1546 | source = "registry+https://github.com/rust-lang/crates.io-index" 1547 | checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" 1548 | dependencies = [ 1549 | "unicode-ident", 1550 | ] 1551 | 1552 | [[package]] 1553 | name = "prometheus" 1554 | version = "0.13.1" 1555 | source = "registry+https://github.com/rust-lang/crates.io-index" 1556 | checksum = "cface98dfa6d645ea4c789839f176e4b072265d085bfcc48eaa8d137f58d3c39" 1557 | dependencies = [ 1558 | "cfg-if", 1559 | "fnv", 1560 | "lazy_static", 1561 | "memchr", 1562 | "parking_lot", 1563 | "protobuf", 1564 | "thiserror", 1565 | ] 1566 | 1567 | [[package]] 1568 | name = "protobuf" 1569 | version = "2.27.1" 1570 | source = "registry+https://github.com/rust-lang/crates.io-index" 1571 | checksum = "cf7e6d18738ecd0902d30d1ad232c9125985a3422929b16c65517b38adc14f96" 1572 | 1573 | [[package]] 1574 | name = "quickcheck" 1575 | version = "1.0.3" 1576 | source = "registry+https://github.com/rust-lang/crates.io-index" 1577 | checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" 1578 | dependencies = [ 1579 | "rand", 1580 | ] 1581 | 1582 | [[package]] 1583 | name = "quote" 1584 | version = "1.0.15" 1585 | source = "registry+https://github.com/rust-lang/crates.io-index" 1586 | checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" 1587 | dependencies = [ 1588 | "proc-macro2", 1589 | ] 1590 | 1591 | [[package]] 1592 | name = "rand" 1593 | version = "0.8.5" 1594 | source = "registry+https://github.com/rust-lang/crates.io-index" 1595 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 1596 | dependencies = [ 1597 | "libc", 1598 | "rand_chacha", 1599 | "rand_core", 1600 | ] 1601 | 1602 | [[package]] 1603 | name = "rand_chacha" 1604 | version = "0.3.1" 1605 | source = "registry+https://github.com/rust-lang/crates.io-index" 1606 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 1607 | dependencies = [ 1608 | "ppv-lite86", 1609 | "rand_core", 1610 | ] 1611 | 1612 | [[package]] 1613 | name = "rand_core" 1614 | version = "0.6.3" 1615 | source = "registry+https://github.com/rust-lang/crates.io-index" 1616 | checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" 1617 | dependencies = [ 1618 | "getrandom", 1619 | ] 1620 | 1621 | [[package]] 1622 | name = "redox_syscall" 1623 | version = "0.2.11" 1624 | source = "registry+https://github.com/rust-lang/crates.io-index" 1625 | checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" 1626 | dependencies = [ 1627 | "bitflags", 1628 | ] 1629 | 1630 | [[package]] 1631 | name = "redox_users" 1632 | version = "0.4.0" 1633 | source = "registry+https://github.com/rust-lang/crates.io-index" 1634 | checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" 1635 | dependencies = [ 1636 | "getrandom", 1637 | "redox_syscall", 1638 | ] 1639 | 1640 | [[package]] 1641 | name = "regex" 1642 | version = "1.5.5" 1643 | source = "registry+https://github.com/rust-lang/crates.io-index" 1644 | checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" 1645 | dependencies = [ 1646 | "aho-corasick", 1647 | "memchr", 1648 | "regex-syntax", 1649 | ] 1650 | 1651 | [[package]] 1652 | name = "regex-syntax" 1653 | version = "0.6.25" 1654 | source = "registry+https://github.com/rust-lang/crates.io-index" 1655 | checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" 1656 | 1657 | [[package]] 1658 | name = "rfc6979" 1659 | version = "0.2.0" 1660 | source = "registry+https://github.com/rust-lang/crates.io-index" 1661 | checksum = "6c0788437d5ee113c49af91d3594ebc4fcdcc962f8b6df5aa1c3eeafd8ad95de" 1662 | dependencies = [ 1663 | "crypto-bigint", 1664 | "hmac", 1665 | "zeroize", 1666 | ] 1667 | 1668 | [[package]] 1669 | name = "ring" 1670 | version = "0.16.20" 1671 | source = "registry+https://github.com/rust-lang/crates.io-index" 1672 | checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" 1673 | dependencies = [ 1674 | "cc", 1675 | "libc", 1676 | "once_cell", 1677 | "spin", 1678 | "untrusted", 1679 | "web-sys", 1680 | "winapi", 1681 | ] 1682 | 1683 | [[package]] 1684 | name = "rustls" 1685 | version = "0.20.4" 1686 | source = "registry+https://github.com/rust-lang/crates.io-index" 1687 | checksum = "4fbfeb8d0ddb84706bc597a5574ab8912817c52a397f819e5b614e2265206921" 1688 | dependencies = [ 1689 | "log", 1690 | "ring", 1691 | "sct", 1692 | "webpki", 1693 | ] 1694 | 1695 | [[package]] 1696 | name = "rustls-native-certs" 1697 | version = "0.6.2" 1698 | source = "registry+https://github.com/rust-lang/crates.io-index" 1699 | checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" 1700 | dependencies = [ 1701 | "openssl-probe", 1702 | "rustls-pemfile", 1703 | "schannel", 1704 | "security-framework", 1705 | ] 1706 | 1707 | [[package]] 1708 | name = "rustls-pemfile" 1709 | version = "1.0.0" 1710 | source = "registry+https://github.com/rust-lang/crates.io-index" 1711 | checksum = "e7522c9de787ff061458fe9a829dc790a3f5b22dc571694fc5883f448b94d9a9" 1712 | dependencies = [ 1713 | "base64", 1714 | ] 1715 | 1716 | [[package]] 1717 | name = "rustversion" 1718 | version = "1.0.6" 1719 | source = "registry+https://github.com/rust-lang/crates.io-index" 1720 | checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" 1721 | 1722 | [[package]] 1723 | name = "ryu" 1724 | version = "1.0.9" 1725 | source = "registry+https://github.com/rust-lang/crates.io-index" 1726 | checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" 1727 | 1728 | [[package]] 1729 | name = "schannel" 1730 | version = "0.1.19" 1731 | source = "registry+https://github.com/rust-lang/crates.io-index" 1732 | checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" 1733 | dependencies = [ 1734 | "lazy_static", 1735 | "winapi", 1736 | ] 1737 | 1738 | [[package]] 1739 | name = "scopeguard" 1740 | version = "1.1.0" 1741 | source = "registry+https://github.com/rust-lang/crates.io-index" 1742 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 1743 | 1744 | [[package]] 1745 | name = "sct" 1746 | version = "0.7.0" 1747 | source = "registry+https://github.com/rust-lang/crates.io-index" 1748 | checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" 1749 | dependencies = [ 1750 | "ring", 1751 | "untrusted", 1752 | ] 1753 | 1754 | [[package]] 1755 | name = "sec1" 1756 | version = "0.3.0" 1757 | source = "registry+https://github.com/rust-lang/crates.io-index" 1758 | checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" 1759 | dependencies = [ 1760 | "base16ct", 1761 | "der", 1762 | "generic-array", 1763 | "pkcs8", 1764 | "subtle", 1765 | "zeroize", 1766 | ] 1767 | 1768 | [[package]] 1769 | name = "security-framework" 1770 | version = "2.6.1" 1771 | source = "registry+https://github.com/rust-lang/crates.io-index" 1772 | checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc" 1773 | dependencies = [ 1774 | "bitflags", 1775 | "core-foundation", 1776 | "core-foundation-sys", 1777 | "libc", 1778 | "security-framework-sys", 1779 | ] 1780 | 1781 | [[package]] 1782 | name = "security-framework-sys" 1783 | version = "2.6.1" 1784 | source = "registry+https://github.com/rust-lang/crates.io-index" 1785 | checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" 1786 | dependencies = [ 1787 | "core-foundation-sys", 1788 | "libc", 1789 | ] 1790 | 1791 | [[package]] 1792 | name = "semver" 1793 | version = "1.0.9" 1794 | source = "registry+https://github.com/rust-lang/crates.io-index" 1795 | checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd" 1796 | 1797 | [[package]] 1798 | name = "serde" 1799 | version = "1.0.136" 1800 | source = "registry+https://github.com/rust-lang/crates.io-index" 1801 | checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" 1802 | dependencies = [ 1803 | "serde_derive", 1804 | ] 1805 | 1806 | [[package]] 1807 | name = "serde_bytes" 1808 | version = "0.11.5" 1809 | source = "registry+https://github.com/rust-lang/crates.io-index" 1810 | checksum = "16ae07dd2f88a366f15bd0632ba725227018c69a1c8550a927324f8eb8368bb9" 1811 | dependencies = [ 1812 | "serde", 1813 | ] 1814 | 1815 | [[package]] 1816 | name = "serde_cbor" 1817 | version = "0.11.2" 1818 | source = "registry+https://github.com/rust-lang/crates.io-index" 1819 | checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" 1820 | dependencies = [ 1821 | "half", 1822 | "serde", 1823 | ] 1824 | 1825 | [[package]] 1826 | name = "serde_derive" 1827 | version = "1.0.136" 1828 | source = "registry+https://github.com/rust-lang/crates.io-index" 1829 | checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" 1830 | dependencies = [ 1831 | "proc-macro2", 1832 | "quote", 1833 | "syn", 1834 | ] 1835 | 1836 | [[package]] 1837 | name = "serde_json" 1838 | version = "1.0.79" 1839 | source = "registry+https://github.com/rust-lang/crates.io-index" 1840 | checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" 1841 | dependencies = [ 1842 | "itoa", 1843 | "ryu", 1844 | "serde", 1845 | ] 1846 | 1847 | [[package]] 1848 | name = "serde_urlencoded" 1849 | version = "0.7.1" 1850 | source = "registry+https://github.com/rust-lang/crates.io-index" 1851 | checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" 1852 | dependencies = [ 1853 | "form_urlencoded", 1854 | "itoa", 1855 | "ryu", 1856 | "serde", 1857 | ] 1858 | 1859 | [[package]] 1860 | name = "sha2" 1861 | version = "0.9.9" 1862 | source = "registry+https://github.com/rust-lang/crates.io-index" 1863 | checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" 1864 | dependencies = [ 1865 | "block-buffer 0.9.0", 1866 | "cfg-if", 1867 | "cpufeatures", 1868 | "digest 0.9.0", 1869 | "opaque-debug", 1870 | ] 1871 | 1872 | [[package]] 1873 | name = "sha2" 1874 | version = "0.10.2" 1875 | source = "registry+https://github.com/rust-lang/crates.io-index" 1876 | checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" 1877 | dependencies = [ 1878 | "cfg-if", 1879 | "cpufeatures", 1880 | "digest 0.10.3", 1881 | ] 1882 | 1883 | [[package]] 1884 | name = "sharded-slab" 1885 | version = "0.1.4" 1886 | source = "registry+https://github.com/rust-lang/crates.io-index" 1887 | checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" 1888 | dependencies = [ 1889 | "lazy_static", 1890 | ] 1891 | 1892 | [[package]] 1893 | name = "signal-hook-registry" 1894 | version = "1.4.0" 1895 | source = "registry+https://github.com/rust-lang/crates.io-index" 1896 | checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" 1897 | dependencies = [ 1898 | "libc", 1899 | ] 1900 | 1901 | [[package]] 1902 | name = "signature" 1903 | version = "1.5.0" 1904 | source = "registry+https://github.com/rust-lang/crates.io-index" 1905 | checksum = "f054c6c1a6e95179d6f23ed974060dcefb2d9388bb7256900badad682c499de4" 1906 | dependencies = [ 1907 | "digest 0.10.3", 1908 | "rand_core", 1909 | ] 1910 | 1911 | [[package]] 1912 | name = "simple_asn1" 1913 | version = "0.6.1" 1914 | source = "registry+https://github.com/rust-lang/crates.io-index" 1915 | checksum = "4a762b1c38b9b990c694b9c2f8abe3372ce6a9ceaae6bca39cfc46e054f45745" 1916 | dependencies = [ 1917 | "num-bigint", 1918 | "num-traits", 1919 | "thiserror", 1920 | "time", 1921 | ] 1922 | 1923 | [[package]] 1924 | name = "siphasher" 1925 | version = "0.3.10" 1926 | source = "registry+https://github.com/rust-lang/crates.io-index" 1927 | checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" 1928 | 1929 | [[package]] 1930 | name = "slab" 1931 | version = "0.4.5" 1932 | source = "registry+https://github.com/rust-lang/crates.io-index" 1933 | checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" 1934 | 1935 | [[package]] 1936 | name = "smallvec" 1937 | version = "1.8.0" 1938 | source = "registry+https://github.com/rust-lang/crates.io-index" 1939 | checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" 1940 | 1941 | [[package]] 1942 | name = "socket2" 1943 | version = "0.4.4" 1944 | source = "registry+https://github.com/rust-lang/crates.io-index" 1945 | checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" 1946 | dependencies = [ 1947 | "libc", 1948 | "winapi", 1949 | ] 1950 | 1951 | [[package]] 1952 | name = "spin" 1953 | version = "0.5.2" 1954 | source = "registry+https://github.com/rust-lang/crates.io-index" 1955 | checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" 1956 | 1957 | [[package]] 1958 | name = "spki" 1959 | version = "0.6.0" 1960 | source = "registry+https://github.com/rust-lang/crates.io-index" 1961 | checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" 1962 | dependencies = [ 1963 | "base64ct", 1964 | "der", 1965 | ] 1966 | 1967 | [[package]] 1968 | name = "string_cache" 1969 | version = "0.8.4" 1970 | source = "registry+https://github.com/rust-lang/crates.io-index" 1971 | checksum = "213494b7a2b503146286049378ce02b482200519accc31872ee8be91fa820a08" 1972 | dependencies = [ 1973 | "new_debug_unreachable", 1974 | "once_cell", 1975 | "parking_lot", 1976 | "phf_shared", 1977 | "precomputed-hash", 1978 | ] 1979 | 1980 | [[package]] 1981 | name = "strsim" 1982 | version = "0.10.0" 1983 | source = "registry+https://github.com/rust-lang/crates.io-index" 1984 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 1985 | 1986 | [[package]] 1987 | name = "strum" 1988 | version = "0.24.0" 1989 | source = "registry+https://github.com/rust-lang/crates.io-index" 1990 | checksum = "e96acfc1b70604b8b2f1ffa4c57e59176c7dbb05d556c71ecd2f5498a1dee7f8" 1991 | 1992 | [[package]] 1993 | name = "strum_macros" 1994 | version = "0.24.0" 1995 | source = "registry+https://github.com/rust-lang/crates.io-index" 1996 | checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef" 1997 | dependencies = [ 1998 | "heck", 1999 | "proc-macro2", 2000 | "quote", 2001 | "rustversion", 2002 | "syn", 2003 | ] 2004 | 2005 | [[package]] 2006 | name = "subtle" 2007 | version = "2.4.1" 2008 | source = "registry+https://github.com/rust-lang/crates.io-index" 2009 | checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" 2010 | 2011 | [[package]] 2012 | name = "syn" 2013 | version = "1.0.89" 2014 | source = "registry+https://github.com/rust-lang/crates.io-index" 2015 | checksum = "ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54" 2016 | dependencies = [ 2017 | "proc-macro2", 2018 | "quote", 2019 | "unicode-xid", 2020 | ] 2021 | 2022 | [[package]] 2023 | name = "sync_wrapper" 2024 | version = "0.1.1" 2025 | source = "registry+https://github.com/rust-lang/crates.io-index" 2026 | checksum = "20518fe4a4c9acf048008599e464deb21beeae3d3578418951a189c235a7a9a8" 2027 | 2028 | [[package]] 2029 | name = "term" 2030 | version = "0.7.0" 2031 | source = "registry+https://github.com/rust-lang/crates.io-index" 2032 | checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" 2033 | dependencies = [ 2034 | "dirs-next", 2035 | "rustversion", 2036 | "winapi", 2037 | ] 2038 | 2039 | [[package]] 2040 | name = "termcolor" 2041 | version = "1.1.3" 2042 | source = "registry+https://github.com/rust-lang/crates.io-index" 2043 | checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" 2044 | dependencies = [ 2045 | "winapi-util", 2046 | ] 2047 | 2048 | [[package]] 2049 | name = "thiserror" 2050 | version = "1.0.30" 2051 | source = "registry+https://github.com/rust-lang/crates.io-index" 2052 | checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" 2053 | dependencies = [ 2054 | "thiserror-impl", 2055 | ] 2056 | 2057 | [[package]] 2058 | name = "thiserror-impl" 2059 | version = "1.0.30" 2060 | source = "registry+https://github.com/rust-lang/crates.io-index" 2061 | checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" 2062 | dependencies = [ 2063 | "proc-macro2", 2064 | "quote", 2065 | "syn", 2066 | ] 2067 | 2068 | [[package]] 2069 | name = "thread_local" 2070 | version = "1.1.4" 2071 | source = "registry+https://github.com/rust-lang/crates.io-index" 2072 | checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" 2073 | dependencies = [ 2074 | "once_cell", 2075 | ] 2076 | 2077 | [[package]] 2078 | name = "time" 2079 | version = "0.3.7" 2080 | source = "registry+https://github.com/rust-lang/crates.io-index" 2081 | checksum = "004cbc98f30fa233c61a38bc77e96a9106e65c88f2d3bef182ae952027e5753d" 2082 | dependencies = [ 2083 | "itoa", 2084 | "libc", 2085 | "num_threads", 2086 | "quickcheck", 2087 | "time-macros", 2088 | ] 2089 | 2090 | [[package]] 2091 | name = "time-macros" 2092 | version = "0.2.3" 2093 | source = "registry+https://github.com/rust-lang/crates.io-index" 2094 | checksum = "25eb0ca3468fc0acc11828786797f6ef9aa1555e4a211a60d64cc8e4d1be47d6" 2095 | 2096 | [[package]] 2097 | name = "tiny-keccak" 2098 | version = "2.0.2" 2099 | source = "registry+https://github.com/rust-lang/crates.io-index" 2100 | checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" 2101 | dependencies = [ 2102 | "crunchy", 2103 | ] 2104 | 2105 | [[package]] 2106 | name = "tinyvec" 2107 | version = "1.5.1" 2108 | source = "registry+https://github.com/rust-lang/crates.io-index" 2109 | checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" 2110 | dependencies = [ 2111 | "tinyvec_macros", 2112 | ] 2113 | 2114 | [[package]] 2115 | name = "tinyvec_macros" 2116 | version = "0.1.0" 2117 | source = "registry+https://github.com/rust-lang/crates.io-index" 2118 | checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" 2119 | 2120 | [[package]] 2121 | name = "tokio" 2122 | version = "1.20.1" 2123 | source = "registry+https://github.com/rust-lang/crates.io-index" 2124 | checksum = "7a8325f63a7d4774dd041e363b2409ed1c5cbbd0f867795e661df066b2b0a581" 2125 | dependencies = [ 2126 | "autocfg", 2127 | "bytes", 2128 | "libc", 2129 | "memchr", 2130 | "mio", 2131 | "num_cpus", 2132 | "once_cell", 2133 | "parking_lot", 2134 | "pin-project-lite", 2135 | "signal-hook-registry", 2136 | "socket2", 2137 | "tokio-macros", 2138 | "winapi", 2139 | ] 2140 | 2141 | [[package]] 2142 | name = "tokio-macros" 2143 | version = "1.7.0" 2144 | source = "registry+https://github.com/rust-lang/crates.io-index" 2145 | checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" 2146 | dependencies = [ 2147 | "proc-macro2", 2148 | "quote", 2149 | "syn", 2150 | ] 2151 | 2152 | [[package]] 2153 | name = "tokio-rustls" 2154 | version = "0.23.2" 2155 | source = "registry+https://github.com/rust-lang/crates.io-index" 2156 | checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b" 2157 | dependencies = [ 2158 | "rustls", 2159 | "tokio", 2160 | "webpki", 2161 | ] 2162 | 2163 | [[package]] 2164 | name = "tokio-util" 2165 | version = "0.7.3" 2166 | source = "registry+https://github.com/rust-lang/crates.io-index" 2167 | checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" 2168 | dependencies = [ 2169 | "bytes", 2170 | "futures-core", 2171 | "futures-sink", 2172 | "pin-project-lite", 2173 | "tokio", 2174 | "tracing", 2175 | ] 2176 | 2177 | [[package]] 2178 | name = "toml" 2179 | version = "0.5.8" 2180 | source = "registry+https://github.com/rust-lang/crates.io-index" 2181 | checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" 2182 | dependencies = [ 2183 | "serde", 2184 | ] 2185 | 2186 | [[package]] 2187 | name = "tower" 2188 | version = "0.4.12" 2189 | source = "registry+https://github.com/rust-lang/crates.io-index" 2190 | checksum = "9a89fd63ad6adf737582df5db40d286574513c69a11dac5214dc3b5603d6713e" 2191 | dependencies = [ 2192 | "futures-core", 2193 | "futures-util", 2194 | "pin-project", 2195 | "pin-project-lite", 2196 | "tokio", 2197 | "tower-layer", 2198 | "tower-service", 2199 | "tracing", 2200 | ] 2201 | 2202 | [[package]] 2203 | name = "tower-http" 2204 | version = "0.3.4" 2205 | source = "registry+https://github.com/rust-lang/crates.io-index" 2206 | checksum = "3c530c8675c1dbf98facee631536fa116b5fb6382d7dd6dc1b118d970eafe3ba" 2207 | dependencies = [ 2208 | "bitflags", 2209 | "bytes", 2210 | "futures-core", 2211 | "futures-util", 2212 | "http", 2213 | "http-body", 2214 | "http-range-header", 2215 | "pin-project-lite", 2216 | "tower", 2217 | "tower-layer", 2218 | "tower-service", 2219 | "tracing", 2220 | ] 2221 | 2222 | [[package]] 2223 | name = "tower-layer" 2224 | version = "0.3.1" 2225 | source = "registry+https://github.com/rust-lang/crates.io-index" 2226 | checksum = "343bc9466d3fe6b0f960ef45960509f84480bf4fd96f92901afe7ff3df9d3a62" 2227 | 2228 | [[package]] 2229 | name = "tower-service" 2230 | version = "0.3.1" 2231 | source = "registry+https://github.com/rust-lang/crates.io-index" 2232 | checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" 2233 | 2234 | [[package]] 2235 | name = "tracing" 2236 | version = "0.1.32" 2237 | source = "registry+https://github.com/rust-lang/crates.io-index" 2238 | checksum = "4a1bdf54a7c28a2bbf701e1d2233f6c77f473486b94bee4f9678da5a148dca7f" 2239 | dependencies = [ 2240 | "cfg-if", 2241 | "log", 2242 | "pin-project-lite", 2243 | "tracing-attributes", 2244 | "tracing-core", 2245 | ] 2246 | 2247 | [[package]] 2248 | name = "tracing-attributes" 2249 | version = "0.1.22" 2250 | source = "registry+https://github.com/rust-lang/crates.io-index" 2251 | checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" 2252 | dependencies = [ 2253 | "proc-macro2", 2254 | "quote", 2255 | "syn", 2256 | ] 2257 | 2258 | [[package]] 2259 | name = "tracing-core" 2260 | version = "0.1.23" 2261 | source = "registry+https://github.com/rust-lang/crates.io-index" 2262 | checksum = "aa31669fa42c09c34d94d8165dd2012e8ff3c66aca50f3bb226b68f216f2706c" 2263 | dependencies = [ 2264 | "lazy_static", 2265 | "valuable", 2266 | ] 2267 | 2268 | [[package]] 2269 | name = "tracing-log" 2270 | version = "0.1.3" 2271 | source = "registry+https://github.com/rust-lang/crates.io-index" 2272 | checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" 2273 | dependencies = [ 2274 | "lazy_static", 2275 | "log", 2276 | "tracing-core", 2277 | ] 2278 | 2279 | [[package]] 2280 | name = "tracing-serde" 2281 | version = "0.1.3" 2282 | source = "registry+https://github.com/rust-lang/crates.io-index" 2283 | checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" 2284 | dependencies = [ 2285 | "serde", 2286 | "tracing-core", 2287 | ] 2288 | 2289 | [[package]] 2290 | name = "tracing-subscriber" 2291 | version = "0.3.11" 2292 | source = "registry+https://github.com/rust-lang/crates.io-index" 2293 | checksum = "4bc28f93baff38037f64e6f43d34cfa1605f27a49c34e8a04c5e78b0babf2596" 2294 | dependencies = [ 2295 | "ansi_term", 2296 | "serde", 2297 | "serde_json", 2298 | "sharded-slab", 2299 | "smallvec", 2300 | "thread_local", 2301 | "tracing-core", 2302 | "tracing-log", 2303 | "tracing-serde", 2304 | ] 2305 | 2306 | [[package]] 2307 | name = "try-lock" 2308 | version = "0.2.3" 2309 | source = "registry+https://github.com/rust-lang/crates.io-index" 2310 | checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" 2311 | 2312 | [[package]] 2313 | name = "typed-arena" 2314 | version = "2.0.1" 2315 | source = "registry+https://github.com/rust-lang/crates.io-index" 2316 | checksum = "0685c84d5d54d1c26f7d3eb96cd41550adb97baed141a761cf335d3d33bcd0ae" 2317 | 2318 | [[package]] 2319 | name = "typenum" 2320 | version = "1.15.0" 2321 | source = "registry+https://github.com/rust-lang/crates.io-index" 2322 | checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" 2323 | 2324 | [[package]] 2325 | name = "unicode-bidi" 2326 | version = "0.3.7" 2327 | source = "registry+https://github.com/rust-lang/crates.io-index" 2328 | checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" 2329 | 2330 | [[package]] 2331 | name = "unicode-ident" 2332 | version = "1.0.4" 2333 | source = "registry+https://github.com/rust-lang/crates.io-index" 2334 | checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" 2335 | 2336 | [[package]] 2337 | name = "unicode-normalization" 2338 | version = "0.1.19" 2339 | source = "registry+https://github.com/rust-lang/crates.io-index" 2340 | checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" 2341 | dependencies = [ 2342 | "tinyvec", 2343 | ] 2344 | 2345 | [[package]] 2346 | name = "unicode-width" 2347 | version = "0.1.9" 2348 | source = "registry+https://github.com/rust-lang/crates.io-index" 2349 | checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" 2350 | 2351 | [[package]] 2352 | name = "unicode-xid" 2353 | version = "0.2.2" 2354 | source = "registry+https://github.com/rust-lang/crates.io-index" 2355 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 2356 | 2357 | [[package]] 2358 | name = "untrusted" 2359 | version = "0.7.1" 2360 | source = "registry+https://github.com/rust-lang/crates.io-index" 2361 | checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" 2362 | 2363 | [[package]] 2364 | name = "url" 2365 | version = "2.2.2" 2366 | source = "registry+https://github.com/rust-lang/crates.io-index" 2367 | checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" 2368 | dependencies = [ 2369 | "form_urlencoded", 2370 | "idna", 2371 | "matches", 2372 | "percent-encoding", 2373 | ] 2374 | 2375 | [[package]] 2376 | name = "utf8-ranges" 2377 | version = "1.0.4" 2378 | source = "registry+https://github.com/rust-lang/crates.io-index" 2379 | checksum = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba" 2380 | 2381 | [[package]] 2382 | name = "valuable" 2383 | version = "0.1.0" 2384 | source = "registry+https://github.com/rust-lang/crates.io-index" 2385 | checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" 2386 | 2387 | [[package]] 2388 | name = "version_check" 2389 | version = "0.9.4" 2390 | source = "registry+https://github.com/rust-lang/crates.io-index" 2391 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 2392 | 2393 | [[package]] 2394 | name = "want" 2395 | version = "0.3.0" 2396 | source = "registry+https://github.com/rust-lang/crates.io-index" 2397 | checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" 2398 | dependencies = [ 2399 | "log", 2400 | "try-lock", 2401 | ] 2402 | 2403 | [[package]] 2404 | name = "wasi" 2405 | version = "0.11.0+wasi-snapshot-preview1" 2406 | source = "registry+https://github.com/rust-lang/crates.io-index" 2407 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 2408 | 2409 | [[package]] 2410 | name = "wasm-bindgen" 2411 | version = "0.2.79" 2412 | source = "registry+https://github.com/rust-lang/crates.io-index" 2413 | checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" 2414 | dependencies = [ 2415 | "cfg-if", 2416 | "wasm-bindgen-macro", 2417 | ] 2418 | 2419 | [[package]] 2420 | name = "wasm-bindgen-backend" 2421 | version = "0.2.79" 2422 | source = "registry+https://github.com/rust-lang/crates.io-index" 2423 | checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" 2424 | dependencies = [ 2425 | "bumpalo", 2426 | "lazy_static", 2427 | "log", 2428 | "proc-macro2", 2429 | "quote", 2430 | "syn", 2431 | "wasm-bindgen-shared", 2432 | ] 2433 | 2434 | [[package]] 2435 | name = "wasm-bindgen-macro" 2436 | version = "0.2.79" 2437 | source = "registry+https://github.com/rust-lang/crates.io-index" 2438 | checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" 2439 | dependencies = [ 2440 | "quote", 2441 | "wasm-bindgen-macro-support", 2442 | ] 2443 | 2444 | [[package]] 2445 | name = "wasm-bindgen-macro-support" 2446 | version = "0.2.79" 2447 | source = "registry+https://github.com/rust-lang/crates.io-index" 2448 | checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" 2449 | dependencies = [ 2450 | "proc-macro2", 2451 | "quote", 2452 | "syn", 2453 | "wasm-bindgen-backend", 2454 | "wasm-bindgen-shared", 2455 | ] 2456 | 2457 | [[package]] 2458 | name = "wasm-bindgen-shared" 2459 | version = "0.2.79" 2460 | source = "registry+https://github.com/rust-lang/crates.io-index" 2461 | checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" 2462 | 2463 | [[package]] 2464 | name = "web-sys" 2465 | version = "0.3.56" 2466 | source = "registry+https://github.com/rust-lang/crates.io-index" 2467 | checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" 2468 | dependencies = [ 2469 | "js-sys", 2470 | "wasm-bindgen", 2471 | ] 2472 | 2473 | [[package]] 2474 | name = "webpki" 2475 | version = "0.22.0" 2476 | source = "registry+https://github.com/rust-lang/crates.io-index" 2477 | checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" 2478 | dependencies = [ 2479 | "ring", 2480 | "untrusted", 2481 | ] 2482 | 2483 | [[package]] 2484 | name = "webpki-roots" 2485 | version = "0.22.2" 2486 | source = "registry+https://github.com/rust-lang/crates.io-index" 2487 | checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449" 2488 | dependencies = [ 2489 | "webpki", 2490 | ] 2491 | 2492 | [[package]] 2493 | name = "winapi" 2494 | version = "0.3.9" 2495 | source = "registry+https://github.com/rust-lang/crates.io-index" 2496 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 2497 | dependencies = [ 2498 | "winapi-i686-pc-windows-gnu", 2499 | "winapi-x86_64-pc-windows-gnu", 2500 | ] 2501 | 2502 | [[package]] 2503 | name = "winapi-i686-pc-windows-gnu" 2504 | version = "0.4.0" 2505 | source = "registry+https://github.com/rust-lang/crates.io-index" 2506 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 2507 | 2508 | [[package]] 2509 | name = "winapi-util" 2510 | version = "0.1.5" 2511 | source = "registry+https://github.com/rust-lang/crates.io-index" 2512 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 2513 | dependencies = [ 2514 | "winapi", 2515 | ] 2516 | 2517 | [[package]] 2518 | name = "winapi-x86_64-pc-windows-gnu" 2519 | version = "0.4.0" 2520 | source = "registry+https://github.com/rust-lang/crates.io-index" 2521 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 2522 | 2523 | [[package]] 2524 | name = "windows-sys" 2525 | version = "0.32.0" 2526 | source = "registry+https://github.com/rust-lang/crates.io-index" 2527 | checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" 2528 | dependencies = [ 2529 | "windows_aarch64_msvc", 2530 | "windows_i686_gnu", 2531 | "windows_i686_msvc", 2532 | "windows_x86_64_gnu", 2533 | "windows_x86_64_msvc", 2534 | ] 2535 | 2536 | [[package]] 2537 | name = "windows_aarch64_msvc" 2538 | version = "0.32.0" 2539 | source = "registry+https://github.com/rust-lang/crates.io-index" 2540 | checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" 2541 | 2542 | [[package]] 2543 | name = "windows_i686_gnu" 2544 | version = "0.32.0" 2545 | source = "registry+https://github.com/rust-lang/crates.io-index" 2546 | checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" 2547 | 2548 | [[package]] 2549 | name = "windows_i686_msvc" 2550 | version = "0.32.0" 2551 | source = "registry+https://github.com/rust-lang/crates.io-index" 2552 | checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" 2553 | 2554 | [[package]] 2555 | name = "windows_x86_64_gnu" 2556 | version = "0.32.0" 2557 | source = "registry+https://github.com/rust-lang/crates.io-index" 2558 | checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" 2559 | 2560 | [[package]] 2561 | name = "windows_x86_64_msvc" 2562 | version = "0.32.0" 2563 | source = "registry+https://github.com/rust-lang/crates.io-index" 2564 | checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" 2565 | 2566 | [[package]] 2567 | name = "zeroize" 2568 | version = "1.5.5" 2569 | source = "registry+https://github.com/rust-lang/crates.io-index" 2570 | checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" 2571 | --------------------------------------------------------------------------------