A rust-based command line tool to serve as a gateway for a Internet Computer replica.

Overview

icx-proxy

A command line tool to serve as a gateway for a Internet Computer replica.

Contributing

Please follow the guidelines in the CONTRIBUTING.md document.

Installing icx-proxy

One can install icx-proxy by running cargo;

cargo install icx-proxy

Usage

Once installed, using icx-proxy --help will show the usage message and all the flags.

Ecosystem

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.

Comments
  • Calls to `/api` are no longer forwarded to the replica

    Calls to `/api` are no longer forwarded to the replica

    I upgraded icx-proxy from e3866f0040d73cda4c5d4092b85af517b11b833f to 7624053a50e1683c48757ee5dacbb454921e39ef and now the initial call to /api/v2/status returns the HTML page of my asset canister, and a CBOR decoder tries to decode that and throws an error.

    I downgraded back to e3866f0040d73cda4c5d4092b85af517b11b833f API calls were forwarded again.

    Is there some new flag I need to pass to get the old behavior? I couldn't see anything obvious in the help text.

    opened by paulyoung 12
  • Could not compile `ic-utils` during `cargo install icx-proxy`

    Could not compile `ic-utils` during `cargo install icx-proxy`

    Hi there! I'm getting the below error when trying to run cargo install icx-proxy.

       Compiling ic-agent v0.9.0
       Compiling ic-utils v0.7.0
    error[E0277]: the trait bound `ic_agent::export::Principal: CandidType` is not satisfied
       --> /Users/phuongvu/.cargo/registry/src/github.com-1ecc6299db9ec823/ic-utils-0.7.0/src/interfaces/management_canister/builders.rs:251:42
        |
    251 | impl<'agent, 'canister: 'agent, T: Sync> AsyncCall<(Principal,)>
        |                                          ^^^^^^^^^^^^^^^^^^^^^^^ the trait `CandidType` is not implemented for `ic_agent::export::Principal`
        |
        = note: required because of the requirements on the impl of `for<'de> ArgumentDecoder<'de>` for `(ic_agent::export::Principal,)`
    note: required by a bound in `AsyncCall`
       --> /Users/phuongvu/.cargo/registry/src/github.com-1ecc6299db9ec823/ic-utils-0.7.0/src/call.rs:38:10
        |
    36  | pub trait AsyncCall<Out>
        |           --------- required by a bound in this
    37  | where
    38  |     Out: for<'de> ArgumentDecoder<'de> + Send,
        |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AsyncCall`
    
    For more information about this error, try `rustc --explain E0277`.
    error: could not compile `ic-utils` due to previous error
    warning: build failed, waiting for other jobs to finish...
    error: failed to compile `icx-proxy v0.7.0`, intermediate artifacts can be found at `/var/folders/zj/f8bhtxm522vd_js96_y2w66c0000gn/T/cargo-installauI5dz`
    
    opened by zestified 10
  • feat: upgrade HTTP calls upon canister's request

    feat: upgrade HTTP calls upon canister's request

    This applies changes from https://github.com/dfinity/agent-rs/pull/195 that are specific to icx-proxy.

    It necessarily depends on a newer version of ~agent-rs~ ic-agent and ic-utils. This will most likely be something like 10.X.0 but temporarily uses a Git URL for now.

    opened by paulyoung 6
  • feat: Add metrics for validation

    feat: Add metrics for validation

    This change creates a Validate trait and then uses it to wrap the existing validation logic. We then wrap our Validator struct using WithMetrics to expose whether requests passed/failed/skipped validation.

    opened by rikonor 4
  • chore: release workflow: check contents of macos binary tarball

    chore: release workflow: check contents of macos binary tarball

    Some of the macos release tarballs contain a corrupt executable, in which the first 0x800000 bytes are all zeros.

    For example, the macos release binary for commit https://github.com/dfinity/icx-proxy/commit/59674697309548b7021d457d95c32057e7681bf6 is corrupt:

    $ wget https://github.com/dfinity/icx-proxy/releases/download/5967469/binaries-macos.tar.gz
    $ tar -xzf binaries-macos.tar.gz 
    $ ./icx-proxy --help
    zsh: exec format error: ./icx-proxy
    $ hexdump -C icx-proxy | head
    00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    00800000  40 69 6e 00 01 00 00 00  62 00 00 00 00 00 00 00  |@in.....b.......|
    00800010  74 01 00 00 09 00 00 00  c0 6a 6e 00 01 00 00 00  |t........jn.....|
    00800020  0c 00 00 00 00 00 00 00  40 69 6e 00 01 00 00 00  |........@in.....|
    00800030  62 00 00 00 00 00 00 00  ff 00 00 00 09 00 00 00  |b...............|
    00800040  cc 6a 6e 00 01 00 00 00  0d 00 00 00 00 00 00 00  |.jn.............|
    00800050  40 69 6e 00 01 00 00 00  62 00 00 00 00 00 00 00  |@in.....b.......|
    00800060  0f 01 00 00 09 00 00 00  fe 6a 6e 00 01 00 00 00  |.........jn.....|
    00800070  0e 00 00 00 00 00 00 00  40 69 6e 00 01 00 00 00  |........@in.....|
    

    I have not found a way to ensure that the macos release tarball contains a valid binary. I tried:

    • Adding retry logic to the workflow
    • Splitting up the tar step from the gzip step

    This PR makes two changes:

    • Verify that the binary in the tarball can execute, or fail the CI run.
    • Create all release artifacts before uploading any of them. An alternative would have been to upload whichever worked, which would then be overwritten on retry.
    opened by ericswanson-dfinity 2
  • fix: fix a crash bug due to incorrect utf8 slicing

    fix: fix a crash bug due to incorrect utf8 slicing

    When we print log strings by taking slices, we must be mindful about utf8 code points. Otherwise it will crash the program:

    thread 'tokio-runtime-worker' panicked at 'byte index 100 is not a char boundary; 
    

    The fix is to take the slice before converting to utf8 (and use from_utf8_lossy).

    opened by ninegua 2
  • fix: added body decoding before validation

    fix: added body decoding before validation

    That is missing part of body validation preprocessor. Without this, the verification of certificates for the assets-canister does not work (). Check the service-worker realization for details

    opened by 3cL1p5e7 1
  • chore(deps): bump axum-core from 0.2.7 to 0.2.8

    chore(deps): bump axum-core from 0.2.7 to 0.2.8

    Bumps axum-core from 0.2.7 to 0.2.8.

    Release notes

    Sourced from axum-core's releases.

    axum-core - v0.2.8

    Security

    • breaking: Added default limit to how much data Bytes::from_request will consume. Previously it would attempt to consume the entire request body without checking its length. This meant if a malicious peer sent an large (or infinite) request body your server might run out of memory and crash.

      The default limit is at 2 MB and can be disabled by adding the new DefaultBodyLimit::disable() middleware. See its documentation for more details.

      This also applies to String which used Bytes::from_request internally.

      (#1346)

    #1346: tokio-rs/axum#1346

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • refactor: from `slog`+`hyper` to `tracing`+`axum`

    refactor: from `slog`+`hyper` to `tracing`+`axum`

    This is a massive refactor which will enable us to collect better logs.

    • Moves code out of main.rs
      • agent proxy code is now in proxy/agent.rs
      • forwarding proxy code is now in proxy/forward.rs
      • temporary src/http_transport.rs pending on dfinity/agent-rs#373
    • Adds a new log format switch with json support. The exact format may need some fine tuning
    • Completely gets rid of reqwest
    opened by Daniel-Bloom-dfinity 0
  • fix: use stream api instead of channel

    fix: use stream api instead of channel

    Spawning a task has some slightly different async properties compared to the stream api, and in this case, we should prefer the stream api.

    This allows us to buffer a preset amount and ties the cancellation of the downstream request more closely to the upstream request.

    opened by Daniel-Bloom-dfinity 0
  • feat: limit request body size

    feat: limit request body size

    This change introduces the usage of http_body::Limited to ensure we don't allow incoming requests to exceed a certain size. We should consider using Tower going forward so that we can construct this using middlewares and not have all the logic live in one large function.

    opened by rikonor 0
  • 400 error for assets with path /api/...

    400 error for assets with path /api/...

    If some asset is uploaded to the asset canister under name api/xyz, then requesting it through icx-proxy will result in 400 error, which happens on both local dfx deployment and main net.

    This is because icx-proxy hard coded path api to redirect to replica in these lines https://github.com/dfinity/icx-proxy/blob/4f732947846f3314e73db185e2932ad5a05c37b3/src/proxy/mod.rs#L157-L158

    Given that /api is such a common prefix, shall we change it to something like /_/api ? Or at least give a better error message with some description of what could be going on?

    opened by ninegua 2
  • feat: chunks certification

    feat: chunks certification

    That is a part of proposal about chunks certification (with backward compatibility).

    These improvements are a proposal to improve the certification infrastructure around IC and might be considered as a recommendation for dfinity-team.

    Goal

    Make it possible to certify asset chunks. Validate chunk certificates on the service-worker and icx-proxy.

    Why

    At the moment, the service-worker and icx-proxy does not support the certification of chunkified files. Moreover, right now it is not possible to correctly stream chunkified and large audio and video files to the front-end. This problems could be solved independently if it would be possible to install an additional service-worker in the certified zone of the domain ic0.app (for 206 partial http-request handling). But is is impossible because there is unable to place custom worker on ic0.app domain. Making your own custom player for audio and video is extremely difficult due to the large number of formats and non-native implementation.

    Details

    To make this possible, support for HTTP-range requests for http_request query method has been added. This is done to support native html audio/video element (which uses 206 partial http-request) and to determine the index of the chunk throught 206 partial http-request. Using 206 partial http-requests allows you to focus only on certification in the worker and icx-proxy.

    Steps

    1. It all starts with PR for certified-assets-canister in cdk-rs
    2. Did file was updated in PR for certified-assets-canister
    3. Service-worker started supporting chunk_tree certificate verification in PR for ic
    4. (Here) icx-proxy started supporting chunk_tree certificate verification here
    5. Added support for new certified-assets-canister did in PR for agent-rs
    opened by 3cL1p5e7 4
  • fix: Enforce http2, fix dfx local server not supported by ic-rosetta-api

    fix: Enforce http2, fix dfx local server not supported by ic-rosetta-api

    When dfx starts a local replica, it automatically starts icx-proxy to reroute the incoming requests. It uses hyper for http logic, and hyper doesn't properly support http1/http2 dual stack. The main ic repo assumes http2 in a lot of places, one consequence of that is ic-rosetta-api being unable to connect to the local replica started by dfx. This patch fixes that problem.

    See ticket https://dfinity.atlassian.net/browse/ROSETTA1-162 for more context.

    opened by TerrorJack 1
Releases(rev-4f73294)
Owner
DFINITY
The Internet Computer aims to reinvent the internet as a computer to host secure software and a new breed of open internet services.
DFINITY
Cover is an open internet service for canister code verification on the Internet Computer

Cover Cover (short for Code Verification) is an open internet service that helps verify the code of canisters on the Internet Computer. Visit our webs

Psychedelic 14 Oct 31, 2022
A simple API gateway written in Rust, using the Hyper and Reqwest libraries.

API Gateway A simple API gateway written in Rust, using the Hyper and Reqwest libraries. This gateway can be used to forward requests to different bac

Adão Raul 3 Apr 24, 2023
A library-first, lightweight, high-performance, cloud-native supported API gateway🪐 by RUST

Preview version, will not guarantee the stability of the API! Do NOT use in production environment! A library-first, lightweight, high-performance, cl

Ideal World 4 May 7, 2023
A sample API Gateway built in Rust (work in progress) for learning purposes

rust-api-gateway A sample API Gateway built in Rust (work in progress) for learning purposes. You can follow along by reading the tutorial articles: P

Luis Soares 4 Oct 29, 2023
A Prometheus Aggregation Gateway for FAAS applications

Gravel Gateway Gravel Gateway is a Prometheus Push Gateway for FAAS applications. In particular it allows aggregation to be controlled by the incoming

Colin Douch 85 Nov 23, 2022
Drop-in proxy for Discord gateway connections and sessions allowing for zero downtime deploys

gateway-proxy This is a very hacky project, so it might stop working if Discord changes their API core. This is unlikely, but keep that in mind while

Jens Reidel 39 Nov 26, 2022
A Prometheus Aggregation Gateway for FAAS applications

Gravel Gateway Gravel Gateway is a Prometheus Push Gateway for FAAS applications. In particular it allows aggregation to be controlled by the incoming

Colin Douch 85 Nov 23, 2022
The registration server for WebThings Gateway.

Registration Server This server exposes an HTTP API that lets you register a WebThings Gateway for tunneling support. When combined with a PowerDNS se

WebThings 78 Nov 21, 2022
WireGuard gateway with SNI for portable connectivity.

Gateway This is a daemon that controls gateway servers. Gateway servers are servers that fulfil three major purposes: facilitating connectivity betwee

Fractal Networks 5 Aug 9, 2022
Bring the power of pre-signed URLs to your apps. Signway is a gateway for redirecting authentic signed URLs to the requested API

A gateway that proxies signed requests to other APIs. Check the docs for more info. If you are looking for the managed version checkout this link http

Gabriel 37 Jun 24, 2023
User-space Wireguard gateway allowing sharing network connection from environment where usual routing rules are inaccessible.

wgslirpy A command line tool (and a Rust library) for accepting incoming connections within a Wireguard link and routing them to external network usin

Vitaly Shukela 4 Aug 21, 2023
A tool to aid in self-hosting. Expose local services on your computer, via a public IPv4 address.

innisfree A tool to aid in self-hosting. Expose local services on your computer, via a public IPv4 address. Why? Most of the data I maintain is local,

Conor Schaefer 7 Mar 19, 2022
MASQ Network 121 Dec 20, 2022
Simple DHCP client for the Wiznet W5500 internet offload chip.

w5500-dhcp Simple DHCP client for the Wiznet W5500 SPI internet offload chip. Warning Please proceed with caution, and review the code before use in a

Alex 0 Mar 20, 2022
Final Project for "Computer Networking Security": A Layer-3 VPN implementation over TLS

Final Project for "Computer Networking Security": A Layer-3 VPN implementation over TLS

Siger Yang 2 Jun 7, 2022
Command-line DNS client using bitvec, nom and RFC 1035

Dingo Domain INformation Gatherer, Obviously. Installation Install cargo, see instructions on the Rust website Run ./install.sh (it just does cargo bu

Adam Chalmers 94 Oct 18, 2022
Userspace libpcap-based tool to mirror your dns traffic

DNS traffic mirroring tool (dns-mirror) Description Userspace libpcap-based tool. dns-mirror sniffs dns packets on the given interface and proxies it

Timofey 1 Mar 15, 2022
Dns subdomain finding tool, based off of the c application of the same name

dnsmap-rs Tool for brute-forcing/scanning for existing subdomains in a domain. Based on dnsmap c application that is packaged in kali linux. Can query

Tomás Alvarez 3 Oct 19, 2022
Futures-based QUIC implementation in Rust

Pure-rust QUIC protocol implementation Quinn is a pure-rust, future-based implementation of the QUIC transport protocol undergoing standardization by

null 2.6k Jan 8, 2023