feat(pusher): add opt-in v2 WeTime ping signing
- Add WELIST_PING_SIG_VERSION (1 legacy, 2 canonical JSON); default 1
- Sign WELIST-PING-V2\n + compact sorted JSON covering url, chain, height,
median_time, last_block_hash, info, base_fee, version and sig_version
- Fetch info/base_fee/version from the local /{chain}/info endpoint and sign them
- Fall back to null metadata on fetch failure; skip the fetch for onion URLs
- Normalize the advertised URL and bound metadata to match the WeTime service
- Activate v2 in bal-pusher.sh and document the TXT record setup
- Add unit tests for canonical payloads, URL normalization, metadata and onion detection
Includes previously uncommitted local deployment hardening:
- pg-server.sh configurable loopback bind address, volume and recreate handling
- .env loading in bal-server.sh and bal-pusher.sh
- second bal-server/bal-pusher development scripts
This commit is contained in:
@@ -69,6 +69,7 @@ the handler (including request body reading) exceeds the limit.
|
||||
| `BAL_PUSHER_PREFER_IPV6` | `false` | Pin HTTP connection to first IPv6 address (for broken IPv4 routes) |
|
||||
| `WELIST_SERVER_URL` | `"https://welist.bitcoin-after.life"` | URL to POST signed stats to (validated against SSRF) |
|
||||
| `WELIST_SKIP_URL_VALIDATION` | `false` | Bypass SSRF URL validation (for testing only) |
|
||||
| `WELIST_PING_SIG_VERSION` | `1` | WeTime ping signature scheme: `1` (legacy) or `2` (canonical JSON) |
|
||||
|
||||
#### Per-Network Settings
|
||||
|
||||
@@ -200,6 +201,19 @@ export $(grep -v '^#' bal-server.env | xargs)
|
||||
RUST_LOG=info cargo run --bin=bal-server 2>&1
|
||||
```
|
||||
|
||||
### `pg-server.sh` (Local PostgreSQL)
|
||||
Starts the `bal-pg` Docker container used when `BAL_SERVER_DB_BACKEND=postgresql`.
|
||||
|
||||
- Requires `BAL_PG_PASSWORD` (loaded from `.env` by the startup scripts).
|
||||
- Publishes port `5432` on `127.0.0.1` only by default. Set
|
||||
`BAL_PG_BIND_ADDR=0.0.0.0` only if remote access is really required; the
|
||||
script prints a warning when the database is not bound to loopback.
|
||||
- Stores data in the Docker volume `BAL_PG_VOLUME` (default `bal-pg-data`), so
|
||||
the container can be recreated without losing data.
|
||||
- Fails if the existing container publishes the port on a different interface.
|
||||
Run `./pg-server.sh --recreate` to recreate it; the data volume is preserved
|
||||
(and migrated to `BAL_PG_VOLUME` if it changed).
|
||||
|
||||
### `bal-pusher.sh` (Development Pusher Startup)
|
||||
Sources `bal-pusher.env` and runs the pusher with a network argument:
|
||||
```bash
|
||||
@@ -282,6 +296,7 @@ Key points:
|
||||
- [ ] Database file owned by `bal` user (`chown bal:bal /var/bal/bal.db`).
|
||||
- [ ] Database file permissions `600` (`chmod 600 /var/bal/bal.db`).
|
||||
- [ ] `.env` files in `.gitignore` and not committed.
|
||||
- [ ] PostgreSQL (if used) published on `127.0.0.1` only (`BAL_PG_BIND_ADDR`).
|
||||
- [ ] `private_key.pem` / `privkey.pem` not in the repository.
|
||||
- [ ] `public_key.pem` readable by Nginx if served directly.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user