The default port is 7654, not 3000
Browse files at this commitd75fca77ddeb0686c46d7298cfee993cd9895ff0Parent: 304b2a9- fix
- the default port is 7654, not 3000
2 changed files +23 -17
- config/izlek.toml +1 -1
- crates/izlek-core/src/config.rs +22 -16
config/izlek.tomlmodified+1 -1
| @@ -3,4 +3,4 @@ database = "izlek.db" | ||
| 3 | 3 | # The address the server listens on. Environment variables are ignored — |
| 4 | 4 | # this is the only thing that decides where Izlek binds. It is also the |
| 5 | 5 | # address mail links fall back to, until an admin sets one in Settings. |
| 6 | -listen = "127.0.0.1:3000" | |
| 6 | +listen = "127.0.0.1:7654" |
crates/izlek-core/src/config.rsmodified+22 -16
| @@ -50,12 +50,18 @@ database = "izlek.db" | ||
| 50 | 50 | # The address the server listens on. Environment variables are ignored — |
| 51 | 51 | # this is the only thing that decides where Izlek binds. It is also the |
| 52 | 52 | # address mail links fall back to, until an admin sets one in Settings. |
| 53 | -listen = "127.0.0.1:3000" | |
| 53 | +listen = "127.0.0.1:7654" | |
| 54 | 54 | "#; |
| 55 | 55 | |
| 56 | 56 | /// The default `listen` when the file is silent about it. A file missing this |
| 57 | 57 | /// key is completed with it on the next boot, so the silence lasts one run. |
| 58 | -const DEFAULT_LISTEN: &str = "127.0.0.1:3000"; | |
| 58 | +/// | |
| 59 | +/// 7654 rather than a round number: 3000, 4000, 5000, 8000 and 8080 are what | |
| 60 | +/// every other thing on a developer's machine already took, and a first run | |
| 61 | +/// that dies on "address already in use" is a first run that teaches nothing. | |
| 62 | +/// This one is unassigned in IANA's registry and sits below the ephemeral | |
| 63 | +/// range, so the kernel never hands it to an outgoing connection either. | |
| 64 | +const DEFAULT_LISTEN: &str = "127.0.0.1:7654"; | |
| 59 | 65 | |
| 60 | 66 | /// Every optional key, with the comment and default a file missing it is |
| 61 | 67 | /// completed with. `database` is not here: it has no default worth guessing, |
| @@ -66,7 +72,7 @@ const OPTIONAL_KEYS: &[(&str, &str)] = &[( | ||
| 66 | 72 | "# The address the server listens on. Environment variables are ignored —\n", |
| 67 | 73 | "# this is the only thing that decides where Izlek binds. It is also the\n", |
| 68 | 74 | "# address mail links fall back to, until an admin sets one in Settings.\n", |
| 69 | - "listen = \"127.0.0.1:3000\"\n" | |
| 75 | + "listen = \"127.0.0.1:7654\"\n" | |
| 70 | 76 | ), |
| 71 | 77 | )]; |
| 72 | 78 | |
| @@ -342,8 +348,8 @@ mod tests { | ||
| 342 | 348 | assert!(config.defaulted); |
| 343 | 349 | assert!(config.database.is_absolute(), "{:?}", config.database); |
| 344 | 350 | assert!(config.database.ends_with("izlek.db")); |
| 345 | - assert_eq!(config.listen, "127.0.0.1:3000".parse().unwrap()); | |
| 346 | - assert_eq!(config.listen_url(), "http://127.0.0.1:3000"); | |
| 351 | + assert_eq!(config.listen, "127.0.0.1:7654".parse().unwrap()); | |
| 352 | + assert_eq!(config.listen_url(), "http://127.0.0.1:7654"); | |
| 347 | 353 | |
| 348 | 354 | let written = std::fs::read_to_string(dir.join(FILE_NAME)).unwrap(); |
| 349 | 355 | assert_eq!(written, DEVELOPMENT_DEFAULTS); |
| @@ -369,10 +375,10 @@ mod tests { | ||
| 369 | 375 | .unwrap(); |
| 370 | 376 | |
| 371 | 377 | let config = Config::load_from(&dir).unwrap(); |
| 372 | - assert_eq!(config.listen, "127.0.0.1:3000".parse().unwrap()); | |
| 378 | + assert_eq!(config.listen, "127.0.0.1:7654".parse().unwrap()); | |
| 373 | 379 | |
| 374 | 380 | let written = std::fs::read_to_string(dir.join(FILE_NAME)).unwrap(); |
| 375 | - assert!(written.contains("listen = \"127.0.0.1:3000\""), "{written}"); | |
| 381 | + assert!(written.contains("listen = \"127.0.0.1:7654\""), "{written}"); | |
| 376 | 382 | // What was there is untouched, comment and all. |
| 377 | 383 | assert!(written.starts_with("# mine\ndatabase = \"state/izlek.db\"\n"), "{written}"); |
| 378 | 384 | |
| @@ -404,7 +410,7 @@ mod tests { | ||
| 404 | 410 | #[test] |
| 405 | 411 | fn a_missing_key_names_itself_rather_than_guessing() { |
| 406 | 412 | let problem = |
| 407 | - Config::parse("listen = \"127.0.0.1:3000\"\n", Path::new("."), false).unwrap_err(); | |
| 413 | + Config::parse("listen = \"127.0.0.1:7654\"\n", Path::new("."), false).unwrap_err(); | |
| 408 | 414 | assert_eq!(problem, ConfigError::Missing("database")); |
| 409 | 415 | let said = problem.to_string(); |
| 410 | 416 | assert!(said.contains("database"), "{said}"); |
| @@ -436,12 +442,12 @@ mod tests { | ||
| 436 | 442 | let _ = std::fs::remove_dir_all(&dir); |
| 437 | 443 | } |
| 438 | 444 | |
| 439 | - /// A file written before `listen` existed still loads, and still binds | |
| 440 | - /// where it always did. | |
| 445 | + /// A file that does not mention `listen` still loads, and binds at the | |
| 446 | + /// default it is about to be completed with. | |
| 441 | 447 | #[test] |
| 442 | - fn a_file_without_listen_falls_back_to_the_old_default() { | |
| 448 | + fn a_file_without_listen_takes_the_default() { | |
| 443 | 449 | let config = Config::parse("database = \"/srv/izlek.db\"\n", Path::new("."), false).unwrap(); |
| 444 | - assert_eq!(config.listen, "127.0.0.1:3000".parse().unwrap()); | |
| 450 | + assert_eq!(config.listen, "127.0.0.1:7654".parse().unwrap()); | |
| 445 | 451 | } |
| 446 | 452 | |
| 447 | 453 | #[test] |
| @@ -471,16 +477,16 @@ mod tests { | ||
| 471 | 477 | .unwrap() |
| 472 | 478 | .listen_url() |
| 473 | 479 | }; |
| 474 | - assert_eq!(url("127.0.0.1:3000"), "http://127.0.0.1:3000"); | |
| 480 | + assert_eq!(url("127.0.0.1:7654"), "http://127.0.0.1:7654"); | |
| 475 | 481 | assert_eq!(url("192.168.1.20:8080"), "http://192.168.1.20:8080"); |
| 476 | 482 | // Port 80 is the one a URL does not say. |
| 477 | 483 | assert_eq!(url("10.0.0.4:80"), "http://10.0.0.4"); |
| 478 | 484 | // A bind that names no interface is reachable by no name, so the |
| 479 | 485 | // loopback stands in: a link somebody on the box can click beats a |
| 480 | 486 | // link nobody can. |
| 481 | - assert_eq!(url("0.0.0.0:3000"), "http://127.0.0.1:3000"); | |
| 482 | - assert_eq!(url("[::]:3000"), "http://127.0.0.1:3000"); | |
| 483 | - assert_eq!(url("[::1]:3000"), "http://[::1]:3000"); | |
| 487 | + assert_eq!(url("0.0.0.0:7654"), "http://127.0.0.1:7654"); | |
| 488 | + assert_eq!(url("[::]:7654"), "http://127.0.0.1:7654"); | |
| 489 | + assert_eq!(url("[::1]:7654"), "http://[::1]:7654"); | |
| 484 | 490 | } |
| 485 | 491 | |
| 486 | 492 | /// The sender used to be environment variables read directly, and the |