add custom host/port argument options

This commit is contained in:
yggverse 2025-08-05 02:49:47 +03:00
parent bab40bd677
commit 0d155d6ef2
2 changed files with 17 additions and 1 deletions

View file

@ -1,5 +1,8 @@
use clap::Parser; use clap::Parser;
use std::path::PathBuf; use std::{
net::{IpAddr, Ipv4Addr},
path::PathBuf,
};
use url::Url; use url::Url;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
@ -32,4 +35,12 @@ pub struct Config {
/// Appends following tracker(s) to the magnet links /// Appends following tracker(s) to the magnet links
#[arg(long)] #[arg(long)]
pub tracker: Option<Vec<Url>>, pub tracker: Option<Vec<Url>>,
/// Bind server on given host
#[arg(long, short, default_value_t = IpAddr::V4(Ipv4Addr::LOCALHOST))]
pub address: IpAddr,
/// Bind server on given port
#[arg(long, short, default_value_t = 8000)]
pub port: u16,
} }

View file

@ -47,6 +47,11 @@ fn rocket() -> _ {
); );
let storage = Storage::init(config.storage, config.limit, config.capacity).unwrap(); // @TODO handle let storage = Storage::init(config.storage, config.limit, config.capacity).unwrap(); // @TODO handle
rocket::build() rocket::build()
.configure(rocket::Config {
port: config.port,
address: config.address,
..rocket::Config::debug_default()
})
.manage(feed) .manage(feed)
.manage(storage) .manage(storage)
.mount("/", routes![index, rss]) .mount("/", routes![index, rss])