Crates.io | communityid |
lib.rs | communityid |
version | 0.1.2 |
source | src |
created_at | 2024-09-23 15:48:02.851639 |
updated_at | 2024-09-24 08:51:11.383692 |
description | A practical implementation of the Community ID standard for network flow hashing |
homepage | |
repository | https://github.com/qjerome/communityid |
max_upload_size | |
id | 1384236 |
size | 70,767 |
This crate provides a practical implementation of the Community ID standard for network flow hashing.
serde
: when enabled implements serde::Serialize
and serde::Deserialize
traitsuse communityid::{Protocol, Flow};
use std::net::Ipv4Addr;
let f = Flow::new(Protocol::UDP, Ipv4Addr::new(192,168,1,42).into(), 4242, Ipv4Addr::new(8,8,8,8).into(), 53);
let f2 = Flow::new(Protocol::UDP, Ipv4Addr::new(8,8,8,8).into(), 53, Ipv4Addr::new(192,168,1,42).into(), 4242);
// community-id can be base64 encoded
assert_eq!(f.community_id_v1(0).base64(), "1:vTdrngJjlP5eZ9mw9JtnKyn99KM=");
// community-id can be hex encoded
assert_eq!(f2.community_id_v1(0).hexdigest(), "1:bd376b9e026394fe5e67d9b0f49b672b29fdf4a3");
// we can test equality between two community-ids
assert_eq!(f.community_id_v1(0), f2.community_id_v1(0));