aboutsummaryrefslogtreecommitdiffstats
path: root/lib/nostr.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nostr.ts')
-rw-r--r--lib/nostr.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/nostr.ts b/lib/nostr.ts
index ed1b2f42..63199bf8 100644
--- a/lib/nostr.ts
+++ b/lib/nostr.ts
@@ -1,4 +1,5 @@
import config from "$config";
+import { safeRelayUrl } from "$lib/safe-fetch";
import { db, g, s } from "$lib/db";
import { l, warn } from "$lib/logging";
import { scan } from "$lib/strfry";
@@ -125,7 +126,14 @@ export async function handleZap(invoice, sender = undefined) {
l("sending receipt");
- const relays = relays_tag.slice(1).filter((r) => r?.startsWith("ws"));
+ // Relay URLs come from the zap request, i.e. from whoever asked for the
+ // invoice; don't let them point our server at internal hosts.
+ const requested = relays_tag
+ .slice(1)
+ .filter((r) => typeof r === "string" && r.startsWith("ws"))
+ .slice(0, 10);
+ const relays = [];
+ for (const r of requested) if (await safeRelayUrl(r)) relays.push(r);
relays.push(config.nostr);
relays.map(async (url) => {
try {