clamav_client
Gleam client for interacting with a ClamAV instance
gleam add clamav_client@1
import clamav_client/clamav
import clamav_client/client_options.{type ClamAvClientOptions}
pub fn main() {
let data = "some data, probably a file" |> bit_array.from_string
let options =
ClamAvClientOptions(
host: "",
port: 3310,
connection_timeout: 10_000, // ms
reply_timeout: 10_000, // ms
logger: client_options.nil_logger
)
case clamav.instream(options, data) {
Ok(Clean) -> "Clean!"
Ok(VirusDetected(infected_files)) -> {
let infected_file =
infected_files |> list.first
"VirusDetected: " <> infected_file.file_name <> " | " <> infected_file.virus_name
}
Error(error) -> "Error: " <> error |> string.inspect
}
}
Further documentation can be found at https://hexdocs.pm/clamav_client.
Development
gleam build # Build the project
gleam test # Run the tests