TypeScript library that connects to BIRD’s Unix control socket, sends the same commands you would type in birdc, and parses show protocols output into structured objects (including BGP channels and passive BGP details).
- BIRD running locally with its control socket available (default path:
/run/bird/bird.ctl). - Node.js 20+ (matches dev tooling in this repo).
This package is marked private in package.json; clone the repo and build from source:
yarn install
yarn build && yarn build:typesThe project is ESM ("type": "module"). After a build, import from dist/ (or from the package name if you publish this library yourself).
import { Bird } from "./dist/index.js";
const bird = new Bird();
// Optional: custom socket path
// const bird = new Bird({ socketPath: "/run/bird/bird.ctl" });
await bird.connect();
try {
const raw = await bird.sendCommand("show route");
console.log(raw);
const protocols = await bird.showProtocols();
console.log(protocols);
const ok = await bird.configureCheck();
if (ok) {
await bird.configure();
}
} finally {
await bird.destroy();
}sendCommand queues requests so only one command runs on the socket at a time.
- Default: list of
Protocolrows (summary view). { all: true }: full detail; BGP entries include parsedchannelsandbgpdata.{ name: "my_proto" }: filter to a single protocol (orundefinedif missing).{ raw: true }: return unparsed text for the matching protocol when combined withnameandall(see overloads insrc/index.ts).
| Method | Purpose |
|---|---|
connect() |
Connect to the socket and wait for BIRD’s ready banner. |
destroy() |
Close the socket. |
sendCommand(command) |
Send a line to BIRD; returns the textual response (status codes stripped). |
showProtocols(options?) |
Parsed or raw protocol listing (overloads for all, name, raw). |
configureCheck() |
Run configure check; resolves true if output contains “Configuration OK”. |
configure() |
Runs configure check then configure if the check passes. |
Exported types live in src/types.ts.
yarn dev # run src with ts-node + nodemon
yarn build # compile to dist with SWC
yarn build:types # emit .d.ts to dist
yarn test:unit # unit tests
yarn test:types # tsc --noEmit
yarn lint # eslint on srcGPL-3.0 — see LICENSE.