Rust SDK for working with RIS-Live real-time BGP data stream.

Overview

ris-live-rs

Rust

Provides parsing functions for RIS-Live real-time BGP message stream JSON data.

The main parsing function, parse_ris_live_message converts a JSON-formatted message string into a vector of BgpElems.

Example

use serde_json::json;
use tungstenite::{connect, Message};
use url::Url;
use ris_live_rs::error::ParserRisliveError;
use ris_live_rs::parse_ris_live_message;

const RIS_LIVE_URL: &str = "ws://ris-live.ripe.net/v1/ws/?client=rust-bgpkit-parser";

/// This is an example of subscribing to RIS-Live's streaming data.
///
/// For more RIS-Live details, check out their documentation at https://ris-live.ripe.net/manual/
fn main() {
    // connect to RIPE RIS Live websocket server
    let (mut socket, _response) =
        connect(Url::parse(RIS_LIVE_URL).unwrap())
            .expect("Can't connect to RIS Live websocket server");

    // subscribe to messages from one collector
    let msg = json!({"type": "ris_subscribe", "data": null}).to_string();
    socket.write_message(Message::Text(msg)).unwrap();

    loop {
        let msg = socket.read_message().expect("Error reading message").to_string();
        if msg.is_empty() {
            continue
        }
        match parse_ris_live_message(msg.as_str()) {
            Ok(elems) => {
                for e in elems {
                    println!("{}", e);
                }
            }
            Err(error) => {
                if let ParserRisliveError::ElemEndOfRibPrefix = error {
                    println!("{:?}", &error);
                    println!("{}", msg);
                    continue
                }
                break;
            }
        }
    }
}

Filtering

ris-live-rs support filtering message by composing customized ris-live subscription message. Use the compose_subscription_message function to create a filtering message.

pub fn compose_subscription_message(
    host: Option<String>,
    msg_type: Option<String>,
    require: Option<String>,
    peer: Option<String>,
    prefix: Option<String>,
    path: Option<String>,
    more_specific: bool,
    less_specific: bool,
) -> String {
    ...
}

// subscribe to messages from one collector
let msg = compose_subscription_message(
opts.host,
opts.msg_type,
opts.require,
opts.peer,
opts.prefix,
opts.path,
opts.more_specific,
opts.less_specific
);
println!("{}", &msg);
socket.write_message(Message::Text(msg)).unwrap();

ris-live-reader

ris-live-rs library also comes with a simple command-line program that supports filtering and different output formats: ris-live-reader.

asciicast

Full command-line options are:

ris-live-rs 0.1.0

Mingwei Zhang <[email protected]>

ris-live-reader is a simple cli tool that can stream BGP data from RIS-Live project with websocket

USAGE:
    ris-live-reader [OPTIONS]

OPTIONS:
        --client <CLIENT>        client name to identify the stream [default: ris-live-rs]
    -h, --help                   Print help information
        --host <HOST>            Filter by RRC host: e.g. rrc01
        --json                   Output as JSON objects
        --less-specific          Match prefixes that are less specific (contain) `prefix`
        --more-specific          Match prefixes that are more specific (part of) `prefix`
        --msg-type <MSG_TYPE>    Only include messages of a given BGP or RIS type: UPDATE, OPEN,
                                 NOTIFICATION, KEEPALIVE, or RIS_PEER_STATE
        --path <PATH>            ASN or pattern to match against the AS PATH attribute
        --peer <PEER>            Only include messages sent by the given BGP peer
        --prefix <PREFIX>        Filter UPDATE messages by prefixes in announcements or withdrawals
        --pretty                 Pretty-print JSON output
        --raw                    Print out raw message without parsing
        --require <REQUIRE>      Only include messages containing a given key
    -V, --version                Print version information

Installation

Install via cargo by:

cargo install ris-live-rs

Or checkout the repo and run:

cargo install --path .

The program ris-live-reader will be installed to your $CARGO_HOME/bin (e.g. ~/.cargo/bin).

Built with ❤️ by BGPKIT Team

BGPKIT is a small-team start-up that focus on building the best tooling for BGP data in Rust. We have 10 years of experience working with BGP data and believe that our work can enable more companies to start keeping tracks of BGP data on their own turf. Learn more about what services we provide at https://bgpkit.com.

https://bgpkit.com/favicon.ico

