mirror of
https://github.com/mikedilger/chorus.git
synced 2026-03-04 06:36:27 +00:00
config.open_relay optionally run as an open public relay
This commit is contained in:
parent
dc4811c0ef
commit
f6c8d214a4
@ -401,6 +401,11 @@ async fn screen_incoming_event(
|
||||
}
|
||||
}
|
||||
|
||||
// Accept if an open relay
|
||||
if GLOBALS.config.get().unwrap().open_relay {
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
// Accept anything from authenticated authorized users
|
||||
if authorized_user {
|
||||
return Ok(true);
|
||||
@ -448,6 +453,17 @@ pub fn screen_outgoing_event(
|
||||
event_flags: &EventFlags,
|
||||
authorized_user: bool,
|
||||
) -> bool {
|
||||
// Forbid if it is a private event (DM or GiftWrap) and theey are neither the recipient
|
||||
// nor the author
|
||||
if event.kind() == Kind(4) || event.kind() == Kind(1059) {
|
||||
return event_flags.tags_current_user || event_flags.author_is_current_user;
|
||||
}
|
||||
|
||||
// Allow if an open relay
|
||||
if GLOBALS.config.get().unwrap().open_relay {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Allow Relay Lists
|
||||
if event.kind() == Kind(10002) && GLOBALS.config.get().unwrap().serve_relay_lists {
|
||||
return true;
|
||||
@ -458,12 +474,6 @@ pub fn screen_outgoing_event(
|
||||
return true;
|
||||
}
|
||||
|
||||
// Forbid if it is a private event (DM or GiftWrap) and theey are neither the recipient
|
||||
// nor the author
|
||||
if event.kind() == Kind(4) || event.kind() == Kind(1059) {
|
||||
return event_flags.tags_current_user || event_flags.author_is_current_user;
|
||||
}
|
||||
|
||||
// Allow if an authorized_user is asking
|
||||
if authorized_user {
|
||||
return true;
|
||||
|
||||
@ -18,6 +18,7 @@ pub struct FriendlyConfig {
|
||||
pub description: Option<String>,
|
||||
pub contact: Option<String>,
|
||||
pub public_key_hex: Option<String>,
|
||||
pub open_relay: bool,
|
||||
pub user_hex_keys: Vec<String>,
|
||||
pub verify_events: bool,
|
||||
pub allow_scraping: bool,
|
||||
@ -45,6 +46,7 @@ impl Default for FriendlyConfig {
|
||||
description: None,
|
||||
contact: None,
|
||||
public_key_hex: None,
|
||||
open_relay: false,
|
||||
user_hex_keys: vec![],
|
||||
verify_events: true,
|
||||
allow_scraping: false,
|
||||
@ -74,6 +76,7 @@ impl FriendlyConfig {
|
||||
description,
|
||||
contact,
|
||||
public_key_hex,
|
||||
open_relay,
|
||||
user_hex_keys,
|
||||
verify_events,
|
||||
allow_scraping,
|
||||
@ -118,6 +121,7 @@ impl FriendlyConfig {
|
||||
description,
|
||||
contact,
|
||||
public_key,
|
||||
open_relay,
|
||||
user_keys,
|
||||
user_hex_keys,
|
||||
verify_events,
|
||||
@ -147,6 +151,7 @@ pub struct Config {
|
||||
pub description: Option<String>,
|
||||
pub contact: Option<String>,
|
||||
pub public_key: Option<Pubkey>,
|
||||
pub open_relay: bool,
|
||||
pub user_keys: Vec<Pubkey>,
|
||||
pub user_hex_keys: Vec<String>,
|
||||
pub verify_events: bool,
|
||||
|
||||
@ -95,6 +95,13 @@ key_pem_path = "/opt/chorus/etc/tls/privkey.pem"
|
||||
# public_key_hex =
|
||||
|
||||
|
||||
# If open_relay is true, the relay behaves as an open public relay.
|
||||
#
|
||||
# Default is false.
|
||||
#
|
||||
# open_relay = false
|
||||
|
||||
|
||||
# These are the public keys (hex format) of your relay's authorized users. See BEHAVIOR.md
|
||||
# to understand how chorus uses these.
|
||||
#
|
||||
|
||||
@ -89,6 +89,12 @@ This is an optional public key (hex format) for your relay, displayed in the NIP
|
||||
|
||||
Default is None.
|
||||
|
||||
### open_relay
|
||||
|
||||
If open_relay true, the relay behaves as an open public relay.
|
||||
|
||||
Default is false.
|
||||
|
||||
### user_hex_keys
|
||||
|
||||
These are the public keys (hex format) of your relay's authorized users. See [BEHAVIOR.md](BEHAVIOR.md) to understand how chorus uses these.
|
||||
|
||||
@ -23,3 +23,7 @@ they will need to setup SSL connections to far too many relays.
|
||||
It may be better for others if people were to use a smaller number of larger relay services.
|
||||
|
||||
But who am I to say? You are the sovereign. Here is your personal relay.
|
||||
|
||||
## Open Relay
|
||||
|
||||
You can run chorus as an open public relay. Just set `open_relay` to true in the config.
|
||||
|
||||
@ -9,6 +9,7 @@ certchain_pem_path = "tls/fullchain.pem"
|
||||
key_pem_path = "tls/privkey.pem"
|
||||
name = "Chorus Sample"
|
||||
description = "A sample run of the Chorus relay"
|
||||
open_relay = false
|
||||
user_hex_keys = [
|
||||
"ee11a5dff40c19a555f41fe42b48f00e618c91225622ae37b6c2bb67b76c4e49"
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user