Skip to content

Commit 7415a20

Browse files
mizchiclaude
andcommitted
refactor: rename CLUSTER_API_TOKEN to BIT_RELAY_AUTH_TOKEN
Public relay runs without API auth for P2P access. BIT_RELAY_AUTH_TOKEN is available for private relay deployments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1053366 commit 7415a20

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ Clone side → (response resolved)
4949

5050
## Auth
5151

52-
`CLUSTER_API_TOKEN` を設定すると `/api/v1/*``/ws` で Bearer 認証を要求します。
52+
`BIT_RELAY_AUTH_TOKEN` を設定すると `/api/v1/*``/ws` で Bearer 認証を要求します。
5353

5454
```bash
55-
export CLUSTER_API_TOKEN='secret-token'
55+
export BIT_RELAY_AUTH_TOKEN='secret-token'
5656
```
5757

5858
## Signing / TOFU
@@ -123,7 +123,7 @@ optional env:
123123

124124
- `HOST` (default: `127.0.0.1`)
125125
- `PORT` (default: `8788`)
126-
- `CLUSTER_API_TOKEN`
126+
- `BIT_RELAY_AUTH_TOKEN`
127127
- `RELAY_MAX_MESSAGES_PER_ROOM` (default: `1000`)
128128
- `PUBLISH_PAYLOAD_MAX_BYTES` (default: `65536`)
129129
- `RELAY_PUBLISH_LIMIT_PER_WINDOW` (default: `30`)

docs/host-bit-relay.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This guide explains how to deploy your own bit-relay instance on Cloudflare Workers.
44

5+
The public instance (`bit-relay.mizchi.workers.dev`) runs without API authentication so that anyone can participate in the P2P network. If you need a private relay for your team, deploy your own and configure `BIT_RELAY_AUTH_TOKEN`.
6+
57
## Prerequisites
68

79
- A [Cloudflare account](https://dash.cloudflare.com/sign-up)
@@ -62,7 +64,7 @@ All configuration is done via environment variables (set in the Cloudflare dashb
6264

6365
| Variable | Description | Default |
6466
|----------|-------------|---------|
65-
| `CLUSTER_API_TOKEN` | Bearer token for API authentication | (none, open) |
67+
| `BIT_RELAY_AUTH_TOKEN` | Bearer token for API authentication. When set, all `/api/v1/*` and `/ws` requests require this token. Leave unset for a public relay. | (none, open) |
6668

6769
### Signature Verification
6870

@@ -103,8 +105,8 @@ All configuration is done via environment variables (set in the Cloudflare dashb
103105
## Example: Setting Secrets
104106

105107
```bash
106-
# Require authentication
107-
wrangler secret put CLUSTER_API_TOKEN
108+
# Require API authentication (for private relays)
109+
wrangler secret put BIT_RELAY_AUTH_TOKEN
108110

109111
# Disable signature requirement (for testing)
110112
wrangler secret put RELAY_REQUIRE_SIGNATURE

src/cloudflare_worker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ interface DurableObjectStateLike {
4141
export interface RelayWorkerEnv {
4242
RELAY_ROOM?: DurableObjectNamespaceLike;
4343
GIT_SERVE_SESSION?: DurableObjectNamespaceLike;
44-
CLUSTER_API_TOKEN?: string;
44+
BIT_RELAY_AUTH_TOKEN?: string;
4545
RELAY_MAX_MESSAGES_PER_ROOM?: string;
4646
PUBLISH_PAYLOAD_MAX_BYTES?: string;
4747
RELAY_PUBLISH_LIMIT_PER_WINDOW?: string;
@@ -101,7 +101,7 @@ function parseBoolean(raw: string | undefined, fallback: boolean): boolean {
101101

102102
function buildOptions(env: RelayWorkerEnv): MemoryRelayOptions {
103103
return {
104-
authToken: env.CLUSTER_API_TOKEN,
104+
authToken: env.BIT_RELAY_AUTH_TOKEN,
105105
maxMessagesPerRoom: parsePositiveInt(
106106
env.RELAY_MAX_MESSAGES_PER_ROOM,
107107
DEFAULT_MAX_MESSAGES_PER_ROOM,

src/deno_main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function parseBoolean(raw: string | undefined, fallback: boolean): boolean {
5252

5353
function optionsFromEnv(): MemoryRelayOptions {
5454
return {
55-
authToken: Deno.env.get('CLUSTER_API_TOKEN') ?? undefined,
55+
authToken: Deno.env.get('BIT_RELAY_AUTH_TOKEN') ?? undefined,
5656
maxMessagesPerRoom: parsePositiveInt(
5757
Deno.env.get('RELAY_MAX_MESSAGES_PER_ROOM') ?? undefined,
5858
DEFAULT_MAX_MESSAGES_PER_ROOM,

0 commit comments

Comments
 (0)