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
28 changes: 28 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: quality

# Keeps the router small and the OpenAPI spec valid. The spec-versus-routes
# test and the browser tests run in test.yml.
on:
push:
branches: [main]
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with: { go-version: '1.27.4' }
- name: gocyclo (router stays small)
run: |
go install github.com/fzipp/gocyclo/cmd/gocyclo@v0.6.0
gocyclo -over 15 web.go stats.go
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with: { node-version: '22' }
- name: OpenAPI lint
run: npx --yes @redocly/cli@2.82.0 lint docs/openapi.yaml
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ Web settings are stored in `targets/routing-options.json` and **override list-fi

Off by default. `VRFPING_ZABBIX_TOKEN=<16+ characters> ./vrf-ping --zabbix user=admin passwd=...` (or `VRFPING_ZABBIX_TOKEN_FILE` / `--zabbix-token-file`) serves a read-only `GET /api/stats`: per target, the last five minutes' p50/p90/p99, loss, loss bursts and `probe_errors` (rounds that could not probe at all, such as a missing VRF). No hosts, VRFs, source addresses or raw samples. Use it with the [fogping Zabbix 7.0 template](https://github.com/githubflyideas/fogping/tree/main/zabbix/template_fogping/7.0): set `{$FOGPING.URL}` to `http://<host>:8517`. Item ids derive from the target name, so a rename starts a new item. Without `--zabbix` nothing changes. `./vrf-ping --gen-token zabbix.token` makes a strong token in a file only you can read (it is never printed).

## HTTP API

The web UI and the Zabbix template use one JSON API: [docs/API.md](docs/API.md) · OpenAPI 3.1: [docs/openapi.yaml](docs/openapi.yaml).

## Data and upgrades

`data/` contains daily JSONL files with a default retention of 300 days. Different VRF/source contexts have separate histories. Clearing both options returns to the target's default-context history.
Expand Down
29 changes: 29 additions & 0 deletions browser_server_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package main

import (
"context"
"fmt"
"net/http/httptest"
"os"
"os/signal"
"syscall"
"testing"
"time"
)

// TestBrowserServer serves the real router, login and CSP included, on a
// random loopback port for login_capslock.test.cjs. It is skipped unless
// that test starts it, and stops when signalled (or after 5 minutes).
func TestBrowserServer(t *testing.T) {
if os.Getenv("BROWSER_TEST_SERVE") == "" {
t.Skip("started by login_capslock.test.cjs")
}
srv := httptest.NewServer(newMux(defaultConfig(), nil, map[string]string{"admin": "browser-test-password"}))
defer srv.Close()
fmt.Println("BROWSER_TEST_URL=" + srv.URL)
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
ctx, cancel := context.WithTimeout(ctx, 5*time.Minute)
defer cancel()
<-ctx.Done()
}
3 changes: 3 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ same rules hold in fogping and pingping, so a client written for one reads the
others the same way. Targets themselves are not edited through the API: they
come from `targets/*.list` (see the README).

The same API in machine-readable form: [openapi.yaml](openapi.yaml) (OpenAPI 3.1).
A test (`TestOpenAPIMatchesRoutes`) fails when it and the registered routes differ.

## Rules

These are enforced by tests (`api_test.go`): code that breaks one does not pass CI.
Expand Down
Loading
Loading