Files
ferrix/bin/bgp/README.md
T
Rayhaan JaufeerallyandClaude Fable 5.1 c3f7713965 feature: HTTP API, event stream and Prometheus metrics (bgp-web)
Phase 2 of the teaching demo: everything the status page will need is now
reachable over HTTP.

- New crate crates/web (axum). JSON endpoints for status, peers, local
  routes (announce / withdraw), received routes, the exact UPDATE bytes a
  local route produces per session, and well-known community names.
  Communities are accepted as ASN:VALUE or by name (NO_EXPORT, BLACKHOLE,
  ...); large communities as A:B:C. Policy errors map to 403/409/422.
- GET /api/events is a server-sent event stream merging session up/down,
  local route and Adj-RIB-In changes, with lag notifications.
- GET /metricz serves Prometheus metrics; the server crate now counts
  messages sent/received by type and sessions established.
- The runnable main moves from crates/server to bin/bgp so it can depend
  on both server and web without a cycle. `cargo run -- config.textpb`.
- Config gains http_endpoint; unset disables the API.
- Integration tests drive the API against a live server with a real BGP
  peer, including verifying the wire view matches the bytes the peer got.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-16 23:10:16 +02:00

1.5 KiB

BGP

This crate provides the bgp binary which runs the Border Gateway Protocol daemon together with its HTTP API.

cargo run -- path/to/config.textpb

The configuration format is defined in crates/server/proto/config.proto; testdata/server.textpb is a worked example. When http_endpoint is set the binary also serves:

Path Purpose
GET /api/status Router ID, ASN, uptime and table sizes
GET /api/peers Established sessions
GET /api/routes/local Locally originated routes
POST /api/routes/local Announce a route (JSON body, see below)
DELETE /api/routes/local Withdraw a route (JSON body: prefix, optional owner)
GET /api/routes/local/wire?prefix=… The exact UPDATE bytes sent to each peer
GET /api/routes/received Adj-RIB-In contents
GET /api/communities/well-known Names accepted in place of numeric communities
GET /api/events Server-sent events for session and route changes
GET /metricz Prometheus metrics

Announce body:

{
  "prefix": "10.100.1.0/24",
  "owner": "alice",
  "origin": "IGP",
  "prepend": 2,
  "med": 100,
  "communities": ["65000:100", "NO_EXPORT"],
  "large_communities": ["65000:1:2"]
}

Only prefix and owner are required. Routes are subject to the local_route_policy in the configuration.

Please refer to the other implementation crates in this repository where most of the actual implementation lives.

Warning: This is still very much a work in progress and is not yet ready for production use.