Radish alpha
r
rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5
Radicle web interface
Radicle
Git
http: release radicle-httpd v0.12.0
Open did:key:z6MkkfM3...sVz5 opened 1 year ago
  • Removal of rad-web
  • Remove of radicle-cli dependency
  • Update radicle crate dependency to 0.11.1
9 files changed +25 -580 5ed05651 13cd3aa1
modified radicle-httpd/Cargo.lock
@@ -139,35 +139,6 @@ dependencies = [
]

[[package]]
-
name = "anstream"
-
version = "0.6.13"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb"
-
dependencies = [
-
 "anstyle",
-
 "anstyle-parse",
-
 "anstyle-query",
-
 "anstyle-wincon",
-
 "colorchoice",
-
 "utf8parse",
-
]
-

-
[[package]]
-
name = "anstyle"
-
version = "1.0.6"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc"
-

-
[[package]]
-
name = "anstyle-parse"
-
version = "0.2.3"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
-
dependencies = [
-
 "utf8parse",
-
]
-

-
[[package]]
name = "anstyle-query"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -177,16 +148,6 @@ dependencies = [
]

[[package]]
-
name = "anstyle-wincon"
-
version = "3.0.2"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
-
dependencies = [
-
 "anstyle",
-
 "windows-sys 0.52.0",
-
]
-

-
[[package]]
name = "anyhow"
version = "1.0.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -479,22 +440,6 @@ dependencies = [
]

[[package]]
-
name = "colorchoice"
-
version = "1.0.0"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
-

-
[[package]]
-
name = "colored"
-
version = "2.1.0"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
-
dependencies = [
-
 "lazy_static",
-
 "windows-sys 0.48.0",
-
]
-

-
[[package]]
name = "const-oid"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -749,18 +694,6 @@ dependencies = [
]

[[package]]
-
name = "escargot"
-
version = "0.5.10"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "4f474c6844cbd04e783d0f25757583db4f491770ca618bedf2fb01815fc79939"
-
dependencies = [
-
 "log",
-
 "once_cell",
-
 "serde",
-
 "serde_json",
-
]
-

-
[[package]]
name = "fastrand"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1360,12 +1293,6 @@ dependencies = [
]

[[package]]
-
name = "normalize-line-endings"
-
version = "0.3.0"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
-

