Skip to content

Commit 880beaa

Browse files
committed
chore: merge upstream main and resolve NIP-25/NIP-12 conflicts
2 parents 8b2f9a2 + d8f62b4 commit 880beaa

49 files changed

Lines changed: 1061 additions & 79 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/dark-places-tickle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nostream": patch
3+
---
4+
5+
Fix root HTML negotiation and subpath-aware template links behind trusted proxies.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"nostream": patch
3+
---
4+
5+
Implement geohash wildcard/prefix behavior for `#g` filters (closes #265): a
6+
criterion ending in `*` matches any event `g` tag whose value starts with the
7+
prefix before `*`; exact matching (no `*`) is unchanged. Only normal geohash
8+
prefixes are intended as input. This is a Nostream extension, not part of
9+
NIP-12.

.changeset/huge-trains-nail.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nostream": patch
3+
---
4+
5+
Use timingSafeEqual for Nodeless webhook HMAC verification and guard against missing NODELESS_WEBHOOK_SECRET

.changeset/jolly-canyons-glow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nostream": minor
3+
---
4+
5+
perf: added k6 performance tests for connection and message rate limiting
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nostream": patch
3+
---
4+
5+
Fix Redis cache connection config to skip AUTH when `REDIS_PASSWORD` is unset

CONTRIBUTING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,41 @@ To observe client and subscription counts in real-time during a test, you can in
302302
docker compose logs -f nostream
303303
```
304304

305+
## Performance Testing (k6)
306+
307+
Nostream includes k6-based load tests to validate rate limiter behavior under concurrent WebSocket
308+
connections. These tests verify that connection and message rate limits are correctly enforced.
309+
310+
### Prerequisites
311+
312+
Install [k6](https://grafana.com/docs/k6/latest/set-up/install-k6/) before running performance
313+
tests. k6 is a standalone Go binary and is not included as an npm dependency.
314+
315+
### Running the Tests
316+
317+
Ensure the relay is running first (`pnpm run cli -- start`), then:
318+
319+
```bash
320+
# Test connection rate limiting
321+
pnpm run cli -- dev test:perf:connection
322+
323+
# Test message rate limiting
324+
pnpm run cli -- dev test:perf:message
325+
```
326+
327+
To test against a different relay instance:
328+
329+
```bash
330+
k6 run -e RELAY_URL=ws://your-host:8008 test/performance/connection-limiting-k6.ts
331+
```
332+
333+
### What the Tests Validate
334+
335+
- **Connection rate limiter** — Ramps concurrent connections through multiple stages and verifies
336+
the relay rejects excess connections beyond the configured limit (default: 12 conn/sec).
337+
- **Message rate limiter** — Opens WebSocket connections and sends continuous REQ messages,
338+
verifying the relay returns NOTICE rejections when the message rate limit is exceeded.
339+
305340
## Local Quality Checks
306341

307342
Run dead code and dependency analysis before opening a pull request:

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
"test:load": "node -r ts-node/register ./scripts/security-load-test.ts",
7878
"smoke:nip03": "node -r ts-node/register scripts/smoke-nip03.ts",
7979
"test:integration": "cucumber-js",
80+
"test:performance:connection-rate-limit": "k6 run test/performance/connection-limiting-k6.ts",
81+
"test:performance:message-rate-limit": "k6 run test/performance/message-limiting-k6.ts",
8082
"cover:integration": "nyc --report-dir .coverage/integration pnpm run test:integration -p cover",
8183
"export": "node --env-file-if-exists=.env -r ts-node/register src/scripts/export-events.ts",
8284
"docker:compose:start": "pnpm run cli -- start",
@@ -125,6 +127,7 @@
125127
"@types/chai-as-promised": "^7.1.5",
126128
"@types/express": "4.17.21",
127129
"@types/js-yaml": "4.0.5",
130+
"@types/k6": "^1.7.0",
128131
"@types/mocha": "^9.1.1",
129132
"@types/node": "^24.12.2",
130133
"@types/pg": "^8.6.5",
@@ -154,10 +157,9 @@
154157
"node": ">=24.14.1"
155158
},
156159
"dependencies": {
157-
"@getalby/sdk": "^5.0.0",
158160
"@clack/prompts": "^1.2.0",
161+
"@getalby/sdk": "^5.0.0",
159162
"@noble/secp256k1": "1.7.1",
160-
"accepts": "^1.3.8",
161163
"axios": "^1.15.0",
162164
"cac": "^7.0.0",
163165
"colorette": "^2.0.20",

pnpm-lock.yaml

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/get-invoice.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</head>
1010
<body lang="en">
1111
<main class="container">
12-
<form method="post" action="/invoices">
12+
<form method="post" action="{{path_prefix}}/invoices">
1313
<div class="row">
1414
<div class="col">
1515
<h1 class="mt-4 mb-4 text-center text-nowrap">{{name}}</h1>
@@ -46,7 +46,7 @@ <h1 class="mt-4 mb-4 text-center text-nowrap">{{name}}</h1>
4646
<div class="form-check">
4747
<input class="form-check-input" type="checkbox" id="tosAccepted" name="tosAccepted" value="yes" required>
4848
<label class="form-check-label" for="tosAccepted">
49-
I have read and agree to the <a href="/terms" class="card-link" target="_blank" rel="noopener noreferrer">Terms of Service</a>
49+
I have read and agree to the <a href="{{path_prefix}}/terms" class="card-link" target="_blank" rel="noopener noreferrer">Terms of Service</a>
5050
</label>
5151
</div>
5252
</div>

resources/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ <h5 class="card-title">Admission Required</h5>
4646
This relay requires a one-time admission fee of <strong>{{amount}} sats</strong>
4747
to publish events. Reading events is free.
4848
</p>
49-
<a href="/invoices" class="btn btn-warning">Pay Admission Fee</a>
49+
<a href="{{path_prefix}}/invoices" class="btn btn-warning">Pay Admission Fee</a>
5050
</div>
5151
</div>
5252

@@ -62,9 +62,9 @@ <h5 class="card-title">Open Relay</h5>
6262

6363
<!-- Legal links -->
6464
<div class="d-flex justify-content-center gap-3 mt-2 mb-5">
65-
<a href="/terms" class="text-muted small">Terms of Service</a>
65+
<a href="{{path_prefix}}/terms" class="text-muted small">Terms of Service</a>
6666
<span class="text-muted small">·</span>
67-
<a href="/privacy" class="text-muted small">Privacy Policy</a>
67+
<a href="{{path_prefix}}/privacy" class="text-muted small">Privacy Policy</a>
6868
</div>
6969

7070
</div>

0 commit comments

Comments
 (0)