From 1c69a77ec156099883cf8d28f253a8be2f8e268b Mon Sep 17 00:00:00 2001 From: Ricardo Arturo Cabral Mejia Date: Tue, 25 Oct 2022 09:13:19 -0400 Subject: [PATCH 1/3] doc: add CONFIGURATION.md --- CONFIGURATION.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 CONFIGURATION.md diff --git a/CONFIGURATION.md b/CONFIGURATION.md new file mode 100644 index 00000000..2babcf7a --- /dev/null +++ b/CONFIGURATION.md @@ -0,0 +1,41 @@ +# Configuration + +# Environment variables + +The following environment variables can be set: + +| Name | Description | Default | +|------------------|--------------------------------|-------------------| +| SERVER_PORT | Relay's server port | 8008 | +| DB_HOST | PostgresSQL Hostname | | +| DB_PORT | PostgreSQL Port | | +| DB_USER | PostgreSQL Username | | +| DB_PASSWORD | PostgreSQL Password | | +| DB_NAME | PostgreSQL Database name | | +| NOSTR_CONFIG_DIR | Configuration directory | ~/.nostr/ | + +# Settings + +Running `nostr-ts-relay` for the first time creates the settings file in `~/.nostr/settings.json`. If the file is not created and an error is thrown ensure that the `~/.nostr` folder exists. The configuration directory can be changed by setting the `NOSTR_CONFIG_DIR` environment variable. + +| Name | Description | +|---------------------------------------------|-------------------------------------------------------------------------------| +| info.relay_url | Public-facing URL of your relay. (e.g. wss://relay.your-domain.com) | +| info.name | Public name of your relay. (e.g. TBG's Public Relay) | +| info.description | Public description of your relay. (e.g. Toronto Bitcoin Group Public Relay) | +| info.pubkey | Relay operator's Nostr pubkey in hex format. | +| info.contact | Relay operator's contact. (e.g. mailto:operator@relay-your-domain.com) | +| workers.count | Number of workers to spin up to handle incoming connections. | +| | Spin workers as many CPUs are available when set to zero. Defaults to zero. | +| limits.event.eventId.minLeadingZeroBits | Leading zero bits required on every incoming event for proof of work. | +| | Defaults to zero. Disabled when set to zero. | +| limits.event.kind.whitelist | List of event kinds to allow. Leave empty to allow any. | +| limits.event.kind.blacklist | List of event kinds to reject. Leave empty to allow any. | +| limits.event.pubkey.minLeadingZeroBits | Leading zero bits required on the public key of incoming events for proof of work. | +| | Defaults to zero. Disabled when set to zero. | +| limits.event.pubkey.whitelist | List of public keys to allow. Only public keys in this list will be able to post to this relay. | +| limits.event.pubkey.blacklist | List of public keys to reject. Public keys in this list will not be able to post to this relay. | +| limits.event.createdAt.maxPositiveDelta | Maximum number of seconds an event's `created_at` can be in the future. Defaults to 900 (15 minutes). Disabled when set to zero. | +| limits.event.createdAt.minNegativeDelta | Maximum number of secodns an event's `created_at` can be in the past. Defaults to zero. Disabled when set to zero. | +| limits.client.subscription.maxSubscriptions | Maximum number of subscriptions per connected client. Defaults to 10. Disabled when set to zero. | +| limits.client.subscription.maxFilters | Maximum number of filters per subscription. Defaults to 10. Disabled when set to zero. | From 7f9e070e67cbb6751167e75e18663e29a40ff1b4 Mon Sep 17 00:00:00 2001 From: Ricardo Arturo Cabral Mejia Date: Tue, 25 Oct 2022 22:17:07 -0400 Subject: [PATCH 2/3] doc: add link to config on readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 05b946f6..e4f1c6f9 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,8 @@ You can change the default folder by setting the `NOSTR_CONFIG_DIR` environment Run nostr-ts-relay using one of the quick-start guides at least once and `~/.nostr/settings.json` will be created. Any changes made to the settings file will be read on the next start. +See [CONFIGURATION.md](CONFIGURATION.md) for a detailed explanation of each environment variable and setting. + ## Dev Channel For development discussions, please use the [Nostr Typescript Relay Dev Channel](https://t.me/nostr_ts_relay). From c13e1ab21cb7fcd56a871a1b15d23719bc507426 Mon Sep 17 00:00:00 2001 From: Ricardo Arturo Cabral Mejia Date: Tue, 25 Oct 2022 22:25:07 -0400 Subject: [PATCH 3/3] doc: add sample settings file --- README.md | 4 +++- settings.sample.json | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 settings.sample.json diff --git a/README.md b/README.md index e4f1c6f9..908c3d7d 100644 --- a/README.md +++ b/README.md @@ -116,8 +116,10 @@ You can change the default folder by setting the `NOSTR_CONFIG_DIR` environment Run nostr-ts-relay using one of the quick-start guides at least once and `~/.nostr/settings.json` will be created. Any changes made to the settings file will be read on the next start. -See [CONFIGURATION.md](CONFIGURATION.md) for a detailed explanation of each environment variable and setting. +A sample settings file is included at the project root under the name `settings.sample.json`. Feel free to copy it to `~/.nostr/settings.json` +if you would like to have a settings file before running the relay first. +See [CONFIGURATION.md](CONFIGURATION.md) for a detailed explanation of each environment variable and setting. ## Dev Channel For development discussions, please use the [Nostr Typescript Relay Dev Channel](https://t.me/nostr_ts_relay). diff --git a/settings.sample.json b/settings.sample.json new file mode 100644 index 00000000..7e9c3eed --- /dev/null +++ b/settings.sample.json @@ -0,0 +1,35 @@ +{ + "info": { + "relay_url": "wss://nostr-ts-relay.your-domain.com", + "name": "nostr-ts-relay.your-domain.com", + "description": "A nostr relay written in Typescript.", + "pubkey": "replace-with-your-pubkey", + "contact": "operator@your-domain.com" + }, + "limits": { + "event": { + "eventId": { + "minLeadingZeroBits": 0 + }, + "kind": { + "whitelist": [], + "blacklist": [] + }, + "pubkey": { + "minLeadingZeroBits": 0, + "whitelist": [], + "blacklist": [] + }, + "createdAt": { + "maxPositiveDelta": 900, + "maxNegativeDelta": 0 + } + }, + "client": { + "subscription": { + "maxSubscriptions": 10, + "maxFilters": 10 + } + } + } +} \ No newline at end of file