Skip to content

Commit b27cb36

Browse files
committed
Only accept port values in the correct range and improve bind call
1 parent 84d9422 commit b27cb36

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

server/src/bin/taskchampion-sync-server.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn command() -> Command {
2323
.arg(
2424
arg!(-p --port <PORT> "Port on which to serve")
2525
.help("Port on which to serve")
26-
.value_parser(value_parser!(usize))
26+
.value_parser(value_parser!(u16))
2727
.default_value("8080"),
2828
)
2929
.arg(
@@ -62,7 +62,7 @@ async fn main() -> anyhow::Result<()> {
6262
let matches = command().get_matches();
6363

6464
let data_dir: &OsString = matches.get_one("data-dir").unwrap();
65-
let port: usize = *matches.get_one("port").unwrap();
65+
let port: u16 = *matches.get_one("port").unwrap();
6666
let snapshot_versions: u32 = *matches.get_one("snapshot-versions").unwrap();
6767
let snapshot_days: i64 = *matches.get_one("snapshot-days").unwrap();
6868
let client_id_allowlist: Option<HashSet<Uuid>> = matches
@@ -82,7 +82,7 @@ async fn main() -> anyhow::Result<()> {
8282
.wrap(Logger::default())
8383
.configure(|cfg| server.config(cfg))
8484
})
85-
.bind(format!("0.0.0.0:{}", port))?
85+
.bind(("0.0.0.0", port))?
8686
.run()
8787
.await?;
8888
Ok(())

0 commit comments

Comments
 (0)