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"
33 # The address the server listens on. Environment variables are ignored —
44 # this is the only thing that decides where Izlek binds. It is also the
55 # 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"
5050 # The address the server listens on. Environment variables are ignored —
5151 # this is the only thing that decides where Izlek binds. It is also the
5252 # 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"
5454 "#;
5555
5656 /// The default `listen` when the file is silent about it. A file missing this
5757 /// 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";
5965
6066 /// Every optional key, with the comment and default a file missing it is
6167 /// completed with. `database` is not here: it has no default worth guessing,
@@ -66,7 +72,7 @@ const OPTIONAL_KEYS: &[(&str, &str)] = &[(
6672 "# The address the server listens on. Environment variables are ignored —\n",
6773 "# this is the only thing that decides where Izlek binds. It is also the\n",
6874 "# 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"
7076 ),
7177 )];
7278
@@ -342,8 +348,8 @@ mod tests {
342348 assert!(config.defaulted);
343349 assert!(config.database.is_absolute(), "{:?}", config.database);
344350 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");
347353
348354 let written = std::fs::read_to_string(dir.join(FILE_NAME)).unwrap();
349355 assert_eq!(written, DEVELOPMENT_DEFAULTS);
@@ -369,10 +375,10 @@ mod tests {
369375 .unwrap();
370376
371377 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());
373379
374380 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}");
376382 // What was there is untouched, comment and all.
377383 assert!(written.starts_with("# mine\ndatabase = \"state/izlek.db\"\n"), "{written}");
378384
@@ -404,7 +410,7 @@ mod tests {
404410 #[test]
405411 fn a_missing_key_names_itself_rather_than_guessing() {
406412 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();
408414 assert_eq!(problem, ConfigError::Missing("database"));
409415 let said = problem.to_string();
410416 assert!(said.contains("database"), "{said}");
@@ -436,12 +442,12 @@ mod tests {
436442 let _ = std::fs::remove_dir_all(&dir);
437443 }
438444
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.
441447 #[test]
442- fn a_file_without_listen_falls_back_to_the_old_default() {
448+ fn a_file_without_listen_takes_the_default() {
443449 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());
445451 }
446452
447453 #[test]
@@ -471,16 +477,16 @@ mod tests {
471477 .unwrap()
472478 .listen_url()
473479 };
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");
475481 assert_eq!(url("192.168.1.20:8080"), "http://192.168.1.20:8080");
476482 // Port 80 is the one a URL does not say.
477483 assert_eq!(url("10.0.0.4:80"), "http://10.0.0.4");
478484 // A bind that names no interface is reachable by no name, so the
479485 // loopback stands in: a link somebody on the box can click beats a
480486 // 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");
484490 }
485491
486492 /// The sender used to be environment variables read directly, and the