Skip to content

type(feat): Enable authenticated private relays to have a higher rate limit - #321

Open
okdistribute wants to merge 2 commits into
tonyantony300:mainfrom
okdistribute:iroh/use-authenticated-relays
Open

okdistribute wants to merge 2 commits into
tonyantony300:mainfrom
okdistribute:iroh/use-authenticated-relays

Conversation

@okdistribute

@okdistribute okdistribute commented Sep 9, 2026

Copy link
Copy Markdown

Description

This PR enables private authenticated relays which have higher rate limits than the public relays for use in Dashbeam. This default relay is managed by the n0.computer team, the same as the public relays, but with higher rate limits and better monitoring capabilities because traffic is not mixed in with all other iroh traffic.

Checklist

  • PR title follows Conventional Commits (type(scope): description)
  • I have run pnpm lint before raising this PR
  • I have run pnpm format before raising this PR

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 34f6ddd3-d838-4db8-8ae0-1714e2c77dc7

📥 Commits

Reviewing files that changed from the base of the PR and between 40cac4e and e0aefc4.

📒 Files selected for processing (2)
  • engine/tests/test_pairing.rs
  • frontend/src/components/animate-ui/primitives/effects/highlight.tsx

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

Summary

The PR adds a shared iroh endpoint builder with iroh-services relay configuration. Native, protocol, WASM, and bridge endpoint creation now use the helper. Relay URL classification and pairing coverage include iroh-services URLs.

Changes

Shared endpoint construction

