diff --git a/pubky-homeserver/src/config.rs b/pubky-homeserver/src/config.rs index e177311..55f015c 100644 --- a/pubky-homeserver/src/config.rs +++ b/pubky-homeserver/src/config.rs @@ -18,6 +18,7 @@ const DEFAULT_STORAGE_DIR: &str = "pubky"; /// Server configuration #[derive(Serialize, Deserialize, Clone)] pub struct Config { + testnet: bool, port: Option, bootstrap: Option>, domain: String, @@ -39,13 +40,23 @@ impl Config { .with_context(|| format!("failed to read {}", path.as_ref().to_string_lossy()))?; let config: Config = toml::from_str(&s)?; + + if config.testnet { + let testnet_config = Config::testnet(); + + return Ok(Config { + bootstrap: testnet_config.bootstrap, + ..config + }); + } + Ok(config) } /// Testnet configurations pub fn testnet() -> Self { let testnet = pkarr::mainline::Testnet::new(10); - info!(?testnet.bootstrap, "Testnet Config"); + info!(?testnet.bootstrap, "Testnet bootstrap nodes"); let bootstrap = Some(testnet.bootstrap.to_owned()); let storage = Some( @@ -117,6 +128,7 @@ impl Config { impl Default for Config { fn default() -> Self { Self { + testnet: false, port: Some(0), bootstrap: None, domain: "localhost".to_string(), @@ -152,6 +164,7 @@ where impl Debug for Config { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_map() + .entry(&"testnet", &self.testnet) .entry(&"port", &self.port()) .entry(&"storage", &self.storage()) .entry(&"public_key", &self.keypair().public_key()) diff --git a/pubky-homeserver/src/config.toml b/pubky-homeserver/src/config.toml index dda26e9..2012efc 100644 --- a/pubky-homeserver/src/config.toml +++ b/pubky-homeserver/src/config.toml @@ -1,3 +1,5 @@ +# Use testnet network (local DHT) for testing. +testnet = false # Secret key (in hex) to generate the Homeserver's Keypair secret_key = "0000000000000000000000000000000000000000000000000000000000000000" # Domain to be published in Pkarr records for this server to be accessible by.