mirror of
https://codeberg.org/YGGverse/psocks.git
synced 2026-03-31 16:35:28 +00:00
28 lines
701 B
Rust
28 lines
701 B
Rust
use log::debug;
|
|
|
|
#[derive(PartialEq, Eq, Hash)]
|
|
pub enum Item {
|
|
Ending(String),
|
|
Exact(String),
|
|
}
|
|
|
|
impl Item {
|
|
pub fn from_line(rule: &str) -> Self {
|
|
if let Some(item) = rule.strip_prefix(".") {
|
|
debug!("Add `{rule}` to the whitelist");
|
|
Self::Ending(item.to_string())
|
|
} else {
|
|
debug!("Add `{rule}` exact match to the whitelist");
|
|
Self::Exact(rule.to_string())
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Display for Item {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
Self::Ending(s) => write!(f, ".{}", s),
|
|
Self::Exact(s) => write!(f, "{}", s),
|
|
}
|
|
}
|
|
}
|