Comments
  • "error: failed to parse manifest"

    % cargo install ris-live-rs   
        Updating crates.io index
      Downloaded ris-live-rs v0.1.0
    error: failed to parse manifest at `/home/stephane/.cargo/registry/src/github.com-1ecc6299db9ec823/ris-live-rs-0.1.0/Cargo.toml`
    
    Caused by:
      feature `edition2021` is required
    
      consider adding `cargo-features = ["edition2021"]` to the manifest
    

    My knowledge of Rust is limited so I cannot really help to solve the problem.

    opened by bortzmeyer 3
  • withdrawal messages does not seem to show up

    withdrawal messages does not seem to show up

    When cross-checking messages showing from the cli, comparing against the ris-live web app, I cannot see any withdraw messages showing up on the tool.

    We should also filter messages at the elem level so that when ris-live bundles multple announcements, we only display the ones user wanted.

    bug 
    opened by digizeph 2
  • Use `structopt` instead of `clap` beta release; reduce msrv

    Use `structopt` instead of `clap` beta release; reduce msrv

    This PR uses the structopt package instead of clap 3 beta for the CLI tool to improve crate stability and brings down minimum supported Rust version (MSRV) from 1.56.0 to 1.46.0.

    A number of other changes to the dependency is also introduced for reducing MSRV:

    • use edition=2018 instead of 2021
    • remove unnecessary url dependency
    • use tungstenite 0.12.0 since newer features are not used
    • add [package.metadata] section to indicate msrv
    opened by digizeph 1
  • Add support for showing withdrawal messages

    Add support for showing withdrawal messages

    In this pull request, we added support for showing withdrawal messages coming from RIS live. This should address issue #7.

    We also made a number of improvement to the command-line tool:

    • added option update-type to allow filtering message by announcement or withdrawal
    • set default RIS-live host to be rrc21 to match what they have on official website. this should stop users from accidental tapping into the full firehose (streaming data from all rrcs). user can still opt-in into firehose by specifying the --host all argument
    • added link to ris-live website to the cli description.

    Additionally, we also run cargo clippy and applied all suggested improvements.

    This PR bumps the crate version to 0.2.0.

    opened by digizeph 0
  • ris-live-reader just exits from processing the live stream

    ris-live-reader just exits from processing the live stream

    As you can see in the below attached logs, I hardly see either couple of messages or sometimes hardly 1 before ris-live-reader exits. Is there any command which can parse the RIS live stream continuously ?

    u2004op2:~$ ris-live-reader {"type": "ris_subscribe", "data":{ "host": "rrc21","moreSpecific": true,"lessSpecific": false } } A|1670564829.24|37.49.236.178|8966|121.52.157.0/24|8966 17557 45773|INCOMPLETE|37.49.236.178|||8966:41 8966:8888 17557:3601||| A|1670564827.39|37.49.236.228|24482|86.111.52.0/24|24482 33891 47692 44472|IGP|37.49.236.228||0|24482:2 24482:12010 24482:12011 24482:65201 33891:2180 33891:7003 33891:33892 33891:40151 47692:120 47692:40142|||

    u2004op2:~$ u2004op2:~$ ris-live-reader --host rrc01 {"type": "ris_subscribe", "data":{ "host": "rrc01","moreSpecific": true,"lessSpecific": false } } A|1670564835.13|195.66.224.32|3257|5.233.254.0/23|3257 6762 49666 48159 58224|INCOMPLETE|195.66.224.32||20|3257:8027 3257:30312 3257:50001 3257:54400 3257:54401||| A|1670564835.13|195.66.224.32|3257|2.179.52.0/23|3257 6762 49666 48159 58224|INCOMPLETE|195.66.224.32||20|3257:8027 3257:30312 3257:50001 3257:54400 3257:54401||| A|1670564835.13|195.66.224.32|3257|46.100.168.0/22|3257 6762 49666 48159 58224|INCOMPLETE|195.66.224.32||20|3257:8027 3257:30312 3257:50001 3257:54400 3257:54401||| A|1670564835.13|195.66.224.32|3257|2.182.224.0/20|3257 6762 49666 48159 58224|INCOMPLETE|195.66.224.32||20|3257:8027 3257:30312 3257:50001 3257:54400 3257:54401||| A|1670564835.13|195.66.224.32|3257|5.236.112.0/20|3257 6762 49666 48159 58224|INCOMPLETE|195.66.224.32||20|3257:8027 3257:30312 3257:50001 3257:54400 3257:54401||| A|1670564835.13|195.66.224.32|3257|2.179.160.0/22|3257 6762 49666 48159 58224|INCOMPLETE|195.66.224.32||20|3257:8027 3257:30312 3257:50001 3257:54400 3257:54401||| A|1670564835.13|195.66.224.32|3257|31.58.84.0/22|3257 6762 49666 48159 58224|INCOMPLETE|195.66.224.32||20|3257:8027 3257:30312 3257:50001 3257:54400 3257:54401||| A|1670564835.13|195.66.224.32|3257|87.251.147.0/24|3257 6762 49666 48159 58224|INCOMPLETE|195.66.224.32||20|3257:8027 3257:30312 3257:50001 3257:54400 3257:54401||| A|1670564835.13|195.66.224.32|3257|2.182.124.0/22|3257 6762 49666 48159 58224|INCOMPLETE|195.66.224.32||20|3257:8027 3257:30312 3257:50001 3257:54400 3257:54401||| A|1670564835.13|195.66.224.32|3257|78.38.230.0/23|3257 6762 49666 48159 58224|INCOMPLETE|195.66.224.32||20|3257:8027 3257:30312 3257:50001 3257:54400 3257:54401||| A|1670564835.13|195.66.224.32|3257|95.38.138.0/23|3257 6762 49666 48159 58224|INCOMPLETE|195.66.224.32||20|3257:8027 3257:30312 3257:50001 3257:54400 3257:54401||| A|1670564835.13|195.66.227.233|207841|196.28.249.0/24|207841 6939 5511 6713 25543|IGP|195.66.227.233|||||| A|1670564835.13|195.66.227.233|207841|41.138.114.0/24|207841 6939 5511 6713 25543|IGP|195.66.227.233|||||| A|1670564835.13|195.66.227.233|207841|196.28.247.0/24|207841 6939 5511 6713 25543|IGP|195.66.227.233|||||| A|1670564834.12|195.66.224.175|13030|130.137.80.0/24|13030 1299 174 16509|IGP|195.66.224.175||1|1299:20000 13030:1299 13030:2 13030:51701 13030:8179|||

    opened by ACodingfreak 0
