Rust ClamAV Client

A simple ClamAV client to stream files to clamd for antivirus scanning.

Please note: The functions ping_socket, scan_file_socket, and scan_buffer_socket are only available on Unix platforms.

Installation

Add this to your Cargo.toml:

toml [dependencies] clamav-client = "0.2.1"

Usage

```rust let clamdhostaddress = "localhost:3310";

// Ping clamd to make sure the server is available and accepting TCP connections let clamdavailable = match clamavclient::pingtcp(clamdhostaddress) { Ok(pingresponse) => pingresponse == b"PONG\0", Err() => false, };

if !clamdavailable { println!("Cannot ping clamd at {}", clamdhost_address); return; }

// Scan file for viruses let filepath = "tests/eicar.txt"; let scanfileresponse = clamavclient::scanfiletcp(filepath, clamdhostaddress, None).unwrap(); let fileclean = clamavclient::clean(&scanfileresponse).unwrap(); if fileclean { println!("No virus found in {}", filepath); } else { println!("The file {} is infected!", filepath); }

// Scan in-memory data for viruses let buffer = br#"X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"#; let scanbufferresponse = clamavclient::scanbuffertcp(buffer, clamdhostaddress, None).unwrap(); let dataclean = clamavclient::clean(&scanbufferresponse).unwrap(); if dataclean { println!("No virus found"); } else { println!("The data is infected!"); } ```

Contributors