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>
63 lines
1.8 KiB
Protocol Buffer
63 lines
1.8 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package bgp.server;
|
|
|
|
// Top level BGP Server configuration.
|
|
message BgpConfig {
|
|
// The router ID, written as a dotted-quad IPv4 address (e.g. "192.0.2.1").
|
|
// Required even on IPv6-only routers per RFC 4271.
|
|
string router_id = 1;
|
|
|
|
// The local 4-byte AS number (RFC 6793).
|
|
uint32 local_asn = 2;
|
|
|
|
// Endpoints to accept incoming BGP connections on.
|
|
// Defaults to 0.0.0.0:179 and [::]:179 when empty.
|
|
repeated TcpEndpoint listen_endpoints = 3;
|
|
|
|
// Peers configured on this server.
|
|
repeated Peer peers = 4;
|
|
|
|
// Limits on routes originated locally (e.g. via the demo UI).
|
|
LocalRoutePolicy local_route_policy = 5;
|
|
|
|
// Where to serve the HTTP API, status page and metrics. The port is
|
|
// required. Unset disables the HTTP server.
|
|
TcpEndpoint http_endpoint = 6;
|
|
}
|
|
|
|
// Limits on locally originated routes.
|
|
message LocalRoutePolicy {
|
|
// A locally originated route is accepted only if it is covered by one of
|
|
// these prefixes, written in CIDR notation (e.g. "10.100.0.0/16").
|
|
// Empty means any prefix may be announced.
|
|
repeated string allowed_prefixes = 1;
|
|
|
|
// Maximum number of routes a single owner may announce. 0 means unlimited.
|
|
uint32 max_routes_per_owner = 2;
|
|
}
|
|
|
|
// An IP address and port pair.
|
|
message TcpEndpoint {
|
|
// IP address (V4 or V6).
|
|
string address = 1;
|
|
// TCP port. Defaults to 179 for BGP when unset.
|
|
uint32 port = 2;
|
|
}
|
|
|
|
// Configuration of a BGP peer.
|
|
message Peer {
|
|
// Human-readable name for logging and diagnostics.
|
|
string name = 1;
|
|
|
|
// Address and port to connect to for this peer.
|
|
TcpEndpoint endpoint = 2;
|
|
|
|
// The peer's 4-byte AS number (RFC 6793).
|
|
uint32 remote_asn = 3;
|
|
|
|
// Hold time to advertise in the OPEN message, in seconds (RFC 4271 §4.2).
|
|
// Must be 0 or >= 3. Defaults to 90 when unset.
|
|
uint32 hold_time_seconds = 4;
|
|
}
|