mirror of
https://github.com/YGGverse/agate.git
synced 2026-04-08 20:45:29 +00:00
add central configuration mode
also slight correction of the documentation because we are now using YAML (a space is now required behind the colon)
This commit is contained in:
parent
8fd9ca15c3
commit
bd9ed3255a
4 changed files with 36 additions and 12 deletions
29
src/main.rs
29
src/main.rs
|
|
@ -9,8 +9,15 @@ use {
|
|||
Certificate, NoClientAuth, PrivateKey, ServerConfig,
|
||||
},
|
||||
std::{
|
||||
borrow::Cow, error::Error, ffi::OsStr, fmt::Write, fs::File, io::BufReader,
|
||||
net::SocketAddr, path::Path, sync::Arc,
|
||||
borrow::Cow,
|
||||
error::Error,
|
||||
ffi::OsStr,
|
||||
fmt::Write,
|
||||
fs::File,
|
||||
io::BufReader,
|
||||
net::SocketAddr,
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
},
|
||||
tokio::{
|
||||
io::{AsyncReadExt, AsyncWriteExt},
|
||||
|
|
@ -67,7 +74,7 @@ static ARGS: Lazy<Args> = Lazy::new(|| {
|
|||
|
||||
struct Args {
|
||||
addrs: Vec<SocketAddr>,
|
||||
content_dir: String,
|
||||
content_dir: PathBuf,
|
||||
cert_chain: Vec<Certificate>,
|
||||
key: PrivateKey,
|
||||
hostnames: Vec<Host>,
|
||||
|
|
@ -76,6 +83,7 @@ struct Args {
|
|||
serve_secret: bool,
|
||||
log_ips: bool,
|
||||
only_tls13: bool,
|
||||
central_config: bool,
|
||||
}
|
||||
|
||||
fn args() -> Result<Args> {
|
||||
|
|
@ -130,6 +138,11 @@ fn args() -> Result<Args> {
|
|||
"Enable serving secret files (files/directories starting with a dot)",
|
||||
);
|
||||
opts.optflag("", "log-ip", "Output IP addresses when logging");
|
||||
opts.optflag(
|
||||
"C",
|
||||
"central-conf",
|
||||
"Use a central .meta file in the content root directory.",
|
||||
);
|
||||
|
||||
let matches = opts.parse(&args[1..]).map_err(|f| f.to_string())?;
|
||||
if matches.opt_present("h") {
|
||||
|
|
@ -176,14 +189,16 @@ fn args() -> Result<Args> {
|
|||
serve_secret: matches.opt_present("serve-secret"),
|
||||
log_ips: matches.opt_present("log-ip"),
|
||||
only_tls13: matches.opt_present("only-tls13"),
|
||||
central_config: matches.opt_present("central-conf"),
|
||||
})
|
||||
}
|
||||
|
||||
fn check_path(s: String) -> Result<String, String> {
|
||||
if Path::new(&s).exists() {
|
||||
Ok(s)
|
||||
fn check_path(s: String) -> Result<PathBuf, String> {
|
||||
let p = PathBuf::from(s);
|
||||
if p.as_path().exists() {
|
||||
Ok(p)
|
||||
} else {
|
||||
Err(format!("No such file: {}", s))
|
||||
Err(format!("No such file: {:?}", p))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue