Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
139eed9
feat: add pay-to-relay
cameri Jan 11, 2023
24b928a
feat: add yaml parser js-yaml
antonleviathan Jan 11, 2023
92a661a
chore: patch vuln in knex and pin dotenv
antonleviathan Jan 11, 2023
6c6084a
feat(utils): refactor settings to use yaml
antonleviathan Jan 11, 2023
683f018
fix: refactor to use process.cwd()
antonleviathan Jan 11, 2023
2579eec
chore: update tests
antonleviathan Jan 12, 2023
5b6134b
chore: use join instead of interpolation
antonleviathan Jan 12, 2023
ed8bef8
chore: use join instead of interpolation
antonleviathan Jan 12, 2023
d8c5967
chore: use console.warn instead of debug
antonleviathan Jan 12, 2023
82fa6af
fix: typo
antonleviathan Jan 12, 2023
fdad32d
chore: remove unnecessary test case
antonleviathan Jan 12, 2023
e127562
docs: fix file extension
antonleviathan Jan 12, 2023
d3db620
fix: remove test file which is failing ci/cd
antonleviathan Jan 14, 2023
a6c29a7
fix: remove dupe updated_at column from invoice
cameri Jan 14, 2023
d339b86
fix: use knex 2.4.0 everywhere
cameri Jan 14, 2023
754857b
chore: mount resources on intg tests
cameri Jan 14, 2023
f3a5374
chore: install @types/js-yaml
cameri Jan 14, 2023
1803519
fix: invalid type for extname()
cameri Jan 14, 2023
59e6ece
chore: ./scripts/clean prunes all unused dkr imgs
cameri Jan 14, 2023
cecef0c
test: disable event rate limits
cameri Jan 14, 2023
6c1d91a
chore: add lint:report script
cameri Jan 17, 2023
1a9730b
feat: massive update
cameri Jan 27, 2023
d548c7e
fix: lots of bugs
cameri Jan 27, 2023
53e5f1a
fix: nip-11 doc and tests
cameri Jan 27, 2023
17f5075
fix: crash when payments are disabled
cameri Jan 27, 2023
6fecdd7
fix: patch
cameri Jan 28, 2023
02a633b
fix: patch knex
cameri Jan 28, 2023
bdaa002
chore: reduce logging
cameri Jan 28, 2023
911641e
chore: log conn pool every min
cameri Jan 28, 2023
297cb7c
fix: rate limiter err
cameri Jan 28, 2023
6d940bd
fix: increase rate limits
cameri Jan 28, 2023
a789a3e
feat: implement static mirroring
cameri Jan 29, 2023
7dffd1c
chore: improve mirror logging
cameri Jan 29, 2023
803eab7
fix: error on heartbeat
cameri Jan 29, 2023
8bef94a
chore: update logging
cameri Jan 30, 2023
61c8549
fix: since to be in seconds
cameri Jan 30, 2023
f706331
chore: disable aborting queries
cameri Jan 30, 2023
40de0ea
chore: patch receiver.write
cameri Jan 30, 2023
a211306
chore: less verbose invalid msgs
cameri Jan 30, 2023
baea30c
chore: inc. pong timeout
cameri Jan 30, 2023
dd2d146
chore: improve logging
cameri Jan 30, 2023
7426ce9
chore: handle pings
cameri Jan 30, 2023
9b01021
feat: adding powered by ZBD badge if its enabled payment processor
andrerfneves Feb 1, 2023
56766c3
chore: revert .nostr.local settings
cameri Feb 2, 2023
777e5a8
chore: add RELAY_PRIVATE_KEY env var
cameri Feb 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 90 additions & 7 deletions .nostr.local/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,69 @@
"info": {
"relay_url": "wss://nostream.localtest.me",
"name": "nostream.localtest.me",
"description": "A nostr relay written in TypeScript.",
"pubkey": "replace-with-your-pubkey",
"description": "A nostr relay written in Typescript.",
"pubkey": "00000000827ffaa94bfea288c3dfce4422c794fbb96625b6b31e9049f729d700",
"contact": "operator@your-domain.com"
},
"network": {
"max_payload_size": 131072,
"remote_ip_header": "x-forwarded-for"
"maxPayloadSize": 131072,
"remoteIpHeader": "x-forwarded-for",
"idleTimeout": 60
},
"payments": {
"enabled": true,
"processor": "zebedee",
"feeSchedules": {
"admission": [{
"enabled": true,
"descripton": "Admission fee in msats (1000 msats = 1 satoshi)",
"amount": 1000000,
"whitelists": {
"pubkeys": ["replace-with-your-pubkey"]
}
}],
"publication": [
{
"enabled": true,
"description": "Publication fee in msats (1000 msats = 1 satoshi)",
"amount": 100,
"whitelists": {
"pubkeys": ["replace-with-your-pubkey"]
}
}
]
}
},
"paymentProcessors": {
"zebedee": {
"baseURL": "https://api.zebedee.io/",
"callbackBaseURL": "https://nostream.localtest.me/callbacks/zebedee"
}
},
"workers": {
"count": 0
},
"limits": {
"connection": {
"rateLimits": [
{
"period": 60000,
"rate": 12
},
{
"period": 3600000,
"rate": 360
},
{
"period": 86400000,
"rate": 2880
}
],
"ipWhitelist": [
"::1",
"::ffff:10.10.10.1"
]
},
"event": {
"eventId": {
"minLeadingZeroBits": 0
Expand All @@ -31,45 +82,62 @@
"maxPositiveDelta": 900,
"maxNegativeDelta": 0
},
"content": {
"maxLength": 1048576
},
"content": [
{
"description": "64 KB for event kind ranges 0-10 and 40-49",
"kinds": [[0, 10], [40, 49]],
"maxLength": 65536
},
{
"description": "96 KB for event kind ranges 11-39 and 50-max",
"kinds": [[11, 39], [50, 9007199254740991]],
"maxLength": 98304
}
],
"rateLimits": [
{
"description": "6 events/min for event kinds 0, 3, 40 and 41",
"kinds": [0, 3, 40, 41],
"period": 60000,
"rate": 6
},
{
"description": "12 events/min for event kinds 1, 2, 4 and 42",
"kinds": [1, 2, 4, 42],
"period": 60000,
"rate": 12
},
{
"description": "360 events/hour for event kinds 1, 2, 4 and 42",
"kinds": [1, 2, 4, 42],
"period": 3600000,
"rate": 360
},
{
"description": "30 events/min for event kind ranges 5-7 and 43-49",
"kinds": [[5, 7], [43, 49]],
"period": 60000,
"rate": 30
},
{
"description": "24 events/min for replaceable events and parameterized replaceable events",
"kinds": [[10000, 19999], [30000, 39999]],
"period": 60000,
"rate": 24
},
{
"description": "60 events/min for ephemeral events",
"kinds": [[20000, 29999]],
"period": 60000,
"rate": 60
},
{
"description": "720 events/hour for all events",
"period": 3600000,
"rate": 720
},
{
"description": "2880 events/day for all events",
"period": 86400000,
"rate": 2880
}
Expand All @@ -91,14 +159,29 @@
"message": {
"rateLimits": [
{
"description": "60 subscriptions/min",
"types": ["REQ"],
"period": 60000,
"rate": 60
},
{
"description": "2880 subscriptions/hour",
"types": ["REQ"],
"period": 3600000,
"rate": 2880
},
{
"description": "120 raw messages/min",
"period": 60000,
"rate": 120
},
{
"description": "3600 raw messages/hour",
"period": 3600000,
"rate": 3600
},
{
"description": "86400 raw messages/day",
"period": 86400000,
"rate": 86400
}
Expand Down
13 changes: 9 additions & 4 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The following environment variables can be set:
| Name | Description | Default |
|----------------------------------|--------------------------------|------------------------|
| RELAY_PORT | Relay's server port | 8008 |
| RELAY_PRIVATE_KEY | Relay's private key in hex | (auto-generated) |
| WORKER_COUNT | Number of workers override | No. of available CPUs |
| DB_HOST | PostgresSQL Hostname | |
| DB_PORT | PostgreSQL Port | 5432 |
Expand Down Expand Up @@ -38,7 +39,7 @@ The following environment variables can be set:

# Settings

Running `nostream` for the first time creates the settings file in `<project_root>/.nostr/settings.json`. If the file is not created and an error is thrown ensure that the `<project_root>/.nostr` folder exists. The configuration directory can be changed by setting the `NOSTR_CONFIG_DIR` environment variable.
Running `nostream` for the first time creates the settings file in `<project_root>/.nostr/settings.yaml`. If the file is not created and an error is thrown ensure that the `<project_root>/.nostr` folder exists. The configuration directory can be changed by setting the `NOSTR_CONFIG_DIR` environment variable.

| Name | Description |
|---------------------------------------------|-------------------------------------------------------------------------------|
Expand All @@ -47,8 +48,11 @@ Running `nostream` for the first time creates the settings file in `<project_roo
| 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) |
| network.max_payload_size | Maximum number of bytes accepted per WebSocket frame |
| network.remote_ip_header | HTTP header from proxy containing IP address from client. |
| network.maxPayloadSize | Maximum number of bytes accepted per WebSocket frame |
| network.remoteIpHeader | HTTP header from proxy containing IP address from client. |
| mirroring.static[].address | Address of mirrored relay. (e.g. ws://100.100.100.100:8008) |
| mirroring.static[].filters | Subscription filters used to mirror. |
| mirroring.static[].secret | Secret to pass to relays. Nostream relays only. Optional. |
| 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. |
Expand All @@ -61,7 +65,8 @@ Running `nostream` for the first time creates the settings file in `<project_roo
| limits.event.pubkey.blacklist | List of public keys to always 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.event.content.maxLength | Maximum length of `content`. Defaults to 1 MB. Disabled when set to zero. |
| limits.event.content[].kinds | List of event kinds to apply limit. Use `[min, max]` for ranges. Optional. |
| limits.event.content[].maxLength | Maximum length of `content`. Defaults to 1 MB. Disabled when set to zero. |
| limits.event.rateLimits[].kinds | List of event kinds rate limited. Use `[min, max]` for ranges. Optional. |
| limits.event.rateLimits[].period | Rate limiting period in milliseconds. |
| limits.event.rateLimits[].rate | Maximum number of events during period. |
Expand Down
2 changes: 1 addition & 1 deletion Caddyfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
nostream.localtest.me {
tls /root/certs/nostream.localtest.me.pem /root/certs/nostream.localtest.me-key.pem

reverse_proxy nostr-ts-relay:8008
reverse_proxy nostream:8008
}
9 changes: 2 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@ LABEL org.opencontainers.image.description="nostream"
LABEL org.opencontainers.image.authors="Ricardo Arturo Cabral Mejía"
LABEL org.opencontainers.image.licenses=MIT


ENV DB_HOST=localhost
ENV DB_PORT=5432
ENV DB_NAME=nostr-ts-relay
ENV DB_USER=nostr-ts-relay
ENV DB_PASSWORD=nostr-ts-relay

WORKDIR /app
RUN apk add --no-cache --update git

ADD resources /app/resources

COPY --from=build /build/dist .

RUN npm install --omit=dev --quiet
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.railwayapp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ COPY ["package.json", "package-lock.json","knexfile.js","./"]

ADD migrations /build/migrations

RUN npm install -g knex@2.3.0 && npm install --quiet
RUN npm install -g knex@2.4.0 && npm install --quiet

RUN npm run db:migrate

Expand Down
14 changes: 1 addition & 13 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
FROM node:18-alpine3.16

ENV DB_HOST=db-test
ENV DB_PORT=5432
ENV DB_NAME=postgres
ENV DB_USER=postgres
ENV DB_PASSWORD=postgres
ENV DB_MIN_POOL_SIZE=1
ENV DB_MAX_POOL_SIZE=2
ENV REDIS_HOST=cache-test
ENV REDIS_PORT=6379
ENV REDIS_USER=default
ENV REDIS_PASSWORD=nostr_ts_relay_test
FROM node:18.8-alpine3.16

WORKDIR /code

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ You can change the default folder by setting the `NOSTR_CONFIG_DIR` environment
Run nostream using one of the quick-start guides at least once and `nostream/.nostr/settings.json` will be created.
Any changes made to the settings file will be read on the next start.

A sample settings file is included at the project root under the name `settings.sample.json`. Feel free to copy it to `nostream/.nostr/settings.json`
if you would like to have a settings file before running the relay first.
Default settings can be found under `resources/default-settings.yaml`. Feel free to copy it to `nostream/.nostr/settings.yaml` 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
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
relay:
nostream:
volumes:
- ${PWD}/.nostr.local:/home/node/
- ${PWD}/.nostr.local:/home/node
caddy:
image: caddy:2.6.2-alpine
container_name: caddy
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.tor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
container_name: tor
user: toruser
depends_on:
- relay
- nostream
volumes:
- ${PWD}/tor/torrc:/etc/tor/torrc
- ${PWD}/.nostr/tor/data:/var/lib/tor
Expand Down
Loading