Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: iroh-one #212

Merged
merged 29 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4efc73e
Introduce the 'ipfsd' feature to run the gateway as a single binary.
fabricedesre Aug 10, 2022
4296326
Add mem-rpc store to ipfsd
fabricedesre Aug 11, 2022
00faa8a
Add mem-rpc p2p module to ipfsd
fabricedesre Aug 11, 2022
cd22c63
Add http over uds support
fabricedesre Aug 12, 2022
0ef6b63
iroh-one: split the all-in-one ipfsd from iroh-gateway into its own c…
fabricedesre Aug 12, 2022
b40238b
iroh-one: share constants, headers and response with iroh-gateway
fabricedesre Aug 12, 2022
e85d32d
refactor: make the http handling code shared between iroh-gateway and…
fabricedesre Aug 12, 2022
f345f98
iroh-one: remove error and metrics
fabricedesre Aug 12, 2022
0b46c89
iroh-one: share templates with iroh-gateway
fabricedesre Aug 12, 2022
9d888d9
iroh-gateway: No need for a fully generic state when creating routes
fabricedesre Aug 12, 2022
b0e316e
iroh-one: cleanup Cargo.toml
fabricedesre Aug 12, 2022
f681824
iroh-one: Implement configuration structure
fabricedesre Aug 13, 2022
dccd9d4
resolver: race p2p with raw CID download from a http gateway
fabricedesre Aug 15, 2022
25ce66b
Update description and README
fabricedesre Aug 15, 2022
59a27a1
chore: sync up with BadBits support
fabricedesre Aug 15, 2022
659cc15
fix: use rustls with reqwest
fabricedesre Aug 17, 2022
8049bce
fix: android specific oopsy
fabricedesre Aug 17, 2022
4867a01
fix: make clippy happy
fabricedesre Aug 18, 2022
64f7aee
fix: make cargo-fmt happy
fabricedesre Aug 18, 2022
07c2b9a
iroh-one: fix tests
fabricedesre Aug 18, 2022
e4a3258
fix: Add missing raw_gateway in Config::collect
fabricedesre Aug 19, 2022
f9176e6
refactor: share CLI args among iroh-gateway and iroh-one
fabricedesre Aug 19, 2022
036ba8a
cleanup
Arqu Aug 19, 2022
d209b76
fix rpc
Arqu Aug 20, 2022
bb8d41e
fixup configs
Arqu Aug 29, 2022
50a628f
further cleanup
Arqu Aug 29, 2022
bed1853
cr
Arqu Aug 30, 2022
8e2851d
fix configs
Arqu Aug 31, 2022
7085e17
bump deps
Arqu Aug 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"iroh-rpc-types",
"iroh-gateway",
"iroh-metrics",
"iroh-one",
"iroh-p2p",
"iroh-resolver",
"iroh-store",
Expand Down
2 changes: 1 addition & 1 deletion iroh-gateway/src/bad_bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ mod tests {
let gw_metrics = Metrics::new(&mut prom_registry);
let rpc_addr = "grpc://0.0.0.0:0".parse().unwrap();
let handler = crate::core::Core::new(
config,
Arc::new(config),
rpc_addr,
gw_metrics,
&mut prom_registry,
Expand Down
47 changes: 47 additions & 0 deletions iroh-gateway/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/// CLI arguments support.
use clap::Parser;
use std::collections::HashMap;
use std::path::PathBuf;

#[derive(Parser, Debug, Clone)]
#[clap(author, version, about, long_about = None)]
pub struct Args {
#[clap(short, long)]
port: Option<u16>,
#[clap(short, long)]
writeable: Option<bool>,
#[clap(short, long)]
fetch: Option<bool>,
#[clap(short, long)]
cache: Option<bool>,
#[clap(long)]
metrics: bool,
#[clap(long)]
tracing: bool,
#[clap(long)]
pub cfg: Option<PathBuf>,
#[clap(long)]
denylist: bool,
}

impl Args {
pub fn make_overrides_map(&self) -> HashMap<&str, String> {
let mut map: HashMap<&str, String> = HashMap::new();
if let Some(port) = self.port {
map.insert("port", port.to_string());
}
if let Some(writable) = self.writeable {
map.insert("writable", writable.to_string());
}
if let Some(fetch) = self.fetch {
map.insert("fetch", fetch.to_string());
}
if let Some(cache) = self.cache {
map.insert("cache", cache.to_string());
}
map.insert("denylist", self.denylist.to_string());
map.insert("metrics.collect", self.metrics.to_string());
map.insert("metrics.tracing", self.tracing.to_string());
map
}
}
2 changes: 1 addition & 1 deletion iroh-gateway/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use tokio_util::io::ReaderStream;
use tracing::info;
use tracing::warn;

use crate::core::GetParams;
use crate::handlers::GetParams;
use crate::response::ResponseFormat;

#[derive(Debug, Clone)]
Expand Down
26 changes: 20 additions & 6 deletions iroh-gateway/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ pub struct Config {
pub cache: bool,
/// default port to listen on
pub port: u16,
/// flag to toggle whether the gateway should use denylist on requests
pub denylist: bool,
/// rpc addresses for the gateway & addresses for the rpc client to dial
pub rpc_client: RpcClientConfig,
/// metrics configuration
pub metrics: MetricsConfig,
// NOTE: for toml to serialize properly, the "table" values must be serialized at the end, and
// so much come at the end of the `Config` struct
/// set of user provided headers to attach to all responses
#[serde(with = "http_serde::header_map")]
pub headers: HeaderMap,
/// rpc addresses for the gateway & addresses for the rpc client to dial
pub rpc_client: RpcClientConfig,
/// metrics configuration
pub metrics: MetricsConfig,
/// flag to toggle whether the gateway should use denylist on requests
pub denylist: bool,
}

impl Config {
Expand Down Expand Up @@ -167,6 +167,20 @@ impl Source for Config {
}
}

impl crate::handlers::StateConfig for Config {
fn rpc_client(&self) -> &iroh_rpc_client::Config {
&self.rpc_client
}

fn port(&self) -> u16 {
self.port
}

fn user_headers(&self) -> &HeaderMap<HeaderValue> {
&self.headers
}
}

fn collect_headers(headers: &HeaderMap) -> Result<Map<String, Value>, ConfigError> {
let mut map = Map::new();
for (key, value) in headers.iter() {
Expand Down
Loading