-
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1699,14 +1626,12 @@ dependencies = [

[[package]]
name = "radicle"
-
version = "0.11.0"
+
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "c2c96b3901ca5b7bfe06da3fb18105c32dc5f9f5c48a217cfc7104385a687195"
+
checksum = "acd518b6fdbfb4355e261f91fa3acb9ab5f83c842714ea5e7a3f66762f17b816"
dependencies = [
 "amplify",
 "base64 0.21.7",
-
 "chrono",
-
 "colored",
 "crossbeam-channel",
 "cyphernet",
 "fastrand",
@@ -1717,7 +1642,6 @@ dependencies = [
 "multibase",
 "nonempty 0.9.0",
 "once_cell",
-
 "qcheck",
 "radicle-cob",
 "radicle-crypto",
 "radicle-git-ext",
@@ -1732,64 +1656,6 @@ dependencies = [
]

[[package]]
-
name = "radicle-cli"
-
version = "0.10.0"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "5347c326bec844b7ced9c8f8bcfec88104ea2066c029d49d5128dd09a4148c50"
-
dependencies = [
-
 "anyhow",
-
 "chrono",
-
 "git-ref-format",
-
 "lexopt",
-
 "localtime",
-
 "log",
-
 "nonempty 0.9.0",
-
 "radicle",
-
 "radicle-cli-test",
-
 "radicle-cob",
-
 "radicle-crypto",
-
 "radicle-git-ext",
-
 "radicle-surf",
-
 "radicle-term",
-
 "serde",
-
 "serde_json",
-
 "shlex",
-
 "tempfile",
-
 "thiserror",
-
 "timeago",
-
 "tree-sitter",
-
 "tree-sitter-bash",
-
 "tree-sitter-c",
-
 "tree-sitter-css",
-
 "tree-sitter-go",
-
 "tree-sitter-highlight",
-
 "tree-sitter-html",
-
 "tree-sitter-json",
-
 "tree-sitter-md",
-
 "tree-sitter-python",
-
 "tree-sitter-ruby",
-
 "tree-sitter-rust",
-
 "tree-sitter-toml",
-
 "tree-sitter-typescript",
-
 "zeroize",
-
]
-

-
[[package]]
-
name = "radicle-cli-test"
-
version = "0.10.0"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "d5bbd1dc7cb2801693d6d00f937021adb0d398e9fec6b998e4830ebba32fdfdd"
-
dependencies = [
-
 "escargot",
-
 "log",
-
 "pretty_assertions",
-
 "radicle",
-
 "shlex",
-
 "snapbox",
-
 "thiserror",
-
]
-

-
[[package]]
name = "radicle-cob"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1854,7 +1720,7 @@ dependencies = [

[[package]]
name = "radicle-httpd"
-
version = "0.11.0"
+
version = "0.12.0"
dependencies = [
 "anyhow",
 "axum",
@@ -1870,7 +1736,6 @@ dependencies = [
 "nonempty 0.9.0",
 "pretty_assertions",
 "radicle",
-
 "radicle-cli",
 "radicle-crypto",
 "radicle-surf",
 "radicle-term",
@@ -2230,12 +2095,6 @@ dependencies = [
]

[[package]]
-
name = "similar"
-
version = "2.5.0"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640"
-

-
[[package]]
name = "siphasher"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2257,28 +2116,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"

[[package]]
-
name = "snapbox"
-
version = "0.4.17"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "4b831b6e80fbcd2889efa75b185d24005f85981431495f995292b25836519d84"
-
dependencies = [
-
 "anstream",
-
 "anstyle",
-
 "normalize-line-endings",
-
 "similar",
-
 "snapbox-macros",
-
]
-

-
[[package]]
-
name = "snapbox-macros"
-
version = "0.3.8"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "e1c4b838b05d15ab22754068cb73500b2f3b07bf09d310e15b27f88160f1de40"
-
dependencies = [
-
 "anstream",
-
]
-

-
[[package]]
name = "socket2"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2542,12 +2379,6 @@ dependencies = [
]

[[package]]
-
name = "timeago"
-
version = "0.4.2"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "a1710e589de0a76aaf295cd47a6699f6405737dbfd3cf2b75c92d000b548d0e6"
-

-
[[package]]
name = "tinyvec"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2711,147 +2542,6 @@ dependencies = [
]

[[package]]
-
name = "tree-sitter"
-
version = "0.20.10"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d"
-
dependencies = [
-
 "cc",
-
 "regex",
-
]
-

-
[[package]]
-
name = "tree-sitter-bash"
-
version = "0.20.5"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "57da2032c37eb2ce29fd18df7d3b94355fec8d6d854d8f80934955df542b5906"
-
dependencies = [
-
 "cc",
-
 "tree-sitter",
-
]
-

-
[[package]]
-
name = "tree-sitter-c"
-
version = "0.20.8"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "4bbd5f3d8658c08581f8f2adac6c391c2e9fa00fe9246bf6c5f52213b9cc6b72"
-
dependencies = [
-
 "cc",
-
 "tree-sitter",
-
]
-

-
[[package]]
-
name = "tree-sitter-css"
-
version = "0.20.0"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "c3306ddefa1d2681adda2613d11974ffabfbeb215e23235da6c862f3493a04fd"
-
dependencies = [
-
 "cc",
-
 "tree-sitter",
-
]
-

-
[[package]]
-
name = "tree-sitter-go"
-
version = "0.20.0"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "1ad6d11f19441b961af2fda7f12f5d0dac325f6d6de83836a1d3750018cc5114"
-
dependencies = [
-
 "cc",
-
 "tree-sitter",
-
]
-

-
[[package]]
-
name = "tree-sitter-highlight"
-
version = "0.20.1"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "042342584c5a7a0b833d9fc4e2bdab3f9868ddc6c4b339a1e01451c6720868bc"
-
dependencies = [
-
 "regex",
-
 "thiserror",
-
 "tree-sitter",
-
]
-

-
[[package]]
-
name = "tree-sitter-html"
-
version = "0.20.0"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "017822b6bd42843c4bd67fabb834f61ce23254e866282dd93871350fd6b7fa1d"
-
dependencies = [
-
 "cc",
-
 "tree-sitter",
-
]
-

-
[[package]]
-
name = "tree-sitter-json"
-
version = "0.20.2"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "5a9a38a9c679b55cc8d17350381ec08d69fa1a17a53fcf197f344516e485ed4d"
-
dependencies = [
-
 "cc",
-
 "tree-sitter",
-
]
-

-
[[package]]
-
name = "tree-sitter-md"
-
version = "0.1.7"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "3c20d3ef8d202430b644a307e6299d84bf8ed87fa1b796e4638f8805a595060c"
-
dependencies = [
-
 "cc",
-
 "tree-sitter",
-
]
-

-
[[package]]
-
name = "tree-sitter-python"
-
version = "0.20.4"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "e6c93b1b1fbd0d399db3445f51fd3058e43d0b4dcff62ddbdb46e66550978aa5"
-
dependencies = [
-
 "cc",
-
 "tree-sitter",
-
]
-

-
[[package]]
-
name = "tree-sitter-ruby"
-
version = "0.20.1"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "44d50ef383469df8485f024c5fb01faced8cb90368192a7ba02605b43b2427fe"
-
dependencies = [
-
 "cc",
-
 "tree-sitter",
-
]
-

-
[[package]]
-
name = "tree-sitter-rust"
-
version = "0.20.4"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "b0832309b0b2b6d33760ce5c0e818cb47e1d72b468516bfe4134408926fa7594"
-
dependencies = [
-
 "cc",
-
 "tree-sitter",
-
]
-

-
[[package]]
-
name = "tree-sitter-toml"
-
version = "0.20.0"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "ca517f578a98b23d20780247cc2688407fa81effad5b627a5a364ec3339b53e8"
-
dependencies = [
-
 "cc",
-
 "tree-sitter",
-
]
-

-
[[package]]
-
name = "tree-sitter-typescript"
-
version = "0.20.5"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "c8bc1d2c24276a48ef097a71b56888ac9db63717e8f8d0b324668a27fd619670"
-
dependencies = [
-
 "cc",
-
 "tree-sitter",
-
]
-

-
[[package]]
name = "try-lock"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2942,12 +2632,6 @@ dependencies = [
]

[[package]]
-
name = "utf8parse"
-
version = "0.2.1"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
-

-
[[package]]
name = "valuable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
modified radicle-httpd/Cargo.toml
@@ -3,7 +3,7 @@ name = "radicle-httpd"
description = "Radicle HTTP daemon"
homepage = "https://radicle.xyz"
license = "MIT OR Apache-2.0"
-
version = "0.11.0"
+
version = "0.12.0"
authors = ["cloudhead <cloudhead@radicle.xyz>"]
edition = "2021"
default-run = "radicle-httpd"
@@ -20,10 +20,6 @@ logfmt = [
name = "radicle-httpd"
path = "src/main.rs"

-
[[bin]]
-
name = "rad-web"
-
path = "src/bin/rad-web.rs"
-

[dependencies]
anyhow = { version = "1" }
axum = { version = "0.7.2", default-features = false, features = ["json", "query", "tokio", "http1"] }
@@ -51,14 +47,11 @@ ureq = { version = "2.9", default-features = false, features = ["json"] }
url = { version = "2.5.0" }

[dependencies.radicle]
-
version = "0.11.0"
+
version = "0.11.1"

[dependencies.radicle-term]
version = "0.10.0"

-
[dependencies.radicle-cli]
-
version = "0.10.0"
-

[dev-dependencies]
hyper = { version = "1.0.1", default-features = false, features = ["client"] }
pretty_assertions = { version = "1.3.0" }
modified radicle-httpd/build/Dockerfile
@@ -60,19 +60,15 @@ ARG RADICLE_VERSION
ARG SOURCE_DATE_EPOCH

COPY --from=builder \
-
    /src/target/x86_64-unknown-linux-musl/release/rad-web \
    /src/target/x86_64-unknown-linux-musl/release/radicle-httpd \
    /builds/x86_64-unknown-linux-musl/bin/
COPY --from=builder \
-
    /src/target/aarch64-unknown-linux-musl/release/rad-web \
    /src/target/aarch64-unknown-linux-musl/release/radicle-httpd \
    /builds/aarch64-unknown-linux-musl/bin/
COPY --from=builder \
-
    /src/target/aarch64-apple-darwin/release/rad-web \
    /src/target/aarch64-apple-darwin/release/radicle-httpd \
    /builds/aarch64-apple-darwin/bin/
COPY --from=builder \
-
    /src/target/x86_64-apple-darwin/release/rad-web \
    /src/target/x86_64-apple-darwin/release/radicle-httpd \
    /builds/x86_64-apple-darwin/bin/
COPY --from=builder /src/*.1 /builds/x86_64-unknown-linux-musl/man/man1/
modified radicle-httpd/src/api/v1/node.rs
@@ -76,7 +76,7 @@ async fn nodes_inventory_handler(
    Path(nid): Path<NodeId>,
) -> impl IntoResponse {
    let db = &ctx.profile.database()?;
-
    let resources = db.get_resources(&nid)?;
+
    let resources = db.get_inventory(&nid)?;

    Ok::<_, Error>(Json(resources))
}
modified radicle-httpd/src/api/v1/sessions.rs
@@ -122,13 +122,31 @@ async fn session_delete_handler(

#[cfg(test)]
mod routes {
-
    use crate::commands::web::{sign, SessionInfo};
    use axum::body::Body;
    use axum::http::StatusCode;
+
    use serde::{Deserialize, Serialize};
+

+
    use radicle::crypto::{PublicKey, Signature, Signer};

    use crate::api::auth::{AuthState, Session};
    use crate::test::{self, get, post, put};

+
    #[derive(Debug, Clone, Deserialize, Serialize)]
+
    #[serde(rename_all = "camelCase")]
+
    pub struct SessionInfo {
+
        pub session_id: String,
+
        pub public_key: PublicKey,
+
    }
+

+
    pub fn sign(
+
        signer: Box<dyn Signer>,
+
        session: &SessionInfo,
+
    ) -> Result<Signature, anyhow::Error> {
+
        signer
+
            .try_sign(format!("{}:{}", session.session_id, session.public_key).as_bytes())
+
            .map_err(anyhow::Error::from)
+
    }
+

    #[tokio::test]
    async fn test_session() {
        let tmp = tempfile::tempdir().unwrap();
deleted radicle-httpd/src/bin/rad-web.rs
@@ -1,10 +0,0 @@
-
use radicle_cli::terminal as term;
-
use radicle_httpd::commands::web as rad_web;
-

-
fn main() {
-
    term::run_command_args::<rad_web::Options, _>(
-
        rad_web::HELP,
-
        rad_web::run,
-
        std::env::args_os().skip(1).collect(),
-
    )
-
}
deleted radicle-httpd/src/commands.rs
@@ -1,2 +0,0 @@
-
//! Extra CLI commands relating to HTTPd.
-
pub mod web;
deleted radicle-httpd/src/commands/web.rs
@@ -1,233 +0,0 @@
-
use std::ffi::OsString;
-
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
-
use std::process::Command;
-
use std::thread::sleep;
-
use std::time::Duration;
-

-
use anyhow::{anyhow, Context};
-
use serde::{Deserialize, Serialize};
-
use url::{Position, Url};
-

-
use radicle::crypto::{PublicKey, Signature, Signer};
-

-
use radicle_cli::terminal as term;
-
use radicle_cli::terminal::args::{Args, Error, Help};
-

-
pub const HELP: Help = Help {
-
    name: "web",
-
    description: "Run the HTTP daemon and connect the web explorer to it",
-
    version: env!("RADICLE_VERSION"),
-
    usage: r#"
-
Usage
-

-
    rad web [<option>...] [<explorer-url>]
-

-
    Runs the Radicle HTTP Daemon and opens a Radicle web explorer to authenticate with it.
-

-
Options
-

-
    --listen, -l  <addr>     Address to bind the HTTP daemon to (default: 127.0.0.1:8080)
-
    --connect, -c [<addr>]   Connect the explorer to an already running daemon (default: 127.0.0.1:8080)
-
    --path, -p  <path>       Path to be opened in the explorer after authentication
-
    --[no-]open              Open the authentication URL automatically (default: open)
-
    --help                   Print help
-
"#,
-
};
-

-
#[derive(Debug, Clone, Deserialize, Serialize)]
-
#[serde(rename_all = "camelCase")]
-
pub struct SessionInfo {
-
    pub session_id: String,
-
    pub public_key: PublicKey,
-
}
-

-
#[derive(Debug)]
-
pub struct Options {
-
    pub app_url: Url,
-
    pub listen: SocketAddr,
-
    pub path: Option<String>,
-
    pub connect: Option<SocketAddr>,
-
    pub open: bool,
-
}
-

-
impl Args for Options {
-
    fn from_args(args: Vec<OsString>) -> anyhow::Result<(Self, Vec<OsString>)> {
-
        use lexopt::prelude::*;
-

-
        let mut parser = lexopt::Parser::from_args(args);
-
        let mut listen = None;
-
        let mut connect = None;
-
        let mut path = None;
-
        // SAFETY: This is a valid URL.
-
        #[allow(clippy::unwrap_used)]
-
        let mut app_url = Url::parse("https://app.radicle.xyz").unwrap();
-
        let mut open = true;
-

-
        while let Some(arg) = parser.next()? {
-
            match arg {
-
                Long("listen") | Short('l') if listen.is_none() => {
-
                    let val = parser.value()?;
-
                    listen = Some(term::args::socket_addr(&val)?);
-
                }
-
                Long("path") | Short('p') if path.is_none() => {
-
                    let val = parser.value()?;
-
                    path = Some(term::args::string(&val));
-
                }
-
                Long("connect") | Short('c') if connect.is_none() => {
-
                    if let Ok(val) = parser.value() {
-
                        connect = Some(term::args::socket_addr(&val)?);
-
                    } else {
-
                        connect = Some(SocketAddr::new(
-
                            IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
-
                            8080,
-
                        ));
-
                    }
-
                }
-
                Long("open") => open = true,
-
                Long("no-open") => open = false,
-
                Long("help") | Short('h') => {
-
                    return Err(Error::Help.into());
-
                }
-
                Value(val) => {
-
                    let val = val.to_string_lossy();
-
                    app_url = Url::parse(val.as_ref()).context("invalid explorer URL supplied")?;
-
                }
-
                _ => {
-
                    return Err(anyhow!(arg.unexpected()));
-
                }
-
            }
-
        }
-

-
        Ok((
-
            Options {
-
                open,
-
                app_url,
-
                listen: listen.unwrap_or(SocketAddr::new(
-
                    IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
-
                    8080,
-
                )),
-
                path,
-
                connect,
-
            },
-
            vec![],
-
        ))
-
    }
-
}
-

-
pub fn sign(signer: Box<dyn Signer>, session: &SessionInfo) -> Result<Signature, anyhow::Error> {
-
    signer
-
        .try_sign(format!("{}:{}", session.session_id, session.public_key).as_bytes())
-
        .map_err(anyhow::Error::from)
-
}
-

-
pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
-
    let profile = ctx.profile()?;
-
    let runtime_and_handle = if options.connect.is_none() {
-
        tracing_subscriber::fmt::init();
-

-
        let runtime = tokio::runtime::Builder::new_multi_thread()
-
            .enable_all()
-
            .build()
-
            .expect("failed to create threaded runtime");
-
        let httpd_handle = runtime.spawn(crate::run(crate::Options {
-
            aliases: Default::default(),
-
            listen: options.listen,
-
            cache: None,
-
        }));
-
        Some((runtime, httpd_handle))
-
    } else {
-
        None
-
    };
-

-
    let mut retries = 30;
-
    let connect = options.connect.unwrap_or(options.listen);
-
    let response = loop {
-
        retries -= 1;
-
        sleep(Duration::from_millis(100));
-

-
        match ureq::post(&format!("http://{connect}/api/v1/sessions")).call() {
-
            Ok(response) => {
-
                break response;
-
            }
-
            Err(err) => {
-
                if err.kind() == ureq::ErrorKind::ConnectionFailed && retries > 0 {
-
                    continue;
-
                } else {
-
                    anyhow::bail!(err);
-
                }
-
            }
-
        }
-
    };
-

-
    let session = response.into_json::<SessionInfo>()?;
-
    let signer = profile.signer()?;
-
    let signature = sign(signer, &session)?;
-

-
    let mut auth_url = options.app_url.clone();
-
    auth_url
-
        .path_segments_mut()
-
        .map_err(|_| anyhow!("URL not supported"))?
-
        .push("session")
-
        .push(&session.session_id);
-

-
    auth_url
-
        .query_pairs_mut()
-
        .append_pair("pk", &session.public_key.to_string())
-
        .append_pair("sig", &signature.to_string())
-
        .append_pair("addr", &connect.to_string());
-

-
    let pathname = radicle::rad::cwd().ok().and_then(|(_, rid)| {
-
        Url::parse(
-
            &profile
-
                .config
-
                .public_explorer
-
                .url(options.listen, rid)
-
                .to_string(),
-
        )
-
        .map(|x| x[Position::BeforePath..].to_string())
-
        .ok()
-
    });
-
    if let Some(path) = options.path.or(pathname) {
-
        auth_url.query_pairs_mut().append_pair("path", &path);
-
    }
-

-
    if options.open {
-
        #[cfg(any(target_os = "freebsd", target_os = "windows"))]
-
        let cmd_name = "echo";
-
        #[cfg(target_os = "macos")]
-
        let cmd_name = "open";
-
        #[cfg(target_os = "linux")]
-
        let cmd_name = "xdg-open";
-

-
        let mut cmd = Command::new(cmd_name);
-
        match cmd.arg(auth_url.as_str()).spawn() {
-
            Ok(mut child) => match child.wait() {
-
                Ok(exit_status) => {
-
                    if exit_status.success() {
-
                        term::success!("Opened {auth_url}");
-
                    } else {
-
                        term::info!("Visit {auth_url} to connect");
-
                    }
-
                }
-
                Err(_) => {
-
                    term::info!("Visit {auth_url} to connect");
-
                }
-
            },
-
            Err(_) => {
-
                term::error(format!("Could not open web browser via `{cmd_name}`"));
-
                term::hint("Use `rad web --no-open` if this continues");
-
                term::info!("Visit {auth_url} to connect");
-
            }
-
        }
-
    } else {
-
        term::info!("Visit {auth_url} to connect");
-
    }
-

-
    if let Some((runtime, httpd_handle)) = runtime_and_handle {
-
        runtime
-
            .block_on(httpd_handle)?
-
            .context("httpd server error")?;
-
    }
-

-
    Ok(())
-
}
modified radicle-httpd/src/lib.rs
@@ -1,7 +1,6 @@
#![allow(clippy::type_complexity)]
#![allow(clippy::too_many_arguments)]
#![recursion_limit = "256"]
-
pub mod commands;
pub mod error;

use std::collections::HashMap;