
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
frr-ospf-api-stream-client
Advanced tools
Stateful pure-python API client for the FRR OSPF API to generate network snapshots and diff-based event streams
This repository contains a Python client for the FRR OSPF API which synchronizes a copy of the network's LSDB via LSA update streams for export into various formats:
This work is based in large part on the reference script included in FRR. You should start there if you are trying to develop your own custom FRR OSPF API client.
> ospf-stream-client --server <frr OSPF API server addr>
2024-12-23 04:29:32,352 WARNING: CLIENT: root Waiting for initial load to complete...
2024-12-23 04:29:32,465 WARNING: CLIENT: root LSDB loaded!
{"timestamp": 1734928168632, "entity": {"type": "router", "id": "10.69.5.52"}, "added": {"link": {"router": {"id": "10.69.6.10", "metric": 100}}}}
{"timestamp": 1734928167633, "entity": {"type": "router", "id": "10.69.6.10"}, "added": {"link": {"router": {"id": "10.69.5.52", "metric": 100}}}}
{"timestamp": 1734928166886, "entity": {"type": "router", "id": "10.69.3.85"}, "removed": {"link": {"router": {"id": "10.69.4.40", "metric": 100}}}}
{"timestamp": 1734928165886, "entity": {"type": "router", "id": "10.69.1.65"}, "added": {"link": {"router": {"id": "10.69.5.51", "metric": 100}}}}
{"timestamp": 1734928164890, "entity": {"type": "router", "id": "10.69.5.51"}, "added": {"link": {"router": {"id": "10.69.1.65", "metric": 100}}}}
This client doesn't implement support for multi-area OSPF LSAs or IPv6 (OSPFv3) and will only work for IPv4 OSPF networks where all routers are present in the backbone network. Exact behavior for trying to use this tool on multi-area networks is undefined but expect crashes
The DB snapshot and streamed updates output formats are detailed using
JSON Schema in src/api_stream_client/db_snapshot.json
and src/api_stream_client/stream_event.json
respectively. Note that the stream
is composed of a series of newline-delimited JSON objects, each of which is formatted
according to stream_event.json
. This means the stream (and any subset of its lines) is
JSONL-compliant. Read more about JSONL here.
Pre-requisites: python3
available via the shell
First, install the CLI via pip:
pip install frr-ospf-api-stream-client
then invoke the tool with the CLI command:
ospf-stream-client --server <frr OSPF API server adress>
Available flags:
--server <frr OSPF API server adress>
: Specify the address that the FRR OSPF API server is running on.
Defaults to localhost
. Note: the FRR OSPF API sockets protocol is somewhat esoteric. It relies
on bidirectional sockets being intiated with dynamic port numbers between the client and the
server, so while it is technically possible to run the client on a separate host from the
server, the connection will not work across most firewalls and definitely WILL NOT work through
any kind of NAT--ws-listen <interface address>:<listen port>
: If provided, we will use autobahn
to listen on the specified interace and port for inbound websockets connections. These connections
are very simple, they do not accept any input from clients. All clients recieve an identical
copy of the event stream, one JSON event per WS message--events-path-prefix <folder path>
: If provided, we will write the event stream to disk, paritioning
into files of one hour each, within the specified prefix. You likely want some kind of cleanup job
to compress/archive/delete these files to avoid filling up your disk--snapshots-path-prefix <folder path>
: If provided, we will write LSDB snapshots to disk, once per minute
grouping by year, month, day, hour, etc, within the specified prefix. You likely want some kind of cleanup job
to compress/archive/delete these files to avoid filling up your disk--mute-stdout-stream
: By default, the event stream will be written to stdout. Provide this flag
to disable that behavior-v, --verbose
: Increase the verbosity of the stderr log messages. Useful for troubleshooting upstream API issuesPre-requisites: python3
available via the shell
Setup by cloning, creating a virtual env, and installing the application
git clone https://github.com/Andrew-Dickinson/frr-ospf-api-stream-client
cd frr-ospf-api-stream-client
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
then invoke the tool with the CLI command:
ospf-stream-client --server <frr OSPF API server adress>
Follow the instructions under "Dev Setup" above, to clone a local copy of this application and activate the virtual environment. Then installing the test dependencies with:
pip install -e ".[test,dev]"
Finally, invoke the test suite using pytest:
pytest test/
Follow the instructions above to clone a local copy of this application, activate the virtual environment, and run the tests.
Then, build & upload the application with
rm -rf dist/*
python -m build .
twine upload dist/*
Distributed under the GPL-2.0 License. See license.txt
for more information.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)FAQs
Stateful pure-python API client for the FRR OSPF API to generate network snapshots and diff-based event streams
We found that frr-ospf-api-stream-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.