[edge] Proxy: Pingora data plane with SNI certs, forward-auth, header rules, health checks, ACME
This commit is contained in:
+56
-4
@@ -2,9 +2,61 @@
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
//! ianitor-edge binary (not implemented yet).
|
||||
//! `ianitor-edge --config <edge.json> [--check] [--acme-root <ca.pem>]`
|
||||
//!
|
||||
//! Secrets come from `$CREDENTIALS_DIRECTORY`; the log level from `$IANITOR_LOG`
|
||||
//! (error, warn, info, debug, trace; libraries are capped at info).
|
||||
|
||||
fn main() -> std::process::ExitCode {
|
||||
eprintln!("ianitor-edge: not implemented yet");
|
||||
std::process::ExitCode::from(2)
|
||||
use std::path::PathBuf;
|
||||
use std::process::ExitCode;
|
||||
|
||||
use ianitor_edge::{EdgeError, Options};
|
||||
|
||||
fn parse_args() -> Result<(Options, bool), EdgeError> {
|
||||
let mut opts = Options::default();
|
||||
let mut check = false;
|
||||
let mut config = None;
|
||||
let mut args = std::env::args_os().skip(1);
|
||||
while let Some(a) = args.next() {
|
||||
match a.to_str() {
|
||||
Some("--config") => config = args.next().map(PathBuf::from),
|
||||
Some("--acme-root") => opts.acme_root = args.next().map(PathBuf::from),
|
||||
Some("--check") => check = true,
|
||||
Some("--help" | "-h") => {
|
||||
println!(
|
||||
"usage: ianitor-edge --config <edge.json> [--check] [--acme-root <ca.pem>]"
|
||||
);
|
||||
std::process::exit(0);
|
||||
}
|
||||
_ => {
|
||||
return Err(EdgeError::Usage(format!(
|
||||
"unknown argument {}",
|
||||
a.to_string_lossy()
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
opts.config =
|
||||
config.ok_or_else(|| EdgeError::Usage("--config <edge.json> is required".into()))?;
|
||||
Ok((opts, check))
|
||||
}
|
||||
|
||||
fn main() -> ExitCode {
|
||||
ianitor_edge::logging::init(std::env::var("IANITOR_LOG").ok().as_deref());
|
||||
let started = parse_args().and_then(|(opts, check)| {
|
||||
let rt = ianitor_edge::prepare(&opts)?;
|
||||
log::info!(target: "ianitor::edge", "config {} loaded: {} hosts", opts.config.display(), rt.hosts.len());
|
||||
if check {
|
||||
return Ok(None);
|
||||
}
|
||||
ianitor_edge::server(rt, &opts).map(Some)
|
||||
});
|
||||
match started {
|
||||
Ok(None) => ExitCode::SUCCESS,
|
||||
Ok(Some(server)) => server.run_forever(),
|
||||
Err(e) => {
|
||||
log::error!(target: "ianitor::edge", "{e}");
|
||||
ExitCode::FAILURE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user