Skip to content

Commit bb9b186

Browse files
feat: add --public-url flag for explicit announce URL
1 parent e5b5773 commit bb9b186

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/cli.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function parseArgs(argv: string[]): CliArgs {
3838
case '--announce': args.announce = true; break
3939
case '--announce-relays': args.announceRelays = argv[++i]; break
4040
case '--announce-key': args.announceKey = argv[++i]; break
41+
case '--public-url': args.publicUrl = argv[++i]; break
4142
case '-h': case '--help': printHelp(); process.exit(0);
4243
case '-v': case '--version': printVersion(); process.exit(0);
4344
default:
@@ -97,6 +98,7 @@ function printHelp(): void {
9798
--announce Publish service on Nostr relays for discovery
9899
--announce-relays <urls> Comma-separated relay URLs (wss://...)
99100
--announce-key <hex> Nostr secret key for signing (auto-generated if omitted)
101+
--public-url <url> Public URL for announcements (overrides tunnel URL)
100102
101103
Storage:
102104
--storage <type> memory | sqlite (default: memory)
@@ -280,7 +282,7 @@ export async function main(argv: string[] = process.argv): Promise<void> {
280282
if (config.announceRelays.length === 0) {
281283
logger.warn('--announce enabled but no --announce-relays provided')
282284
} else {
283-
const publicUrl = tunnelResult?.url ?? `http://localhost:${config.port}`
285+
const publicUrl = config.publicUrl ?? tunnelResult?.url ?? `http://localhost:${config.port}`
284286

285287
const { announceService } = await import('402-announce')
286288
const { randomBytes } = await import('node:crypto')

src/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export interface TokenTollConfig {
6161
announceRelays: string[]
6262
/** Hex Nostr secret key for signing announcements. */
6363
announceKey: string
64+
/** Explicit public URL for announcements (overrides tunnel URL). */
65+
publicUrl?: string
6466
}
6567

6668
export interface CliArgs {
@@ -89,6 +91,7 @@ export interface CliArgs {
8991
announce?: boolean
9092
announceRelays?: string
9193
announceKey?: string
94+
publicUrl?: string
9295
}
9396

9497
export interface FileConfig {
@@ -406,6 +409,7 @@ export function loadConfig(
406409
const announce = args.announce ?? (env.ANNOUNCE === 'true' || false)
407410
const announceRelays = (args.announceRelays ?? env.ANNOUNCE_RELAYS ?? '').split(',').filter(Boolean)
408411
const announceKey = args.announceKey ?? env.ANNOUNCE_KEY ?? ''
412+
const publicUrl = args.publicUrl ?? env.PUBLIC_URL ?? undefined
409413

410414
return {
411415
upstream: upstream.replace(/\/+$/, ''),
@@ -437,5 +441,6 @@ export function loadConfig(
437441
announce,
438442
announceRelays,
439443
announceKey,
444+
publicUrl,
440445
}
441446
}

0 commit comments

Comments
 (0)