2个版本
使用旧的Rust 2015
0.1.1 | 2018年8月14日 |
---|---|
0.1.0 | 2018年8月4日 |
#5 in #antivirus
在 2 crates 中使用
32KB
441 行
clam-client
clam-client
是一个简单的Rust接口,用于通过TCP套接字与ClamAV服务器通信。
示例
extern crate clam_client;
use clam_client::client::ClamClient;
use clam_client::response::ClamScanResult;
fn main() {
let client = ClamClient::new("127.0.0.1", 3310).unwrap();
if let Ok(results) = client.scan_path("/tmp/", true) {
for scan_result in results.iter() {
match scan_result {
ClamScanResult::Found(location, virus) => {
println!("Found virus: '{}' in {}", virus, location)
},
_ => {}
}
}
}
}
支持流式传输
let client = ClamClient::new("127.0.0.1", 3310).unwrap();
let file = File::open(some_path).unwrap();
match client.scan_stream(file) {
Ok(result) => match result {
ClamScanResult::Ok => println!("File {} is OK!", some_path,
ClamScanResult::Found(_, virus) => {
println!("Found virus: '{}' in {}", virus, some_path)
}
ClamScanResult::Error(err) => println!("Received error from ClamAV: {}", err),
},
Err(e) => println!("A network error occurred whilst talking to ClamAV:\n{}", e),
}
待办事项
- 添加会话支持:IDSESSION / END
- 决定是否实现VERSIONCOMMANDS
- 决定是否实现FILDES
依赖项
~2.5MB
~42K SLoC