[control] Fix round 2: Caddy rereads its files on every load and the served certificate is checked, Caddy trials get a deadline outside control (caddy-guard, caddy-revert), the watch under Caddy judges upstreams as edge does, a reload of Caddy during the watch is noticed and device changes wait for the apply, stricter root key scan, IPv4-mapped trusted proxies
This commit is contained in:
@@ -30,7 +30,8 @@ fn usage() -> ExitCode {
|
||||
eprintln!(
|
||||
"usage: ianitor-control --config <control.toml> | --dev [--edge-bin <path>] | \
|
||||
token create --name <name> [--expires-days <n> | --never] (--config <c> | --state-dir <d>) | \
|
||||
token list (...) | token revoke <id> (...) | openapi | check --config <c>"
|
||||
token list (...) | token revoke <id> (...) | openapi | check --config <c> | \
|
||||
caddy-revert --config <c> | caddy-guard --config <c>"
|
||||
);
|
||||
ExitCode::from(2)
|
||||
}
|
||||
@@ -395,6 +396,27 @@ fn main() -> ExitCode {
|
||||
Ok(())
|
||||
}
|
||||
Some("check") => state_dir(&args[1..]).map(|_| eprintln!("config is valid")),
|
||||
// Caddy trial deadline (ianitor_control::caddy_guard): after control stops, and the guard.
|
||||
Some(verb @ ("caddy-revert" | "caddy-guard")) => match args
|
||||
.iter()
|
||||
.position(|a| a == "--config")
|
||||
.and_then(|i| args.get(i + 1))
|
||||
{
|
||||
Some(p) => match Config::load(&PathBuf::from(p)) {
|
||||
Ok(cfg) if verb == "caddy-guard" => {
|
||||
rt.block_on(ianitor_control::caddy_guard::run(cfg))
|
||||
}
|
||||
Ok(cfg) => rt
|
||||
.block_on(ianitor_control::caddy_guard::revert_after_stop(&cfg))
|
||||
.map(|done| {
|
||||
if done {
|
||||
eprintln!("Caddy is back on the last good config.");
|
||||
}
|
||||
}),
|
||||
Err(e) => Err(e.to_string()),
|
||||
},
|
||||
None => return usage(),
|
||||
},
|
||||
Some("--dev") => rt.block_on(dev::run(&args[1..])),
|
||||
Some("--config") => match args.get(1) {
|
||||
Some(p) => match Config::load(&PathBuf::from(p)) {
|
||||
|
||||
Reference in New Issue
Block a user