65 lines
1.8 KiB
Rust
65 lines
1.8 KiB
Rust
use clap::Parser as _;
|
|
|
|
mod args;
|
|
mod config;
|
|
mod log;
|
|
mod server;
|
|
|
|
mod consts {
|
|
pub static TEMPLATE_CFG: &str = include_str!("../data/example-config.toml");
|
|
}
|
|
|
|
fn main() -> anyhow::Result<()> {
|
|
let args = args::Args::parse();
|
|
log::state::set_log_level(args.loglevel);
|
|
|
|
match args.command {
|
|
args::Command::Serve {
|
|
config_path,
|
|
listen,
|
|
} => {
|
|
use server::{ServeArgs, run_server};
|
|
|
|
let config = config::Config::open(config_path)?;
|
|
|
|
#[cfg(debug_assertions)]
|
|
crate::log::macros::trace!("{config:#?}");
|
|
|
|
let rt = tokio::runtime::Builder::new_multi_thread()
|
|
.enable_all()
|
|
.build()?;
|
|
|
|
rt.block_on(async { run_server(ServeArgs { listen }, config).await })?;
|
|
}
|
|
args::Command::Features => {
|
|
let http2 = cfg!(feature = "http2");
|
|
let compress = cfg!(feature = "compress");
|
|
|
|
let http2_req = cfg!(feature = "http2-req");
|
|
let compress_req = cfg!(feature = "compress-req");
|
|
|
|
let native_tls = cfg!(feature = "native-tls");
|
|
let rustls = cfg!(feature = "rustls");
|
|
|
|
println!(
|
|
"Server Features:\
|
|
\n http2 enabled: {http2}\
|
|
\n compress enabled: {compress}\
|
|
\n\
|
|
\nRequest Features:\
|
|
\n http2-req enabled: {http2_req}\
|
|
\n compress-req enabled: {compress_req}\
|
|
\n\
|
|
\n TLS Features:\
|
|
\n native-tls enabled = {native_tls}\
|
|
\n rustls enabled = {rustls}"
|
|
);
|
|
}
|
|
args::Command::TemplateConfig => {
|
|
println!("{}", consts::TEMPLATE_CFG);
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|