Files
ukmesh/.env.example

498 lines
27 KiB
Bash

# ─────────────────────────────────────────
# MeshCore Analytics — Environment Config
# ─────────────────────────────────────────
# Copy this file to .env and fill in your values.
# Never commit .env to source control.
# Optional host interface for database, MQTT WebSocket, and Redis port
# publishing. The loopback default keeps infrastructure private; set this to a
# trusted LAN interface only when remote access is required and firewalled.
INFRA_BIND_ADDRESS=127.0.0.1
# Application listeners default to all container interfaces. The local stack
# sets both to 127.0.0.1 when running the processes directly on the host.
HTTP_HOST=0.0.0.0
METRICS_HOST=0.0.0.0
# Required for the backend/operator dashboard. Send as
# `Authorization: Bearer <token>` or `X-Operator-Token`.
# Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
OPERATOR_SITE_TOKEN=change_me_64_hex_chars
# ── Database ──────────────────────────────────────────────────────────────────
POSTGRES_DB=meshcore
POSTGRES_USER=meshcore
POSTGRES_PASSWORD=change_me_strong_password
# OLTP/API limit; analytical work retains its separate 15-minute pool budget.
DATABASE_STATEMENT_TIMEOUT_MS=30000
# Only backend analytics and region rebuild pools receive these estimates. Standalone
# callers with no explicit settings retain server defaults. The cache estimate
# allocates no memory; a larger VPS can explicitly review and override both.
DATABASE_ANALYTICS_RANDOM_PAGE_COST=4
DATABASE_ANALYTICS_EFFECTIVE_CACHE_SIZE=512MB
# Optional role-specific DSNs for backend, worker and migration processes.
# Main Compose forwards them to their owning services. URLs must resolve from
# inside the containers; enable enforcement after provisioning every role.
# DATABASE_URL=
# MESHCORE_HTTP_DATABASE_URL=
# MESHCORE_INGEST_DATABASE_URL=
# MESHCORE_WORKER_DATABASE_URL=
# MESHCORE_MIGRATE_DATABASE_URL=
# OWNER_DATABASE_URL=
# POSTGRES_EXPORTER_DATABASE_URL=
# With enforcement enabled, every role opened by the process needs its DSN.
# DATABASE_ROLE_ENFORCEMENT=false
# Region snapshot worker: only publishes complete, current privacy-certified
# results. Exceeding a source/deadline limit retains the previous snapshot;
# APIs withhold it after a privacy generation change until repair succeeds.
REGION_SCOPE_WINDOW_DAYS=92
REGION_SCOPE_MAX_PACKETS=550000
REGION_SCOPE_MAX_NODES=100000
# PostgreSQL scratch memory per region query operation; does not change server defaults.
REGION_SCOPE_WORK_MEM_KB=16384
# Set 1 to allow bitmap scans in the regional rebuild pool.
REGION_SCOPE_BITMAP_SCAN=0
REGION_SCOPE_STATEMENT_TIMEOUT_MS=120000
REGION_SCOPE_RUN_TIMEOUT_MS=180000
REGION_SCOPE_POLL_MS=30000
REGION_SCOPE_MAX_AGE_MS=900000
# Optional additional region probe names, comma separated.
MESHCORE_REGION_NAMES=
# ── MQTT broker ───────────────────────────────────────────────────────────────
# Internal docker network URL for Mosquitto WebSocket listener
MQTT_BROKER_URL=ws://mosquitto:9001
MQTT_CLIENT_ID=meshcore-analytics-ingest
# Optional independent control prefix; blank keeps the first business prefix.
# A separate prefix requires publish/subscribe ACLs for its exact probe topic.
MQTT_DELIVERY_PROBE_TOPIC_PREFIX=
# Optional exact Mosquitto system-topic metrics. Full local DEV enables this.
MQTT_BROKER_BACKLOG_MONITOR=false
MESHCORE_SITE_ID=ukmesh
# Site-to-site owner packet sharing is available to every authenticated owner.
# It does not enable a destination. Each owner/node selection starts off until
# that owner turns it on. Destination rows are operator-managed in PostgreSQL;
# leave the encryption key empty until a destination is provisioned.
OWNER_PACKET_SHARE_ENCRYPTION_KEY=
OWNER_PACKET_SHARE_POLL_INTERVAL_MS=5000
OWNER_PACKET_SHARE_BATCH_SIZE=25
# Owner dashboard RX-strength cache warmer. Keeps the last-hop series cached for
# every active MQTT owner's nodes (7d and 30d windows) so the owner dashboard
# chart never pays for a cold scan on open. Interval in ms (invalid or <= 0
# disables); NODE_DELAY paces the per-node loop within a pass.
OWNER_LAST_HOP_PREWARM_INTERVAL_MS=900000
OWNER_LAST_HOP_PREWARM_NODE_DELAY_MS=150
# Concurrent nodes, default 1, hard cap 2. Windows per node stay sequential.
# Logs every 30s include refresh/skip/failure counts, rate per second and ETA.
OWNER_LAST_HOP_PREWARM_CONCURRENCY=1
# Public feed endpoint settings. This is the authentication-locked UKmesh
# Mosquitto endpoint; opted-in active owners use their existing MQTT login for
# a read-only ACL grant. Account toggles remain off by default.
PUBLIC_FEED_PUBLISH_ENABLED=false
PUBLIC_FEED_BROKER_URL=
# Credentials for the backend MQTT client
MQTT_USERNAME=backend
MQTT_PASSWORD=change_me_strong_password
# Optional live password file. Mount a directory with a private, readable
# password file. The current broker, MQTT username and client ID stay fixed.
MQTT_INGEST_PASSWORD_HOST_DIR=./deploy/mqtt-credentials
# Bound in-process MQTT work during a burst. The backend uses a persistent
# session and QoS 1 subscriptions so the broker can replay acknowledged QoS 1
# publications after a reconnect; the packet batch writer also retries transient
# database failures.
MQTT_MAX_PAYLOAD_BYTES=65536
# One durable ingest connection acknowledges only after its database commit.
# Values above 1 are rejected until shared-session restart/resize recovery is qualified.
MQTT_INGEST_CONNECTIONS=1
# N>1 is currently rejected: persistent shared sessions have not passed broker restart/resize recovery.
# Reserved for a future qualified shared-subscription topology.
MQTT_INGEST_SHARE_GROUP=meshcore-ingest
# How long a packet batch may wait for more packets before flushing (ms;
# 0 flushes immediately).
MQTT_INGEST_FLUSH_MS=0
# Upper bound on queued-but-uncommitted packets; overflow leaves messages
# unacknowledged so the broker redelivers them instead of growing memory.
MQTT_INGEST_QUEUE_MAX=1000
# Archive and remove repeater visibility after its own observer MQTT feed has
# been silent for one month. Credentials and packet history are preserved.
STALE_MQTT_OBSERVER_CLEANUP_DAYS=30
STALE_MQTT_OBSERVER_CLEANUP_INTERVAL_MS=21600000
# Optional webhook for observer-registration notifications.
OBSERVER_REGISTRATION_WEBHOOK_URL=
# Packet identity read authority: "uid" (canonical content UID with hash
# fallback) or "hash" (rollback-compatible stored hash).
PACKET_IDENTITY_READ_AUTHORITY=uid
# Bound expensive statistics scans so they cannot exhaust the OLTP pool.
DATABASE_POOL_MAX=8
# Ordinary standalone workers use their own pools and credentials. Region
# polling and privacy rematerialization retain their specialized pool sizes.
WORKER_DATABASE_POOL_MAX=2
OWNER_DATABASE_POOL_MAX=2
# The lean runtime runs one statistics statement at a time; larger hosts can override it.
STATS_DB_QUERY_CONCURRENCY=1
# Multibyte fact coverage checks and rebuilds have their own deadlines.
# These settings use the same analytics pool and concurrency as charts.
STATS_BACKFILL_DURATION_BUDGET_MS=300000
STATS_BACKFILL_QUERY_TIMEOUT_MS=360000
# Aggregate reads remain off until the resumable backfill and shadow comparison
# have passed. Never leave shadow mode enabled after rollout validation.
STATS_AGGREGATE_READS_ENABLED=false
STATS_AGGREGATE_SHADOW_ENABLED=false
WARMUP_NETWORKS=ukmesh
PATH_LEARNING_INTERVAL_MS=3600000
# Logical storage budgets used by operator health. The backend measures only
# these mounted data volumes; container root filesystem usage is not reported.
HEALTH_DATABASE_BUDGET_BYTES=322122547200
HEALTH_REDIS_BUDGET_BYTES=4294967296
HEALTH_TERRAIN_BUDGET_BYTES=53687091200
HEALTH_LOG_BUDGET_BYTES=21474836480
# Destructive lifecycle actions are opt-in and additionally require the
# approval/backup/restore gates documented in docs/db-lifecycle.md.
DATA_LIFECYCLE_COMPRESSION_ENABLED=false
DATA_LIFECYCLE_RETENTION_ENABLED=false
DATA_LIFECYCLE_COMPRESSION_TARGETS=packets,packet_paths,node_status_samples,node_neighbor_samples
DATA_LIFECYCLE_RETENTION_TARGETS=packets,worker_health_snapshots,frontend_error_events,owner_alert_deliveries,owner_packet_share_deliveries,public_feed_deliveries,operational_check_results,observer_region_packet_sightings,observer_region_observer_sightings,link_job_commits,ml_model_variant_packet_results,packet_decryptions,observer_registration_requests,operator_audit_events,node_status_samples,node_neighbor_samples
BACKUP_RECEIPT_HOST_DIR=./backup-receipts
# Provision this directory independently of the signed receipt directory.
BACKUP_RECEIPT_VERIFY_KEY_HOST_DIR=./restore-receipt-trust
# SHA-256 of the verify key's DER SubjectPublicKeyInfo, provisioned out of band.
DATA_LIFECYCLE_RECEIPT_VERIFY_KEY_SHA256=
DATA_LIFECYCLE_RECEIPT_MAX_AGE_DAYS=7
# ── Redis ─────────────────────────────────────────────────────────────────────
# Docker Compose protects the internal Redis service with this password. The
# application passes it separately, so REDIS_URL can remain a plain endpoint.
REDIS_PASSWORD=change_me_strong_redis_password
# Optional endpoint override (for an external Redis service). Leave this as the
# internal service URL when using the bundled Compose stack.
REDIS_URL=redis://redis:6379
# ── JWT ───────────────────────────────────────────────────────────────────────
# Generate with: node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"
JWT_SECRET=change_me_64_hex_chars
# ── CORS / allowed origins ────────────────────────────────────────────────────
# Comma-separated list of browser origins allowed to access the API and WebSocket.
# For local development, the defaults in docker-compose.yml cover localhost.
# Set this to your production domains for deployment.
ALLOWED_ORIGINS=https://app.ukmesh.com,https://www.ukmesh.com,https://ukmesh.com,https://test.ukmesh.com,http://localhost:3003,http://localhost:3004
# Per-client public API requests/minute. Keep 120 in production; only isolated
# load-test projects should raise this.
API_RATE_LIMIT_MAX=120
# ── Frontend hostname (build-time) ────────────────────────────────────────────
# If you're running two separate frontends (an analytics app and a public website)
# on different hostnames, set this to the analytics app's hostname.
# When a visitor hits this hostname they see the analytics dashboard;
# all other hostnames serve the public website layout.
# Leave blank to always show the analytics dashboard (simpler single-domain setup).
VITE_APP_HOSTNAME=app.example.com
# Canonical whole-region RF coverage is generated by the pinned HopReach
# source in third_party/hopreach and exposed only on app.ukmesh.com.
RF_COVERAGE_ENABLED=true
HOPREACH_IMAGE=meshcore-analytics-hopreach:local
HOPREACH_CPUS=1.0
HOPREACH_CPU_WORKERS=1
HOPREACH_MEMORY_LIMIT=512m
# The worker ingress is loopback-only. Connect through a private tunnel.
HOPREACH_GPU_WORKER_PORT=19101
# HOPREACH_CONFIG_PATH=/private/operator/config.ukmesh.yaml
# Main Compose owns each service's lean memory ceiling. A larger VPS can set
# e.g. BACKEND_MEMORY_LIMIT=2g or LINK_WORKER_MEMORY_LIMIT=1536m; each override
# updates both memory and combined memory/swap constraints together.
# BACKEND_MEMORY_LIMIT=512m
# MQTT_INGEST_MEMORY_LIMIT=512m
# MQTT_INGEST_RUNTIME_POOL_MAX=2
# MQTT_INGEST_STOP_GRACE_PERIOD=40s
# The root docker-compose.postgres.yml policy is inherited by the existing local
# database. The DEV launcher clears caller settings and uses the defaults in that
# policy. Worker slots allow schedulers for retained DEV stores and active jobs.
# Use overrides only for the matching external infrastructure configuration.
POSTGRES_CPUS=2.5
POSTGRES_SHARED_BUFFERS=128MB
POSTGRES_MAINTENANCE_WORK_MEM=64MB
POSTGRES_AUTOVACUUM_WORK_MEM=16MB
POSTGRES_WORK_MEM=4MB
POSTGRES_AUTOVACUUM_MAX_WORKERS=4
POSTGRES_MAX_WORKER_PROCESSES=28
POSTGRES_TIMESCALE_BG_WORKERS=21
# Lossless full-page WAL compression trades some logging/replay CPU for less I/O.
# Normal Compose can explicitly override this, e.g. POSTGRES_WAL_COMPRESSION=off.
# Local DEV clears caller settings and uses the policy's lz4 default.
POSTGRES_WAL_COMPRESSION=lz4
# A larger VPS may explicitly consume the same policy in its existing external
# infrastructure Compose service and override the memory settings
# for that host. VPS adoption remains a separate, explicit deployment action.
# The infrastructure resolver does not apply it automatically or start another DB.
# CI retains its separate 4GiB/300 connection/24 worker policy; these variables do not
# replace that command. Local launchers retain their clean environment contract.
# ── MeshCore channel secrets ──────────────────────────────────────────────────
# Comma-separated list of AES-128 channel secrets for decrypting GroupText packets.
# Format: name:hex or bare hex (name defaults to first 6 chars of hex).
# The default MeshCore public channel key is always included automatically.
# Example: MESHCORE_CHANNEL_SECRETS=mychannel:9cd4e1f2a3b4c5d6e7f8a9b0c1d2e3f4,aabbccddeeff00112233445566778899
MESHCORE_CHANNEL_SECRETS=
# Extra channel names (comma-separated) whose plaintext the public API may
# serve. Committed PUBLIC_CHANNELS are always public; env-supplied secrets are
# confidential unless listed here. Empty = deny all env-supplied channels.
PUBLIC_DECRYPT_CHANNELS=
# Optional independent health-check channel configuration.
HEALTHCHECK_MESHCORE_CHANNEL_SECRETS=
# ── Health check app ──────────────────────────────────────────────────────────
# Optional MeshCore health-check web app for healthcheck.ukmesh.com.
# The app subscribes to observer packet MQTT and waits for users to send a
# generated code to the configured MeshCore channel.
HEALTHCHECK_APP_TITLE=UKMesh Health Check
# For direct image builds, take the verified revision from scripts/healthcheck-source.sh --verify.
HEALTHCHECK_SOURCE_REF=
HEALTHCHECK_TEST_CHANNEL_NAME=ukmeshtest
# Optional source entry name in MESHCORE_CHANNEL_SECRETS when the stored secret
# is named differently from the user-facing channel name.
HEALTHCHECK_TEST_CHANNEL_SECRET_SOURCE_NAME=test
# Optional override. If left blank, the container will reuse the matching
# name:secret entry from MESHCORE_CHANNEL_SECRETS.
HEALTHCHECK_TEST_CHANNEL_SECRET=
# Optional: restrict default scoring to a comma-separated list of observer public keys.
HEALTHCHECK_KNOWN_OBSERVERS=
# Stock defaults are 900 active / 14400 retained. Set both to 3600 if listed
# observers should have sent packets, status, or internal MQTT within one hour.
HEALTHCHECK_OBSERVER_ACTIVE_WINDOW_SECONDS=900
HEALTHCHECK_OBSERVER_RETENTION_SECONDS=14400
# Enable these after adding Cloudflare Turnstile keys.
HEALTHCHECK_TURNSTILE_ENABLED=false
HEALTHCHECK_TURNSTILE_SITE_KEY=
HEALTHCHECK_TURNSTILE_SECRET_KEY=
# ── Owner portal auth ─────────────────────────────────────────────────────────
# Signs owner-session cookies. Required: the backend refuses to start without
# it. Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
OWNER_COOKIE_SECRET=change_me_64_hex_chars
# Map MQTT usernames to owned node public keys (lowercase 64-hex), comma-separated.
# Format:
# OWNER_MQTT_USERNAME_MAP=username1=nodeid1|nodeid2,username2=nodeid3
# Example:
# OWNER_MQTT_USERNAME_MAP=node1=10cfab...713c95,node-ukmesh=20ed75...fe2ac
OWNER_MQTT_USERNAME_MAP=hermes-test=A2FF345C45EDDCCB453C9F6B1E9973296932CD4C32EC106541D972BFBF4A4FC5
# Owner authorization and ACL reconciliation fail closed by default. Shadow is
# an explicit opt-in for migration/CI stacks without an owner-auth database.
OWNER_AUTHORIZATION_MODE=enforce
OWNER_ACL_MODE=apply
# Public observer enrollment requires the broker session plugin and reloader.
MQTT_SELF_ENROLLMENT=false
MQTT_ENROLLMENT_ORIGIN=https://ukmesh.com
OWNER_ACL_UNMANAGED_USERS=backend,test,test2
# Explicit exception list for intentionally revoked/disabled accounts that
# should retain an empty broker stanza during apply cutover.
OWNER_ACL_ALLOW_EMPTY_USERS=
# Operator-approved read-only subscribers (comma-separated MQTT usernames).
# These accounts receive only the curated public packet namespace for opted-in,
# active owners; they never receive publish permission.
OWNER_ACL_PUBLIC_FEED_READ_USERS=
# Internal backend publish namespace for the curated public feed.
OWNER_ACL_SYSTEM_READWRITE_TOPICS=public/#
# Set these after exporting the reviewed pre-reset inventory. Readiness fails
# closed if database counts/grants, generations, or ACL readback differ.
OWNER_AUTH_INVENTORY_HOST_DIR=./backup-receipts
OWNER_AUTH_INVENTORY_BASELINE_PATH=
# Bounded analytics controls. These defaults are intentionally conservative;
# raise them only after reviewing query plans, RSS, and queue latency.
# One worker avoids duplicating the full path context on lean hosts; larger
# hosts can raise this existing concurrency setting up to eight workers.
PATH_RESOLVE_WORKERS=1
PATH_RESOLVE_BACKGROUND_QUEUE_MAX=128
PATH_RESOLVE_INTERACTIVE_QUEUE_MAX=32
PATH_RESOLVE_END_TO_END_TIMEOUT_MS=15000
PATH_RESOLVE_UNIQUE_INFLIGHT_MAX=34
PATH_RESOLVE_OBSERVER_VARIANTS_PER_PACKET_MAX=4
# Optional best-effort warmups; interval is clamped to 1 second..24 hours.
PATH_BETA_PRERESOLVE_ENABLED=0
PATH_BETA_PRERESOLVE_MIN_INTERVAL_MS=10000
PATH_SINGLE_HISTORY_HOURS=168
PATH_SINGLE_MAX_OBSERVERS=128
PATH_MULTI_HISTORY_WINDOW_HOURS=168
PATH_MULTI_MAX_SCAN_ROWS=2048
PATH_MULTI_MAX_OBSERVERS=128
LAZY_PATH_HISTORY_WINDOW_HOURS=168
LAZY_PATH_MAX_OBSERVATIONS=2048
LAZY_PATH_MAX_OBSERVERS=128
LAZY_PATH_MAX_UNIQUE_HASHES=64
LAZY_PATH_MAX_CANDIDATE_NODES=2048
PATH_LEARNING_MAX_TRAINING_PACKETS=120000
PATH_LEARNING_MAX_NODES=50000
PATH_LEARNING_MAX_LINKS=200000
PATH_LEARNING_MAX_AGGREGATE_KEYS=1000000
PATH_LEARNING_RUN_DEADLINE_MS=2700000
SPAM_MESSAGE_MAX_CANDIDATE_ROWS=10000
SPAM_MESSAGE_MAX_MESSAGES=2000
SPAM_MESSAGE_MAX_OBSERVERS=32
SPAM_MESSAGE_MAX_NORMALIZED_CHARS=512
SPAM_MESSAGE_MAX_INCIDENTS=100
SPAM_MESSAGE_MAX_CANDIDATE_CLUSTERS=64
SPAM_MESSAGE_MAX_EVIDENCE_MEMBERS=256
# Per-run work budget for the spam analyzer. Quiet days finish in ~4s; busy
# spam days need ~30-60s (relay-path origin resolution per public incident).
# Raise (e.g. 60000) if the analyzer log shows status=timed_out.
SPAM_MESSAGE_ANALYSIS_BUDGET_MS=5000
SPAM_MESSAGE_DB_TIMEOUT_MS=15000
STATS_UNIQUE_INFLIGHT_MAX=32
LINK_QUEUE_V3_PRODUCER_ENABLED=1
LINK_QUEUE_V3_MAX_JOBS=5000
LINK_QUEUE_V3_MAX_BYTES=67108864
LINK_QUEUE_V3_MAX_PAYLOAD_BYTES=32768
LINK_QUEUE_V3_DEAD_MAX_JOBS=1000
LINK_QUEUE_V3_DEAD_MAX_BYTES=33554432
LINK_QUEUE_V3_DEAD_RETENTION_MS=2592000000
LINK_QUEUE_V3_MAX_ATTEMPTS=5
LINK_QUEUE_V3_LEASE_MS=120000
LINK_REBUILD_ADMISSION_TIMEOUT_MS=1800000
LINK_REBUILD_COMPLETION_TIMEOUT_MS=21600000
LINK_REBUILD_MAX_NODES=5000
LINK_REBUILD_MAX_PHYSICAL_JOBS=200000
LINK_REBUILD_LEASE_MS=120000
MQTT_AUDIT_MAX_OBSERVATIONS_PER_SCAN=4096
# Audit-only broker log correlations: clamps are 100..60000 ms poll,
# 1..65536 clients, and 1000..86400000 ms TTL. Nonfinite values use defaults.
MQTT_CONN_MONITOR_POLL_MS=2000
MQTT_CONN_MONITOR_MAX_CLIENTS=4096
MQTT_CONN_MONITOR_CLIENT_TTL_MS=900000
MQTT_AUDIT_MAX_NODES_PER_USER=256
MQTT_AUDIT_RETENTION_DAYS=30
# ── Public map runtime features ───────────────────────────────────────────────
# Public map layers are independently controlled at runtime and fail closed.
# Change these values and recreate only the backend container (no image rebuild);
# connected clients refresh /api/runtime-config within the configured TTL.
PUBLIC_FEATURE_INFERRED_NODES_ENABLED=true
PUBLIC_FEATURE_PACKET_ARCS_ENABLED=true
PUBLIC_FEATURE_HEATMAP_ENABLED=false
# Phase B: enable only after migration 063 and Phase A participation data exist.
PUBLIC_FEATURE_REGION_SCOPING_ENABLED=false
PUBLIC_FEATURE_CONFIG_TTL_SECONDS=30
SRTM_MAX_LINK_TILES=64
SRTM_CACHE_MAX_BYTES=21474836480
# Synthetic monitoring and optional alert delivery
SYNTHETIC_INTERVAL_MS=60000
SYNTHETIC_FULL_INTERVAL_MS=720000
SYNTHETIC_SUCCESS_TTL_MS=960000
SYNTHETIC_TIMEOUT_MS=10000
SYNTHETIC_INITIAL_STATE_TIMEOUT_MS=35000
SYNTHETIC_FAILURE_THRESHOLD=3
ALERT_WEBHOOK_URL=
MAINTENANCE_ACTIVE=0
MAINTENANCE_MESSAGE=
# Per-client WebSocket safeguards for browser input and slow consumers.
WS_MAX_PAYLOAD_BYTES=65536
WS_INITIAL_STATE_DB_TIMEOUT_MS=30000
WS_MAX_QUEUE_BYTES=8388608
WS_MAX_BUFFERED_BYTES=33554432
WS_INITIAL_STATE_MAX_BYTES=16777216
# ── Monitoring ────────────────────────────────────────────────────────────────
# Required by docker-compose.yml; provision before starting the stack.
GRAFANA_ADMIN_PASSWORD=change_me_strong_password
# ── Cloudflare Tunnel ─────────────────────────────────────────────────────────
# Get from: Cloudflare Zero Trust → Access → Tunnels → your tunnel → token
CLOUDFLARE_TUNNEL_TOKEN=paste_your_tunnel_token_here
# ── Anubis bot protection ─────────────────────────────────────────────────────
# Signing key shared across all Anubis sidecar containers.
# Generate with: openssl rand -hex 32
# Keep this secret — it signs the PoW challenge cookies.
ANUBIS_ED25519_PRIVATE_KEY_HEX=
# ── App port ──────────────────────────────────────────────────────────────────
PORT=3000
# ── Message-spam detection (Spam Watch) ───────────────────────────────────────
# Detects repeated near-duplicate chat messages and groups them into incidents
# for the public /spam dashboard. All defaults are sensible; see
# docs/spam-detection.md for the full list and tuning guidance.
SPAM_MESSAGE_ANALYZER_ENABLED=true
SPAM_MESSAGE_INTERVAL_MS=300000
SPAM_MESSAGE_WINDOW_HOURS=24
# Min distinct near-duplicate messages before a cluster can be an incident.
# Legit chatter is a few repeats; real spam is dozens+. Raise to reduce false
# positives from small bursts of normal traffic.
SPAM_MESSAGE_MIN_TRANSMISSIONS=8
# Confidence floor for the public list / "ongoing" status (0..1).
SPAM_MESSAGE_PUBLIC_MIN_SCORE=0.5
# At/above this many near-duplicate messages a qualified cluster is treated as a
# sustained automated flood and scored up (unless it is plain test/connectivity
# traffic). Catches templated floods even when they embed the word "test".
SPAM_MESSAGE_FLOOD_MIN_MESSAGES=25
# Rotating-ID botnet detection: many single-shot, machine-named sender IDs
# blasting the same text in bursts (see docs/spam-detection.md). A cluster
# qualifies when >= MIN_SENDERS distinct senders, >= SINGLE_SHOT_SHARE of them
# appear exactly once in the window, >= MACHINE_NAME_SHARE have keygen-style
# names, and >= MIN_BURST_SENDERS land inside one burst window.
SPAM_MESSAGE_ROTATING_MIN_SENDERS=5
SPAM_MESSAGE_ROTATING_SINGLE_SHOT_SHARE=0.8
SPAM_MESSAGE_ROTATING_MACHINE_NAME_SHARE=0.5
SPAM_MESSAGE_ROTATING_MIN_BURST_SENDERS=3
# Channel labels excluded from detection (comma-separated). The test channel
# carries repeated test traffic by design. NOTE: a flood that also hits other
# channels (e.g. Public) is still caught via those copies.
SPAM_MESSAGE_EXCLUDE_CHANNELS=test
# Origin estimation. Primary method resolves relay PATHS: the first repeater in
# the path is the source of truth, resolved next to the closest (lowest-hop)
# receiver. Falls back to the observer-signal estimate (closest-receiver cohort,
# min-hop + slack) when paths can't be resolved. Per-hop km = radius per hop.
SPAM_MESSAGE_ORIGIN_USE_PATHS=true
SPAM_MESSAGE_ORIGIN_PATH_MAX_PACKETS=40
SPAM_MESSAGE_ORIGIN_PATH_MIN_VOTES=3
SPAM_MESSAGE_ORIGIN_PATH_CLUSTER_KM=45
SPAM_MESSAGE_ORIGIN_PATH_AMBIGUOUS_WEIGHT=0.4
SPAM_MESSAGE_ORIGIN_NEAR_HOP_MAX=2
SPAM_MESSAGE_ORIGIN_NEAR_HOP_SLACK=1
SPAM_MESSAGE_ORIGIN_PER_HOP_KM=12
# Numeric host group allowed to read the system journal (usually 999).
JOURNAL_GID=999
# ------------------------------------------------------------------------------
# RAM-first ingestion (draft; see docs/ram-first-ingestion.md).
# Default "durable" keeps the existing acknowledge-after-commit pipeline.
# "ram" admits validated packets to a bounded Redis stream (PUBACK after RAM
# admission, batched persistence in the background): recent telemetry can be
# lost on crash in exchange for lower database load. Privacy-critical state
# stays durable; the database remains the authoritative historical store.
# MQTT_INGEST_MODE=durable
# MQTT_RAM_BATCH_SIZE=100
# MQTT_RAM_MAX_AGE_MS=120000
# MQTT_RAM_QUEUE_MAX_PACKETS=5000
# MQTT_RAM_QUEUE_MAX_BYTES=33554432
# MQTT_RAM_STREAM_KEY=meshcore:ingest:pending
# MQTT_RAM_CONSUMER_GROUP=ingest-writers
# MQTT_RAM_CONSUMER_NAME=backend
# MQTT_RAM_DRAIN_DEADLINE_MS=600000
# Keep the budget below the shared Redis maxmemory; code caps this at 64 MiB.
# Switching back to durable mode requires draining the acknowledged RAM queue
# with the standalone writer before stopping RAM processing.
# Authenticated internal alert ingress. Provision the same secret into the
# ignored logging/alert_receiver_token file for Alertmanager's bearer auth.
ALERT_RECEIVER_TOKEN=
# Restore receipt trust is provisioned separately from backup-receipts.
# Pin SHA-256 of the public key's DER SPKI bytes; the verifier fails closed
# when the key is co-located with receipts or this pin is missing/mismatched.
RESTORE_RECEIPT_TRUST_HOST_DIR=./restore-receipt-trust
# Maximum pending durable alert forwards; full queues return HTTP 503 for retry.
ALERT_FORWARD_QUEUE_MAX=1000
# Operational notifications require an approved forwarding destination.
# Leave empty for archive-only mode (receiver readiness remains degraded).
ALERT_FORWARD_URL=