| Crates.io | ipset |
| lib.rs | ipset |
| version | 0.9.0 |
| created_at | 2023-01-05 08:57:01.461227+00 |
| updated_at | 2025-03-05 02:37:40.963122+00 |
| description | A wrapper for libipset |
| homepage | |
| repository | https://github.com/lazytiger/ipset |
| max_upload_size | |
| id | 751405 |
| size | 75,281 |
A library wrapper for libipset.
Support the following options:
EnvOption::SortedEnvOption::ExistEnvOption::QuietEnvOption::ResolveEnvOption::ListSetNameEnvOption::ListHeaderSupport the following commands:
Support the following type:
use std::net::IpAddr;
use ipset::{Error, HashIp, IPSet, Session};
fn main() -> Result<(), Error> {
let mut session: Session<HashIp> = Session::<HashIp>::new("test".to_string());
let ip: IpAddr = "192.168.3.1".parse().unwrap();
session.create(|builder| builder.with_ipv6(false)?.build())?;
let ret = session.add(ip, &[])?;
println!("add {}", ret);
let exists = session.test(ip)?;
println!("test {}", exists);
let ips = session.list()?;
for ip in ips {
println!("list {}", ip);
}
let ret = session.save("test.ipset".into())?;
println!("save {}", ret);
let ret = session.del(ip)?;
println!("del {}", ret);
let ret = session.flush()?;
println!("flush {}", ret);
let ret = session.destroy()?;
println!("destroy {}", ret);
let set = IPSet::new();
set.restore("test.ipset")?;
Ok(())
}