Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ A clear description of the change and why it was made.

## Checklist

- [ ] Docs match the actual files in `docker-deployment-*/` and `app_config/`
- [ ] Variable tables in the README are in sync with the example config files
- [ ] This PR targets `dev`, not `main`
- [ ] Docs match the actual files in `docker-deployment-*/` and `app_config/`, and the code where the behaviour lives there
- [ ] Variable tables in the README and `docs/configuration.md` are in sync with the example config files
- [ ] Internal and external links resolve
- [ ] Any changed `docker-compose.yml` passes `docker compose config`
- [ ] No real secrets, passwords, channel keys, or MQTT credentials committed
- [ ] No em dashes
- [ ] I have read [CONTRIBUTING.md](../CONTRIBUTING.md)

## Notes for reviewers
Expand Down
69 changes: 56 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contributing to Beacon

Thank you for your interest in contributing. This page is the shared workflow for all three
Beacon repositories:
Thank you for your interest in contributing. This page is the shared workflow for every Beacon
repository:

- [beacon-docs](https://github.com/MeshCore-Beacon/beacon-docs), this repo: deployment,
configuration and operator documentation.
Expand All @@ -11,14 +11,22 @@ Beacon repositories:
- [beacon-web](https://github.com/MeshCore-Beacon/beacon-web): the frontend. Its own
[CONTRIBUTING.md](https://github.com/MeshCore-Beacon/beacon-web/blob/main/CONTRIBUTING.md)
covers TypeScript style, tests and the feature layout.
- [beacon-flutter-app](https://github.com/MeshCore-Beacon/beacon-flutter-app): BEACON Mobile, the
iOS and Android app. Its own
[CONTRIBUTING.md](https://github.com/MeshCore-Beacon/beacon-flutter-app/blob/main/CONTRIBUTING.md)
covers Dart style, tests and app releases.
- [beacon-push](https://github.com/MeshCore-Beacon/beacon-push): the push server that forwards
alerts to the app. Its own
[CONTRIBUTING.md](https://github.com/MeshCore-Beacon/beacon-push/blob/main/CONTRIBUTING.md)
covers what the relay may and may not do.

Please read this before opening a PR anywhere.

## Before you start

**Talk first for anything bigger than a small fix.** On beacon-server and beacon-web, open or
comment on an issue before starting work, so maintainers can say if something is already in
progress or out of scope. Issues are disabled on beacon-docs; for a docs restructure, a new
**Talk first for anything bigger than a small fix.** On the code repos, open or comment on an
issue before starting work, so maintainers can say if something is already in progress or out of
scope. Issues are disabled on beacon-docs; for a docs restructure, a new
deployment type or a correction you are unsure about, reach out on the
[MeshCore Canada Discord](https://discord.gg/Gz3KvJx2hf). For typos, broken links and small
clarifications, just open a PR.
Expand All @@ -33,24 +41,46 @@ appear to be unreviewed AI output may be closed without further comment.

## Branches

Every Beacon repo, docs included:
Every Beacon repo, docs included, has the same two branches:

- `main` holds stable releases only and is protected. Never target it directly.
- `dev` is active development. All PRs target `dev`.
- `dev` is where all work lands. Contributors open pull requests against `dev`; maintainers
commit to it directly.
- `main` holds releases only and is protected. It changes one way: a release pull request from
`dev` into `main`, merged as a merge commit by a maintainer. A check in every repo
(`main-source-guard.yml`) fails any pull request into `main` that does not come from that
repo's own `dev` branch, so never target `main` with a change.

In beacon-docs, `main` describes the current release and `dev` describes what is coming next.
The release steps are in [Releases and versioning](docs/releases.md).

## Workflow

1. Fork, or create a branch from `dev`.
1. Fork the repo and create a branch from `dev`.
2. Make your change.
3. Run that repo's checklist (below for docs; in each code repo's CONTRIBUTING for code).
4. Open a pull request with a clear description of what changed and why, referencing any
related issue.
3. Run that repo's checks (the table below).
4. Open a pull request against `dev` with a clear description of what changed and why,
referencing any related issue.

## Checks before you open a pull request

CI runs these on every pull request. Run them first; each repo's own CONTRIBUTING explains them.

| Repo | Run |
|---|---|
| beacon-server | `go build ./...`, `gofmt -l .` (must print nothing), `go vet ./...`, `go test ./...`, `govulncheck ./...`. After changing SQL under `db/`, `sqlc generate`. After changing a handler or an API type, `swag init -g cmd/beacon/main.go -o docs --parseInternal --parseDependency`; CI fails when the committed Swagger is out of date. |
| beacon-web | `npm run build` (the only real typecheck), `npm run lint`, `npm test` |
| beacon-flutter-app | `dart format --set-exit-if-changed .`, `flutter analyze`, `flutter test` |
| beacon-push | `go build ./...`, `gofmt -l .` (must print nothing), `go vet ./...`, `go test -race ./...` |
| beacon-docs | The [docs checklist](#checklist-before-opening-a-docs-pr) below |

beacon-server's CI also runs a selected set of integration tests and query plan checks against
PostgreSQL 16, which a plain `go test ./...` skips. If your change touches SQL, read the server's
CONTRIBUTING for how to run them locally, and watch CI on your pull request.

## Running the full stack locally

Most changes to either code repo are easier to check against the other one running next to it.
Most changes to a client or to the server are easier to check against the other running next to
it.

**beacon-server**, with a throwaway PostgreSQL in Docker:

Expand Down Expand Up @@ -90,6 +120,19 @@ you would rather have the browser talk to `localhost:8080` directly, add
`websocket: {allowed_origins: [http://localhost:5173]}` to the server's `config.yaml` instead.
Open `http://localhost:5173`.

**beacon-flutter-app**, against the same server:

```bash
git clone https://github.com/MeshCore-Beacon/beacon-flutter-app.git && cd beacon-flutter-app
flutter pub get
flutter run
```

The app has no built-in server. On first launch tap **Add server** and enter the address of
your local beacon-server as the device sees it: your computer's LAN address (for example
`http://192.168.1.20:8080`) on a phone, or `http://10.0.2.2:8080` on the Android emulator, where
`localhost` is the emulator itself.

## Checklist before opening a docs PR

- **Docs match reality.** If you change a variable, path, command or image name, check it
Expand Down
41 changes: 32 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@

Beacon watches a MeshCore mesh from above. It listens to the MQTT brokers that observers publish
into, decodes every LoRa packet it hears, stores it, and shows the network live: packets,
channels, nodes, observers, routes, traces and stats, on a map and in lists.
channels, nodes, observers, routes, traces and stats, on a map and in lists. The same server
feeds the web app and BEACON Mobile, the iOS and Android app.

A plain install does all of that with no sign-in. The rest is optional and off until you turn
it on:

- [Repeater polling](docs/repeater-polling.md): observers ask nearby repeaters for battery,
temperature, counters and sensor readings, and Beacon stores and charts them.
- [User accounts](docs/accounts.md): sign-in for the web app and the mobile app, with an
[Atlas](docs/atlas.md) watchlist that follows the account.
- [Requested telemetry](docs/telemetry-requests.md): signed-in users ask for a repeater to be
polled.
- [Alerts](docs/alerts.md): email and push notices when a radio on a user's Atlas goes quiet,
runs low on battery, reboots and more.

This repo is where you deploy and operate it. The code lives in
[beacon-server](https://github.com/MeshCore-Beacon/beacon-server) (the API and ingest) and
[beacon-web](https://github.com/MeshCore-Beacon/beacon-web) (the frontend).
[beacon-server](https://github.com/MeshCore-Beacon/beacon-server) (the API and ingest),
[beacon-web](https://github.com/MeshCore-Beacon/beacon-web) (the web frontend) and
[beacon-flutter-app](https://github.com/MeshCore-Beacon/beacon-flutter-app) (BEACON Mobile).

> **Coming from 1.x?** 2.0.0 needs a fresh database and a few config changes. Read
> [Upgrading](docs/upgrading.md) before you pull new images.
Expand Down Expand Up @@ -136,7 +150,7 @@ The `app` and `web` services pull public images from GitHub Container Registry
`docker login` is needed.

The compose files use `latest`, which follows stable releases. To decide for yourself when to
upgrade, pin both images to the same release line (`:2.0`) or an exact release (`:2.0.0`); server
upgrade, pin both images to the same release line (`:2.3`) or an exact release (`:2.3.4`); server
and web share `major.minor`. Tags, versioning and the release process are in
[Releases and versioning](docs/releases.md). A `403 Forbidden` on pull means the package has
gone private; see [Troubleshooting](docs/troubleshooting.md#docker-compose-up-fails-with-403-forbidden-pulling-an-image).
Expand All @@ -154,38 +168,47 @@ gone private; see [Troubleshooting](docs/troubleshooting.md#docker-compose-up-fa
- [Reverse proxy](docs/reverse-proxy.md): Caddy, nginx, Apache, rate limits, split origins, and an RSA certificate for observers.
- [Securing a deployment](docs/security.md): the admin key, the listener, origins, bans.
- [Day-to-day operations](docs/operations.md): health, logs, retention, backup and restore.
- [Upgrading](docs/upgrading.md): 2.0.0 from 1.x, 2.1, 2.3.0 from 2.2.0, 2.3.1 from 2.3.0, and routine upgrades.
- [Upgrading](docs/upgrading.md): 2.0.0 from 1.x, 2.1, each release from 2.3.0 to 2.3.4, and routine upgrades.
- [Troubleshooting](docs/troubleshooting.md): symptom, cause, fix.
- [Releases and versioning](docs/releases.md): image tags and how releases are cut.

**Understand it**

- [High level design](docs/high-level-design.md): how it works, the schema, the ingest pipeline.
- [API contract](docs/api-contract.md): REST, WebSocket, admin endpoints, errors.
- [Observer directory](docs/observer-directory.md): the observer list endpoint with traffic counts for a time window.
- [Atlas](docs/atlas.md): the watchlist of nodes and observers (per browser, or synced to an account), what its cards mean, and its export file.
- [Backup and export](docs/backup-export.md) and [CPU profiling](docs/profiling.md).

**BEACON Mobile**

- [Support](docs/mobile/support.md) and [privacy policy](docs/mobile/privacy.md): the pages the
app stores link to.

**Change it**

- [Contributing](CONTRIBUTING.md): the workflow for all three repos and running the full stack
- [Contributing](CONTRIBUTING.md): the workflow for every Beacon repo and running the full stack
locally.
- beacon-server: [historical stats](https://github.com/MeshCore-Beacon/beacon-server/blob/main/docs/historical-stats.md),
how the hourly rollups work.
- beacon-web: [translations](https://github.com/MeshCore-Beacon/beacon-web/blob/main/docs/translations.md),
adding a language.

Deployment folders are `docker-deployment-type1/` and `docker-deployment-type2/`; templates
and proxy configs (`.env`, `config.yaml`, Caddy, nginx, Apache, fail2ban) are in `app_config/`;
brand assets are in `logos/`.
and proxy configs (`.env`, `config.yaml`, Caddy, nginx, Apache, [fail2ban](app_config/fail2ban/README.md))
are in `app_config/`; brand assets are in `logos/`. `deploy/push/` holds the files for the project's
own [push server](deploy/push/README.md); a Beacon server does not need them.

## Source repositories

- **beacon-server** (API and ingest): [github.com/MeshCore-Beacon/beacon-server](https://github.com/MeshCore-Beacon/beacon-server), image `ghcr.io/meshcore-beacon/beacon-server`
- **beacon-web** (frontend): [github.com/MeshCore-Beacon/beacon-web](https://github.com/MeshCore-Beacon/beacon-web), image `ghcr.io/meshcore-beacon/beacon-web`
- **beacon-flutter-app** (BEACON Mobile, iOS and Android): [github.com/MeshCore-Beacon/beacon-flutter-app](https://github.com/MeshCore-Beacon/beacon-flutter-app)
- **beacon-push** (the push server that forwards alerts to the app): [github.com/MeshCore-Beacon/beacon-push](https://github.com/MeshCore-Beacon/beacon-push)

## Maintainers: publishing images

Container images are published automatically by each repo's `docker-publish.yml` workflow on
The server and web images are published automatically by each repo's `docker-publish.yml` workflow on
pushes to `main` and `dev` and on `v*` tags. GHCR packages are private by default, which makes
anonymous `docker pull` fail with `403 Forbidden`. To make a package publicly pullable, once per
package:
Expand Down
14 changes: 8 additions & 6 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

This is the **documentation and deployment** repository for Beacon. If you have
found a vulnerability in the Beacon application itself (server, web, mobile app or
push server), please
report it against the relevant code repository:
push server), please report it against the relevant code repository:

- [beacon-server](https://github.com/MeshCore-Beacon/beacon-server)
- [beacon-web](https://github.com/MeshCore-Beacon/beacon-web)
Expand All @@ -12,8 +11,8 @@ report it against the relevant code repository:

## Reporting a Vulnerability

Please do not report security issues through public GitHub. Issues are disabled
on this repository.
Please do not report security issues through public GitHub issues or pull
requests, in any Beacon repository. Issues are disabled on this one.

Instead, contact the maintainers directly via the MeshCore Canada Discord
server: [MeshCore Canada Discord](https://discord.gg/Gz3KvJx2hf); reach out to
Expand All @@ -32,7 +31,10 @@ The Docker deployments in this repo expose `db`, `redis`, and `app` only on
`127.0.0.1`, with Caddy terminating TLS on ports 80/443. Beacon's REST reads
and WebSocket feed are public by design; only `/api/v1/admin/*` needs a bearer
key (`BEACON_API_KEY`), and abuse is limited by per-IP rate limits. With user
accounts on, the `/api/v1/auth` and `/api/v1/me` routes need a signed-in user. It is
intended to sit behind that reverse proxy, listed in `server.trusted_proxies`.
accounts on, the sign-up, sign-in and password reset routes under
`/api/v1/auth` take no credentials and have their own per-IP limits, and the
`/api/v1/me` routes need a signed-in user. The server is meant to sit
behind that reverse proxy, with the proxy listed in `server.trusted_proxies`.
Keep this in mind when assessing the severity of any findings, and never expose
the database, Redis, or the raw app port to the public internet.
[Securing a deployment](docs/security.md) has the full checklist.
4 changes: 2 additions & 2 deletions app_config/config.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ websocket:
# prevents startup. Omitted or empty (default) means the built-in floor only.
# Takes effect on restart.
#mobile:
# min_app_version: "2.3.0" # BEACON Mobile; built-in floor: 2.3.0
# min_app_version: "2.3.4" # BEACON Mobile; built-in floor: 2.3.4
#web:
# min_web_version: "2.3.0" # Beacon Web; built-in floor: 2.3.0
# min_web_version: "2.3.4" # Beacon Web; built-in floor: 2.3.4

# CORS configuration.
# Controls which origins, methods and headers are allowed for cross-origin requests.
Expand Down
6 changes: 4 additions & 2 deletions app_config/fail2ban/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Two deployment shapes, two file sets:

| Shape | Edge | Files |
|---|---|---|
| Caddy in Docker (type 1, e.g. dev.meshcore.ca) | `docker-deployment-type1/data/Caddy/…` | `fail2ban/caddy/` |
| Caddy in Docker (type 1, e.g. dev.meshcore.ca; the type 2 server host has the same Caddy files under `docker-deployment-type2/server/`) | `docker-deployment-type1/data/Caddy/…` | `fail2ban/caddy/` |
| Host Apache in front of the containers (analyzer.meshmapper.net) | `app_config/apache/analyzer-vhost.snippet.conf` | `fail2ban/apache/` |

## 1. Edge: log + client-IP hygiene + manual block list
Expand Down Expand Up @@ -55,7 +55,9 @@ Three jails per box, same thresholds:
| `beacon-api-sustained` | every `/api/` request | 1,000 in 1 h | a paced scraper (the day-0 Pi ran ~135/min for hours) never trips the flood rule; real sessions peak ~300/h |

All three use `backend = polling` (the Debian default `systemd` cannot tail files) and a flat 10 min ban.
Install:
The jail files expect the log at `/opt/docker/beacon/data/Caddy/logs/access.json` (Caddy) or
`/var/log/apache2/analyzer-ssl-access.log` (Apache); change `logpath` in `jail.d/beacon-http.conf`
if yours is elsewhere. Install from `fail2ban/caddy/` or `fail2ban/apache/`, whichever matches the box:

```bash
sudo cp filter.d/*.conf /etc/fail2ban/filter.d/
Expand Down
2 changes: 1 addition & 1 deletion deploy/push/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ starting point.
```

3. Create `.env` from the relay's
[`.env.example`](https://github.com/MeshCore-Beacon/beacon-push/blob/dev/.env.example) and
[`.env.example`](https://github.com/MeshCore-Beacon/beacon-push/blob/main/.env.example) and
`chmod 600 .env`. The compose file already sets the listen address, database path and key
paths. Set at least `PUSH_PUBLIC_URL`, `PUSH_TRUST_PROXY=true`, the `PUSH_APNS_*` IDs and
topic (`meshcorebeacon.app`), the `PUSH_SMTP_*` settings and `PUSH_ADMIN_EMAIL`.
Expand Down
17 changes: 11 additions & 6 deletions docker-deployment-type2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ docker-deployment-type2/
nano .env
```

Set `DOMAIN` to the API hostname (`api.example.com`) and add one line this stack needs that
the all-in-one one does not:
Set `DOMAIN` to the API hostname (`api.example.com`) and uncomment or add the one line this
stack needs that the all-in-one stack does not:

```
WEB_DOMAIN=beacon.example.com
```

Caddy redirects anything that is not `/api/*`, `/ws` or `/.well-known/beacon-push` to that host. The password inside
`POSTGRES_DSN` must match `POSTGRES_PASSWORD` in `docker-compose.yml`.
Caddy redirects anything that is not `/api/*`, `/ws` or `/.well-known/beacon-push` to that
host, and the server uses it for the links in account and alert mail. The stack does not start
without it. The password inside `POSTGRES_DSN` must match `POSTGRES_PASSWORD` in
`docker-compose.yml`.

For MeshMapper imports, set `MESHMAPPER_API_KEY` in this server host's `.env`.
Your local MeshMapper regional or grouped-region admin can generate the regional or
Expand Down Expand Up @@ -87,7 +89,7 @@ docker-deployment-type2/
| Variable | Value |
|---|---|
| `DOMAIN` | the web hostname, `beacon.example.com` |
| `BEACON_WEB_IMAGE` | `ghcr.io/meshcore-beacon/beacon-web:latest` to follow releases like the server half does. To pin instead, pin both halves to the same release line, for example `:2.0` here and `beacon-server:2.0` in `server/docker-compose.yml`. |
| `BEACON_WEB_IMAGE` | `ghcr.io/meshcore-beacon/beacon-web:latest` to follow releases like the server half does. To pin instead, pin both halves to the same release line, for example `:2.3` here and `beacon-server:2.3` in `server/docker-compose.yml`. |
| `VITE_API_BASE` | `https://api.example.com/api/v1` |
| `VITE_WS_URL` | `wss://api.example.com/ws` |

Expand All @@ -107,7 +109,10 @@ docker-deployment-type2/
## How the two connect

The browser talks to the API host directly; the web host only serves files. That is why the
API host has to allow the web origin for WebSocket. REST CORS allows any origin by default.
API host has to allow the web origin for WebSocket. REST CORS allows any origin by default,
which covers the public pages. If you turn on [user accounts](../docs/accounts.md), signed-in
requests cross origins too and need the `cors` settings in
[Same site, and a web app on another origin](../docs/accounts.md#same-site-and-a-web-app-on-another-origin).
Rate limits and connection caps work the same as in the all-in-one stack because each host's
Caddy sets `X-Real-IP` and is trusted through `server.trusted_proxies`; see
[Reverse proxy](../docs/reverse-proxy.md).
Expand Down
4 changes: 2 additions & 2 deletions docker-deployment-type2/web/.env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Domain for Caddy TLS
DOMAIN=web.example.com
DOMAIN=beacon.example.com

# Image to run. :latest follows releases, like the server half's compose file. To pin, use the
# same release line on both halves (e.g. :2.0 here and beacon-server:2.0 on the server host).
# same release line on both halves (e.g. :2.3 here and beacon-server:2.3 on the server host).
BEACON_WEB_IMAGE=ghcr.io/meshcore-beacon/beacon-web:latest

# BEACON REST API base URL
Expand Down
Loading