Releases(v0.2.0)
  • v0.2.0(Jul 9, 2022)

    Update CLI

    Install/update the CLI tool (ris-live-reader) by running cargo install ris-live-rs --version 0.2.0.

    Support Withdrawal Messages

    V0.2.0 added support for showing withdrawal messages included in RIS-live messages. This addresses issue #7.

    CLI Improvements

    • added option update-type to allow filtering message by announcement or withdrawal
    • set default RIS-live host to be rrc21 to match what they have on official website. this should stop users from accidental tapping into the full firehose (streaming data from all rrcs). user can still opt-in into firehose by specifying the --host all argument
    • added link to ris-live website to the cli description.

    Additionally, we also run cargo clippy and applied all suggested improvements.

    Full Changelog: https://github.com/bgpkit/ris-live-rs/compare/v.0.1.1...v0.2.0

    Source code(tar.gz)
    Source code(zip)
  • v.0.1.1(Dec 2, 2021)

    What's Changed

    This release brings down minimum supported Rust version (MSRV) from 1.56.0 to 1.46.0. No breaking changes to existing users.

    A number of other changes to the dependency is also introduced for reducing MSRV:

    • use edition=2018 instead of 2021
    • remove unnecessary url dependency
    • use tungstenite 0.12.0 since newer features are not used
    • use structopt instead of clap
    • add [package.metadata] section to indicate msrv

    Full Changelog: https://github.com/bgpkit/ris-live-rs/compare/v0.1.0...v.0.1.1

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Nov 28, 2021)

    What's Changed

    • add filtering by subscription by @digizeph in https://github.com/bgpkit/ris-live-rs/pull/1

    New Contributors

    • @digizeph made their first contribution in https://github.com/bgpkit/ris-live-rs/pull/1

    Full Changelog: https://github.com/bgpkit/ris-live-rs/compare/v0.0.1...v0.1.0

    Source code(tar.gz)
    Source code(zip)
  • v0.0.1(Nov 24, 2021)

Owner
BGPKIT
BGP Data Analysis Tool Kit
BGPKIT
Dark Forest, the world's first decentralized real-time strategy game.

darkforest-rs Dark Forest, the world's first decentralized real-time strategy game.

null 44 Oct 9, 2022
First-person 3D pong ray-traced on CPU in real time.

