From 8f227d775d67e049eebcc060b660a89701665350 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Tue, 11 Feb 2025 13:28:57 +1300 Subject: [PATCH] config.public_key_hex is now config.contact_public_key_hex This will avoid a future name collision when the relay has it's own keypair. --- contrib/chorus.toml | 2 +- docs/CONFIG.md | 8 +++++--- docs/DEPLOYING.md | 6 +++++- src/config.rs | 17 +++++++++-------- src/web/nip11.rs | 2 +- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/contrib/chorus.toml b/contrib/chorus.toml index ba21e7a..ed8fb30 100644 --- a/contrib/chorus.toml +++ b/contrib/chorus.toml @@ -116,7 +116,7 @@ key_pem_path = "/opt/chorus/etc/tls/privkey.pem" # # Default is not set # -# public_key_hex = +# contact_public_key_hex = # If open_relay is true, the relay behaves as an open public relay. diff --git a/docs/CONFIG.md b/docs/CONFIG.md index bfc9b96..fe925ad 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -100,13 +100,15 @@ This is an optional URL for an graphical icon representing your relay, displayed ### contact -This is an optional contact for your relay, displayed in the NIP-11 response. +This is an optional administrative contact for your relay, displayed in the NIP-11 response. Default is None. -### public_key_hex +### contact_public_key_hex -This is an optional public key (hex format) for your relay, displayed in the NIP-11 response. +This is an optional public key (hex format) for your relay's administrative contact, displayed in the NIP-11 response. + +Deprecated "public_key_hex" also works. Default is None. diff --git a/docs/DEPLOYING.md b/docs/DEPLOYING.md index a1a5f7e..97509b5 100644 --- a/docs/DEPLOYING.md +++ b/docs/DEPLOYING.md @@ -84,7 +84,7 @@ Go ahead and edit that file to your liking. In particular: or to 127.0.0.1 with a local port like 8080 (if you are proxying behind nginx) - Change the port if necessary - Change the name, description, icon_url and contact (e.g. your email address) as desired -- Set your public_key_hex (it is an option, so use `Some()`) +- Set your contact_public_key_hex (it is an option, so use `Some()`) - Set hex keys of users for which this relay will act as a personal relay @@ -166,6 +166,10 @@ Restart nginx sudo systemctl restart nginx.service ``` +## Adding users and moderators + +See [MANAGEMENT](MANAGEMENT.md) for how to add users and moderators. + ## Monitoring the service You can watch the logs with a command like this diff --git a/src/config.rs b/src/config.rs index b8e4ccd..81ef61a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -21,7 +21,8 @@ pub struct FriendlyConfig { pub description: Option, pub icon_url: Option, pub contact: Option, - pub public_key_hex: Option, + #[serde(alias = "public_key_hex")] + pub contact_public_key_hex: Option, pub open_relay: bool, pub admin_hex_keys: Vec, pub verify_events: bool, @@ -61,7 +62,7 @@ impl Default for FriendlyConfig { description: Some("A default config of the Chorus relay".to_string()), icon_url: None, contact: None, - public_key_hex: None, + contact_public_key_hex: None, open_relay: false, admin_hex_keys: vec![], verify_events: true, @@ -103,7 +104,7 @@ impl FriendlyConfig { description, icon_url, contact, - public_key_hex, + contact_public_key_hex, open_relay, admin_hex_keys, verify_events, @@ -127,9 +128,9 @@ impl FriendlyConfig { enable_negentropy, } = self; - let mut public_key: Option = None; - if let Some(pkh) = public_key_hex { - public_key = Some(Pubkey::read_hex(pkh.as_bytes())?); + let mut contact_public_key: Option = None; + if let Some(pkh) = contact_public_key_hex { + contact_public_key = Some(Pubkey::read_hex(pkh.as_bytes())?); }; let mut admin_keys: Vec = Vec::with_capacity(admin_hex_keys.len()); @@ -160,7 +161,7 @@ impl FriendlyConfig { description, icon_url, contact, - public_key, + contact_public_key, open_relay, admin_keys, admin_hex_keys, @@ -202,7 +203,7 @@ pub struct Config { pub description: Option, pub icon_url: Option, pub contact: Option, - pub public_key: Option, + pub contact_public_key: Option, pub open_relay: bool, pub admin_keys: Vec, pub admin_hex_keys: Vec, diff --git a/src/web/nip11.rs b/src/web/nip11.rs index 547c3d5..c8e0cd2 100644 --- a/src/web/nip11.rs +++ b/src/web/nip11.rs @@ -92,7 +92,7 @@ fn build_rid(config: &Config) -> String { rid.push_str(contact); rid.push('\"'); } - if let Some(pubkey) = &config.public_key { + if let Some(pubkey) = &config.contact_public_key { let mut pkh: [u8; 64] = [0; 64]; pubkey.write_hex(&mut pkh).unwrap(); rid.push(',');