mirror of
https://github.com/aljazceru/pubky-core.git
synced 2026-01-08 00:34:21 +01:00
refactor(homeserver): remove unnecessary testnet property in the Config
This commit is contained in:
@@ -22,26 +22,13 @@ mod pkarr;
|
||||
pub struct HomeserverBuilder(Config);
|
||||
|
||||
impl HomeserverBuilder {
|
||||
pub fn testnet(&mut self) -> &mut Self {
|
||||
self.0.io.testnet = true;
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Configure the Homeserver's keypair
|
||||
/// Set the Homeserver's keypair
|
||||
pub fn keypair(&mut self, keypair: Keypair) -> &mut Self {
|
||||
self.0.keypair = keypair;
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Configure the Mainline DHT bootstrap nodes. Useful for testnet configurations.
|
||||
pub fn bootstrap(&mut self, bootstrap: Vec<String>) -> &mut Self {
|
||||
self.0.io.bootstrap = Some(bootstrap);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Configure the storage path of the Homeserver
|
||||
pub fn storage(&mut self, storage: PathBuf) -> &mut Self {
|
||||
self.0.core.storage = storage;
|
||||
@@ -146,10 +133,6 @@ impl Homeserver {
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct IoConfig {
|
||||
// TODO: why does this matter?
|
||||
/// Run in [testnet](crate::Homeserver::run_testnet) mode.
|
||||
pub testnet: bool,
|
||||
|
||||
pub http_port: u16,
|
||||
pub https_port: u16,
|
||||
pub public_addr: Option<SocketAddr>,
|
||||
@@ -168,7 +151,6 @@ impl Default for IoConfig {
|
||||
https_port: DEFAULT_HTTPS_PORT,
|
||||
http_port: DEFAULT_HTTP_PORT,
|
||||
|
||||
testnet: false,
|
||||
public_addr: None,
|
||||
domain: None,
|
||||
bootstrap: None,
|
||||
|
||||
@@ -83,20 +83,17 @@ pub fn create_signed_packet(
|
||||
signed_packet_builder = signed_packet_builder.https(".".try_into().unwrap(), svcb, 60 * 60);
|
||||
|
||||
// Set low priority https record for legacy browsers support
|
||||
if config.testnet {
|
||||
if let Some(ref domain) = config.domain {
|
||||
let mut svcb = SVCB::new(10, ".".try_into()?);
|
||||
|
||||
let http_port_be_bytes = http_port.to_be_bytes();
|
||||
svcb.set_param(
|
||||
pubky_common::constants::reserved_param_keys::HTTP_PORT,
|
||||
&http_port_be_bytes,
|
||||
)?;
|
||||
if domain == "localhost" {
|
||||
svcb.set_param(
|
||||
pubky_common::constants::reserved_param_keys::HTTP_PORT,
|
||||
&http_port_be_bytes,
|
||||
)?;
|
||||
}
|
||||
|
||||
svcb.target = "localhost".try_into().expect("localhost is valid dns name");
|
||||
|
||||
signed_packet_builder = signed_packet_builder.https(".".try_into().unwrap(), svcb, 60 * 60)
|
||||
} else if let Some(ref domain) = config.domain {
|
||||
let mut svcb = SVCB::new(10, ".".try_into()?);
|
||||
svcb.target = domain.as_str().try_into()?;
|
||||
|
||||
signed_packet_builder = signed_packet_builder.https(".".try_into().unwrap(), svcb, 60 * 60);
|
||||
|
||||
Reference in New Issue
Block a user