Layer / File(s) Summary
Shared endpoint builder
engine/protocol/Cargo.toml, engine/protocol/src/endpoint.rs, engine/protocol/src/lib.rs
Adds endpoint_builder, iroh-services configuration, public exports, and a configuration test.
Protocol endpoint adoption
engine/protocol/src/discovery.rs, engine/protocol/src/receive.rs, engine/protocol/src/relay.rs
Routes discovery, metadata, and relay endpoint creation through the shared builder. Recognizes .relay.iroh-svc.com URLs as public relays.
Runtime integration and validation
engine/native/src/*, engine/wasm-io/src/*, wasm-bridge/src/lib.rs, engine/tests/test_pairing.rs, frontend/src/components/animate-ui/primitives/effects/highlight.tsx
Updates native, WASM, and bridge endpoint creation. Adds pairing coverage for an iroh-services relay URL. Reformats the HighlightContext declaration without changing behavior.

Suggested reviewers: tonyantony300

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to e0aef

Private authenticated relay support changes how clients establish and advertise relay connections. A reusable client-side relay credential could be abused, and overly broad relay-host matching could omit a required relay from pairing metadata, leaving a moderate merge-readiness risk.

🚥 Pre-merge checks | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.63% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 13 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 Clippy (1.97.1)

Clippy execution failed


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@socket-security

socket-security Bot commented Sep 9, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​iroh-services@​1.0.08210093100100

View full report

@okdistribute okdistribute changed the title Enable authenticated private relays to have a higher rate limit type(feat): Enable authenticated private relays to have a higher rate limit Sep 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 97cfa734-bcf7-47e0-a80b-81e160041a32

📥 Commits

Reviewing files that changed from the base of the PR and between ccc1eb8 and 40cac4e.

⛔ Files ignored due to path filters (3)
  • engine/Cargo.lock is excluded by !**/*.lock
  • src-tauri/Cargo.lock is excluded by !**/*.lock
  • wasm-bridge/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (13)
  • engine/native/src/node.rs
  • engine/native/src/receive.rs
  • engine/native/src/send.rs
  • engine/protocol/Cargo.toml
  • engine/protocol/src/discovery.rs
  • engine/protocol/src/endpoint.rs
  • engine/protocol/src/lib.rs
  • engine/protocol/src/receive.rs
  • engine/protocol/src/relay.rs
  • engine/tests/test_pairing.rs
  • engine/wasm-io/src/receive.rs
  • engine/wasm-io/src/send.rs
  • wasm-bridge/src/lib.rs

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment on lines +15 to +16
const IROH_SERVICES_API_SECRET: &str =
"servicesaaqizynrq3pdxtwxnnrlcxg5rpezbcpthntqlwpxc5oren2557x6nkgjlxfzhaykym52alh56n2vwg5b5sme5k2r3ez6rbuyevxwsx2cgeaa";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🛡️ Analyzed with Security Review | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🤖 get_repo_knowledge executed:

get_repo_knowledge tonyantony300/dashbeam /tmp/coderabbit-repo-knowledge/tonyantony300-dashbeam-aad65dbd

Length of output: 370


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- endpoint.rs ---'
sed -n '1,90p' engine/protocol/src/endpoint.rs
printf '%s\n' '--- direct references to the secret and builder ---'
rg -n -C 3 'IROH_SERVICES_API_SECRET|api_secret_from_str|endpoint_builder' engine/protocol
printf '%s\n' '--- dependency declarations ---'
rg -n -C 2 'iroh-services|iroh' Cargo.toml engine Cargo.lock 2>/dev/null | head -120

Repository: tonyantony300/dashbeam

Length of output: 14408


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- iroh-services declarations and lock entries ---'
rg -n -C 5 'iroh-services|iroh_svc|relay\.iroh-svc\.com|api_secret' . --glob '!target/**' --glob '!node_modules/**' | head -200
printf '%s\n' '--- public entry callers for default mode ---'
sed -n '150,200p' engine/protocol/src/discovery.rs
sed -n '160,195p' engine/protocol/src/relay.rs
sed -n '330,360p' engine/protocol/src/relay.rs
sed -n '250,285p' engine/protocol/src/receive.rs

Repository: tonyantony300/dashbeam

Length of output: 14396


🌐 Web query:

iroh-services 1.0.0 api_secret_from_str API secret relay authorization documentation

💡 Result:

In the iroh-services 1.0.0 Rust crate, the api_secret_from_str method is a function provided by the IrohServicesPreset builder (and ClientBuilder) used to configure an Iroh Services client with an API secret [1][2][3]. When you provide an API secret string via api_secret_from_str, the method parses the encoded string into an ApiSecret and stashes it on the builder [1][3]. This API secret is then used by the iroh-services SDK to automatically authenticate your endpoint when it connects to managed relays [4][5][6]. Key points regarding relay authorization and the API secret: 1. Automatic Authentication: You do not need to manually manage Authorization headers or tokens for managed relays [4][6]. The iroh-services preset uses your API secret to mint short-lived, signed access tokens scoped to your endpoint's specific identity [5][6]. 2. Security: The API secret itself never leaves your application or is sent over the wire [5][6]. Only the derived, short-lived token is presented to the relay during the connection handshake [5][6]. 3. Configuration: While api_secret_from_str allows you to set the secret directly from a string (e.g., from a config file), it is recommended to use api_secret_from_env to load the secret from the IROH_SERVICES_API_SECRET environment variable in production environments [7][3][8]. Example usage: let preset = iroh_services::preset.api_secret_from_str("YOUR_API_KEY")? // Sets the secret from a string [8].build?; let endpoint = Endpoint::bind(preset.clone).await?; let client = preset.client_builder(&endpoint).build.await?; [7][8] If you are running your own, non-managed relay, the authentication mechanism differs; those relays typically require shared tokens or HTTP callout configurations defined in their own server settings rather than using the iroh-services preset API secret [9].

Citations:


Sensitive Data Exposure

Reachability: External
Exploitability: Trivial
CWE: CWE-798 — Use of Hard-coded Credentials

Remove the client-embedded relay credential.

IROH_SERVICES_API_SECRET is embedded in client code. Anyone can recover it from the source or a distributed binary and mint relay access tokens under the shared service account. This can exhaust shared relay quotas or rate limits.

Issue per-user or short-lived credentials from an authenticated service. If this value is intended to be public, do not use it as relay authorization.

url.contains("relay.n0.iroh.link") || url.contains(".iroh.link")
url.contains("relay.n0.iroh.link")
|| url.contains(".iroh.link")
|| url.contains(".relay.iroh-svc.com")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Match the relay host boundary.

contains accepts untrusted hosts such as https://x.relay.iroh-svc.com.attacker.example/. This classifies the URL as public. Pairing can then omit the configured relay URL and cause recipients to use the wrong relay.

Parse the URL and test host_str() with an exact suffix check, such as host.ends_with(".relay.iroh-svc.com").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants