diff --git a/Cargo.toml b/Cargo.toml index 3568da1..767a950 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,6 @@ name = "ptth" version = "0.1.0" authors = ["Trish"] edition = "2018" -license-file = "COPYING" license = "AGPL-3.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -23,5 +22,6 @@ regex = "1.4.1" reqwest = { version = "0.10.8", features = ["stream"] } rmp-serde = "0.14.4" serde = {version = "1.0.117", features = ["derive"]} +structopt = "0.3.20" tokio = { version = "0.2.22", features = ["full"] } ulid = "0.4.1" diff --git a/src/bin/server.rs b/src/bin/server.rs index 4220f91..b142c39 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -1,11 +1,30 @@ -use std::error::Error; +use std::{ + error::Error, + path::PathBuf, +}; + +use structopt::StructOpt; + +#[derive (Debug, StructOpt)] +struct Opt { + #[structopt (name = "RELAY_URL")] + relay_url: String, + + #[structopt (name = "SERVER_NAME")] + server_name: String, + + #[structopt (long)] + file_server_root: Option , +} #[tokio::main] async fn main () -> Result <(), Box > { + let opt = Opt::from_args (); + let opt = ptth::server::Opt { - relay_url: "http://127.0.0.1:4000".into (), - server_name: "alien_wildlands".into (), - file_server_root: "/home/user".into (), + relay_url: opt.relay_url, + server_name: opt.server_name, + file_server_root: opt.file_server_root.unwrap_or ("/home/user".into ()), }; ptth::server::main (opt).await diff --git a/todo.md b/todo.md index f9b04b1..b356638 100644 --- a/todo.md +++ b/todo.md @@ -1,11 +1,8 @@ -- Parameter for server URL -- Parameter for static file serve path -- Parameter for server name +- Fix possible timing gap when refreshing http_listen - Set up tokens or privkeys or tripcodes or something so clients can't trivially impersonate servers - Prevent directory traversal attacks -- Fix possible timing gap when refreshing http_listen (Just have client wait a few seconds?) - Error handling - Reverse proxy to other local servers