Crates.io | path |
lib.rs | path |
version | 0.8.2 |
source | src |
created_at | 2016-12-22 15:52:08.278736 |
updated_at | 2017-02-01 13:12:20.409741 |
description | IP based connection identification and tracing |
homepage | https://github.com/saschagrunert/path |
repository | https://github.com/saschagrunert/path |
max_upload_size | |
id | 7723 |
size | 25,090 |
This crate is highly inspired by the netfilter project, which provides connection tracking for TCP/IP based protocols. The timeout of a connection (per default 10 minutes) is handled completely internally by using the time crate.
use path::{Path, Identifier};
use std::net::{IpAddr, Ipv4Addr};
// Create a new `Path` for tracking `u8` values as custom data
let mut path :Path<u8, u8> = Path::new();
// Build up a new identifier from IP Addresses, their ports, and a key (in this case the IP Protocol)
let identifier = Identifier::new(IpAddr::V4(Ipv4Addr::new(10, 0, 0, 1)), 1234,
IpAddr::V4(Ipv4Addr::new(10, 0, 0, 2)), 443,
6);
// Do the actual work
let connection = path.track(identifier).unwrap();
// Now it is possible to set/get the custom data
assert_eq!(connection.data.custom, None);
assert_eq!(connection.data.packet_counter, 1);