forge
Explore
Log in

Don't you dare go Hollow

The default port is 7654, not 3000

Browse files at this commit

d75fca77ddeb0686c46d7298cfee993cd9895ff0Ahmet Kaan GümüşParent: 304b2a9
  • fix
    • the default port is 7654, not 3000
Show full message
🎨 fix(config): the default port is 7654, not 3000

3000 is what every other thing on a developer's machine already took, and a
first run that dies on "address already in use" teaches nothing. 7654 is
unassigned in IANA's registry and sits below the ephemeral range, so the
kernel never hands it to an outgoing connection either.
config/izlek.tomlmodified+1 -1
@@ -3,4 +3,4 @@ database = "izlek.db"
3 # The address the server listens on. Environment variables are ignored —3 # The address the server listens on. Environment variables are ignored —
4 # this is the only thing that decides where Izlek binds. It is also the4 # this is the only thing that decides where Izlek binds. It is also the
5 # address mail links fall back to, until an admin sets one in Settings.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 # The address the server listens on. Environment variables are ignored —50 # The address the server listens on. Environment variables are ignored —
51 # this is the only thing that decides where Izlek binds. It is also the51 # this is the only thing that decides where Izlek binds. It is also the
52 # address mail links fall back to, until an admin sets one in Settings.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 /// The default `listen` when the file is silent about it. A file missing this56 /// The default `listen` when the file is silent about it. A file missing this
57 /// key is completed with it on the next boot, so the silence lasts one run.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 /// Every optional key, with the comment and default a file missing it is66 /// Every optional key, with the comment and default a file missing it is
61 /// completed with. `database` is not here: it has no default worth guessing,67 /// completed with. `database` is not here: it has no default worth guessing,
@@ -66,7 +72,7 @@ const OPTIONAL_KEYS: &[(&str, &str)] = &[(
66 "# The address the server listens on. Environment variables are ignored —\n",72 "# The address the server listens on. Environment variables are ignored —\n",
67 "# this is the only thing that decides where Izlek binds. It is also the\n",73 "# this is the only thing that decides where Izlek binds. It is also the\n",
68 "# address mail links fall back to, until an admin sets one in Settings.\n",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 assert!(config.defaulted);348 assert!(config.defaulted);
343 assert!(config.database.is_absolute(), "{:?}", config.database);349 assert!(config.database.is_absolute(), "{:?}", config.database);
344 assert!(config.database.ends_with("izlek.db"));350 assert!(config.database.ends_with("izlek.db"));
345- assert_eq!(config.listen, "127.0.0.1:3000".parse().unwrap());351+ assert_eq!(config.listen, "127.0.0.1:7654".parse().unwrap());
346- assert_eq!(config.listen_url(), "http://127.0.0.1:3000");352+ assert_eq!(config.listen_url(), "http://127.0.0.1:7654");
347 353
348 let written = std::fs::read_to_string(dir.join(FILE_NAME)).unwrap();354 let written = std::fs::read_to_string(dir.join(FILE_NAME)).unwrap();
349 assert_eq!(written, DEVELOPMENT_DEFAULTS);355 assert_eq!(written, DEVELOPMENT_DEFAULTS);
@@ -369,10 +375,10 @@ mod tests {
369 .unwrap();375 .unwrap();
370 376
371 let config = Config::load_from(&dir).unwrap();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 let written = std::fs::read_to_string(dir.join(FILE_NAME)).unwrap();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 // What was there is untouched, comment and all.382 // What was there is untouched, comment and all.
377 assert!(written.starts_with("# mine\ndatabase = \"state/izlek.db\"\n"), "{written}");383 assert!(written.starts_with("# mine\ndatabase = \"state/izlek.db\"\n"), "{written}");
378 384
@@ -404,7 +410,7 @@ mod tests {
404 #[test]410 #[test]
405 fn a_missing_key_names_itself_rather_than_guessing() {411 fn a_missing_key_names_itself_rather_than_guessing() {
406 let problem =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 assert_eq!(problem, ConfigError::Missing("database"));414 assert_eq!(problem, ConfigError::Missing("database"));
409 let said = problem.to_string();415 let said = problem.to_string();
410 assert!(said.contains("database"), "{said}");416 assert!(said.contains("database"), "{said}");
@@ -436,12 +442,12 @@ mod tests {
436 let _ = std::fs::remove_dir_all(&dir);442 let _ = std::fs::remove_dir_all(&dir);
437 }443 }
438 444
439- /// A file written before `listen` existed still loads, and still binds445+ /// A file that does not mention `listen` still loads, and binds at the
440- /// where it always did.446+ /// default it is about to be completed with.
441 #[test]447 #[test]
442- fn a_file_without_listen_falls_back_to_the_old_default() {448+ fn a_file_without_listen_takes_the_default() {
443 let config = Config::parse("database = \"/srv/izlek.db\"\n", Path::new("."), false).unwrap();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 #[test]453 #[test]
@@ -471,16 +477,16 @@ mod tests {
471 .unwrap()477 .unwrap()
472 .listen_url()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 assert_eq!(url("192.168.1.20:8080"), "http://192.168.1.20:8080");481 assert_eq!(url("192.168.1.20:8080"), "http://192.168.1.20:8080");
476 // Port 80 is the one a URL does not say.482 // Port 80 is the one a URL does not say.
477 assert_eq!(url("10.0.0.4:80"), "http://10.0.0.4");483 assert_eq!(url("10.0.0.4:80"), "http://10.0.0.4");
478 // A bind that names no interface is reachable by no name, so the484 // A bind that names no interface is reachable by no name, so the
479 // loopback stands in: a link somebody on the box can click beats a485 // loopback stands in: a link somebody on the box can click beats a
480 // link nobody can.486 // link nobody can.
481- assert_eq!(url("0.0.0.0:3000"), "http://127.0.0.1:3000");487+ assert_eq!(url("0.0.0.0:7654"), "http://127.0.0.1:7654");
482- assert_eq!(url("[::]:3000"), "http://127.0.0.1:3000");488+ assert_eq!(url("[::]:7654"), "http://127.0.0.1:7654");
483- assert_eq!(url("[::1]:3000"), "http://[::1]:3000");489+ assert_eq!(url("[::1]:7654"), "http://[::1]:7654");
484 }490 }
485 491
486 /// The sender used to be environment variables read directly, and the492 /// The sender used to be environment variables read directly, and the