···77- Tail PLC ops to stdout: `allegedly tail | jq`
88- Export PLC ops to weekly gzipped bundles: `allegdly bundle --dest ./some-folder`
99- Dump bundled ops to stdout FAST: `allegedly backfill --source-workers 6 | pv -l > /ops-unordered.jsonl`
1010-- Wrap the reference PLC server and run it as a mirror:
1010+- Wrap the reference PLC server and run it as a mirror, copying ops from upstream:
11111212 ```bash
1313+ allegedly mirror \
1414+ --wrap "http://127.0.0.1:3000" \
1515+ --wrap-pg "postgresql://user:pass@pg-host:5432/plc-db"
1616+ ```
1717+1818+- Wrap a plc server, maximalist edition:
1919+2020+ ```bash
2121+ # put sensitive values in environment so they don't leak via process name.
1322 export ALLEGEDLY_WRAP_PG="postgresql://user:pass@pg-host:5432/plc-db"
1414- allegedly --upstream "https://plc.directory" mirror \
1515- --bind "0.0.0.0:8000" \
1616- --wrap "http://127.0.0.1:3000"
1717- ```
18231919-(add `--help` to any command for more info about it)
2424+ # sudo to bind :80 + :443 for acme tls, but it's better to give user net cap.
2525+ # will try to autoprovision cert for "plc.wtf" from letsencrypt staging.
2626+ sudo allegedly mirror \
2727+ --upstream "https://plc.directory" \
2828+ --wrap "http://127.0.0.1:3000" \
2929+ --acme-domain "plc.wtf" \
3030+ --acme-cache-dir ./acme-cache \
3131+ --acme-directory-url "https://acme-staging-v02.api.letsencrypt.org/directory"
3232+ ```
3333+3434+3535+add `--help` to any command for more info about it
203621372238## install
+28
src/mirror.rs
···230230 auto_cert = auto_cert.domain(domain);
231231 }
232232 let auto_cert = auto_cert.build().expect("acme config to build");
233233+234234+ run_insecure_notice();
233235 run(app, TcpListener::bind("0.0.0.0:443").acme(auto_cert)).await
234236 }
235237 ListenConf::Bind(addr) => run(app, TcpListener::bind(addr)).await,
···246248 .run(app)
247249 .await
248250}
251251+252252+/// kick off a tiny little server on a tokio task to tell people to use 443
253253+fn run_insecure_notice() {
254254+ #[handler]
255255+ fn oop_plz_be_secure() -> (StatusCode, String) {
256256+ (
257257+ StatusCode::BAD_REQUEST,
258258+ format!(
259259+ r#"{}
260260+261261+You probably want to change your request to use HTTPS instead of HTTP.
262262+"#,
263263+ logo("mirror (tls on 443 please)")
264264+ ),
265265+ )
266266+ }
267267+268268+ let app = Route::new().at("/", get(oop_plz_be_secure)).with(Tracing);
269269+ let listener = TcpListener::bind("0.0.0.0:80");
270270+ tokio::task::spawn(async move {
271271+ Server::new(listener)
272272+ .name("allegedly (mirror:80 helper)")
273273+ .run(app)
274274+ .await
275275+ });
276276+}