ray ten Run in browser ray-ten.mp4 Reimagining of a 1986 ZX Spectrum game room ten made with ray tracing. Completely ignoring GPUs when rendering 3D g

Egor 2 Aug 20, 2022
A real-time raytracing engine, with extra Bevy integration

strolle Strolle (from strålspårning) is a real-time raytracing engine written entirely in Rust, running on CPU & GPU: It comes integrated with Bevy, b

Patryk Wychowaniec 72 Jan 1, 2023
Coordination repository of the Game Development Working Group

Rust Game Development Working Group ??️ The game development working group's main purpose is to make Rust a first-class option for game developers. Wh

Rust game development working group 448 Jan 2, 2023
Helper functions and structs for working with 2D space in Bevy.

About Baffled by quaternions? Want to accelerate an object in 2D? Wish that there was a simple way to work with grids? Just want to know if two axis-a

Leafwing Studios 11 May 9, 2022
Tools for working with Retro game formats. Currently only supports Metroid Prime Remastered.

retrotool Warning Under active development, not guaranteed to be useful or even function. Tools for working with Retro game formats. Currently only su

null 4 Feb 19, 2023
An (unofficial) open source Rust implementation of the Discord Game SDK.

⚔️ discord-sdk An (unofficial) open source Rust implementation of the Discord Game SDK. Why not use this? This project is not official and is using a

Embark 86 Dec 23, 2022
A Team Fortress 2 SDK written in Rust that I update every now and then

tf-rs A Team Fortress 2 SDK written in Rust that I update every now and then. Most of this has been written in early November. I've published it so th

cristei 2 Dec 17, 2022
A first-time implementation of Conway's Game of Life in Rust: Adventure and Commentary

A Commentary on Life This project documents the process and final result of my first-ever attempt at implementing Conway's Game of Life. I'll be using

Avery R. 2 Feb 25, 2022
Rushes are new ephemeral projects at Hive Helsinki. Wordle is the first in this series with 48 hours time window

Rushes are new ephemeral projects at Hive Helsinki. Wordle is the first in this series with 48 hours time window

Jiri Novotny 1 Feb 24, 2022
Cross-platform GPU-accelerated viewer for the Mandelbrot set and similar (escape-time) fractals

fractal_viewer A cross-platform, GPU-accelerated viewer for the Mandelbrot Set and related fractals. Try it online! Usage Scroll wheel to zoom, click

null 5 Jan 8, 2023
Transform tagged Markdown string to HTML during build time.

tagged-md Transform tagged Markdown string to HTML! Check out the examples! Motivation Have you ever written HTML strings in your JavaScript code? It'

PortOne 23 May 30, 2023
A refreshingly simple data-driven game engine built in Rust

What is Bevy? Bevy is a refreshingly simple data-driven game engine built in Rust. It is free and open-source forever! WARNING Bevy is still in the ve

Bevy Engine 21.1k Jan 4, 2023
Bevy is a refreshingly simple data-driven game engine built in Rust

What is Bevy? Bevy is a refreshingly simple data-driven game engine built in Rust. It is free and open-source forever! WARNING Bevy is still in the ve

John Winston 3 Jun 3, 2022
🍖A WGPU graphics pipeline, along with simple types used to marshal data to the GPU

renderling ?? This library is a collection of WGPU render pipelines. Shaders are written in GLSL. shaderc is used to compile shaders to SPIR-V. Defini

Schell Carl Scivally 5 Dec 20, 2022
Provides a mechanism to lay out data into GPU buffers according to WGSL's memory layout rules

Provides a mechanism to lay out data into GPU buffers ensuring WGSL's memory layout requirements are met. Features supports all WGSL host-shareable ty

Teodor Tanasoaia 69 Dec 30, 2022
Generic and extensible egui widgets to create analog synthesizer-like UI with data-oriented API

egui_cable A generic and extensible data-oriented widget for connecting ports by cables. I create this for the visual programming editor of Hihaheho/D

Ryo Hirayama 44 Dec 30, 2022
A data compatibility project for Minecraft's assets

Data Compat MC Data tool for the Falcon MC project. Description DataCompatMC is a cli tool designed to help deal with the many different versions of M

GrizzlT 5 Dec 11, 2022
A data compatibility project for Minecraft's assets

Data Compat MC Data tool for the Falcon MC project. Description DataCompatMC is a cli tool designed to help deal with the many different versions of M

FalconMC 2 Jul 6, 2022