diff --git a/README.md b/README.md index 0b5871e..a7401d9 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ faery-ring /path/to/domains.txt docker run -v /path/to/domains.txt:/domains.txt -p 3243:3243 alch0emi/faery-ring ``` -Right now, Faery Ring always binds to port 3243, but this might change in the future, who knows. Anyway, now you can point your webserver at Faery Ring! The config below is for Caddy, but any webserver that supports reverse proxies will work! +You can also use the `-p ` flag to tell faery-ring what port you want to bind on. If you don't, it'll pick port `3243`. Anyway, now you can point your webserver at Faery Ring! The config below is for Caddy, but any webserver that supports reverse proxies will work! ```Caddyfile your.web.site { diff --git a/src/main.rs b/src/main.rs index 6804657..5a57ad2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,7 +72,7 @@ fn main() { // // Step 2: Run the server // - server::go(&domains); + server::go(&domains, args.port); } #[derive(argh::FromArgs)] @@ -81,4 +81,8 @@ struct CommandlineArgs { /// a text file listing all domains in the ring, one per line #[argh(positional)] domains: PathBuf, + + /// the port to bind to (default: 3243) + #[argh(option, short='p', default="3243")] + port: u16, } diff --git a/src/server.rs b/src/server.rs index 8f135cf..98fc577 100644 --- a/src/server.rs +++ b/src/server.rs @@ -11,8 +11,8 @@ use tiny_http::StatusCode; /// /// Runs the server in a single thread, bound to port 3243. Requests are handled /// first-come, first-serve -pub fn go(domains: &[&str]) { - let server = Server::http("0.0.0.0:3243").unwrap(); +pub fn go(domains: &[&str], port: u16) { + let server = Server::http(("0.0.0.0", port)).unwrap(); println!("Running on 0.0.0.0:3243");