diff --git a/Cargo.lock b/Cargo.lock index d348ec3..eea2958 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,7 +28,7 @@ dependencies = [ [[package]] name = "allegedly" -version = "0.2.1" +version = "0.3.0" dependencies = [ "anyhow", "async-compression", diff --git a/Cargo.toml b/Cargo.toml index 18b3ffd..f412dba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "allegedly" description = "public ledger server tools and services (for the PLC)" license = "MIT OR Apache-2.0" -version = "0.2.1" +version = "0.3.0" edition = "2024" default-run = "allegedly" diff --git a/readme.md b/readme.md index 96dcc6e..6f1e0bf 100644 --- a/readme.md +++ b/readme.md @@ -26,9 +26,14 @@ Allegedly can sudo allegedly mirror \ --upstream "https://plc.directory" \ --wrap "http://127.0.0.1:3000" \ + --wrap-pg-cert "/opt/allegedly/postgres-cert.pem" \ --acme-domain "plc.wtf" \ + --acme-domain "alt.plc.wtf" \ + --experimental-acme-domain "experimental.plc.wtf" \ --acme-cache-path ./acme-cache \ - --acme-directory-url "https://acme-staging-v02.api.letsencrypt.org/directory" + --acme-directory-url "https://acme-staging-v02.api.letsencrypt.org/directory" \ + --acme-ipv6 \ + --experimental-write-upstream ``` @@ -68,11 +73,11 @@ to install the latest from source: ### new things -- experimental: websocket version of /export -- experimental: accept writes by forwarding them upstream -- experimental: serve a tlog -- experimental: embed a log database directly for fast and efficient mirroring -- experimental: support multiple upstreams? +- [ ] experimental: websocket version of /export +- [x] experimental: accept writes by forwarding them upstream +- [ ] experimental: serve a tlog +- [ ] experimental: embed a log database directly for fast and efficient mirroring +- [ ] experimental: support multiple upstreams? - [ ] new command todo: `zip` or `check` or `diff`: compare two plc logs over some time range - [ ] new command to consider: `scatter` or something: broadcast plc writes to multiple upstreams diff --git a/src/mirror.rs b/src/mirror.rs index cb05356..dafac67 100644 --- a/src/mirror.rs +++ b/src/mirror.rs @@ -25,7 +25,29 @@ struct State { } #[handler] -fn hello(Data(State { upstream, .. }): Data<&State>) -> String { +fn hello( + Data(State { + upstream, + experimental: exp, + .. + }): Data<&State>, + req: &Request, +) -> String { + let post_info = match (exp.write_upstream, &exp.acme_domain, req.uri().host()) { + (false, _, _) => " - POST /* Always rejected. This is a mirror.".to_string(), + (_, None, _) => { + " - POST /:did Create a PLC op. Allegedly will forward it upstream.".to_string() + } + (_, Some(d), Some(f)) if f == d => { + " - POST /:did Create a PLC op. Allegedly will forward it upstream.".to_string() + } + (_, Some(d), _) => format!( + r#"\ + - POST /* Rejected, but experimental upstream op forwarding is + available at `POST {d}/:did`!"# + ), + }; + format!( r#"{} @@ -45,10 +67,9 @@ Available APIs: - GET /* Proxies to wrapped server; see PLC API docs: https://web.plc.directory/api/redoc - - POST /* Always rejected. This is a mirror. - + tip: try `GET /{{did}}` to resolve an identity - tip: try `GET /{{did}}` to resolve an identity +{post_info} Allegedly is a suite of open-source CLI tools from for working with PLC logs,