mirror of
https://github.com/YGGverse/btracker.git
synced 2026-03-31 17:15:31 +00:00
add custom host/port argument options
This commit is contained in:
parent
bab40bd677
commit
0d155d6ef2
2 changed files with 17 additions and 1 deletions
|
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue