1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! # ufwlog
//!
//! A library for parsing UFW (Uncomplicated Firewall) log files.
//!
//! ## Quick Start
//!
//! Parse a log file and filter blocked events from local:
//!
//! ```rust, no_run
//! use ufwlog::{UfwLog, LoggedEvent};
//!
//! let logs: Vec<UfwLog> = UfwLog::from_file("./ufw.log")?;
//!
//! let blocked = logs.iter()
//! .filter(|log| log.event == LoggedEvent::Block)
//! .filter(|log| log.src == "127.0.0.1")
//! .collect::<Vec<_>>();
//! # Ok::<(), ufwlog::error::Error>(())
//! ```
//!
//! Or you want to a lazy iterator to handle each log:
//!
//! ```rust, no_run
//! use std::io::BufReader;
//! use ufwlog::{UfwLog, LoggedEvent};
//!
//! let reader = BufReader::new(std::fs::File::open("./ufw.log")?);
//! let log_iters = UfwLog::from_buf_reader(reader);
//!
//! let blocked = log_iters
//! .filter_map(|log| log.ok())
//! .filter(|log| log.event == LoggedEvent::Block)
//! .filter(|log| log.src == "127.0.0.1")
//! .for_each(|log| println!("{}", log.dst));
//! # Ok::<(), ufwlog::error::Error>(())
//! ```
pub use LoggedEvent;
pub use UfwLog;