clamd

package module
v0.0.0-...-b970184 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2017 License: MIT Imports: 11 Imported by: 43

README

go-clamd

Interface to clamd (clamav daemon). You can use go-clamd to implement virus detection capabilities to your application.

GoDoc Build Status

Examples

c := clamd.NewClamd("/tmp/clamd.socket")

reader := bytes.NewReader(clamd.EICAR)
response, err := c.ScanStream(reader, make(chan bool))

for s := range response {
    fmt.Printf("%v %v\n", s, err)
}

Contributions

Contributions are welcome.

Creators

Remco Verhoef

Code and documentation copyright 2011-2014 Remco Verhoef. Code released under the MIT license.

Documentation

Index

Constants

View Source
const (
	RES_OK          = "OK"
	RES_FOUND       = "FOUND"
	RES_ERROR       = "ERROR"
	RES_PARSE_ERROR = "PARSE ERROR"
)
View Source
const CHUNK_SIZE = 1024
View Source
const TCP_TIMEOUT = time.Second * 2

Variables

View Source
var EICAR = []byte(`X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*`)

Functions

This section is empty.

Types

type CLAMDConn

type CLAMDConn struct {
	net.Conn
}

type Clamd

type Clamd struct {
	// contains filtered or unexported fields
}

func NewClamd

func NewClamd(address string) *Clamd

func (*Clamd) AllMatchScanFile

func (c *Clamd) AllMatchScanFile(path string) (chan *ScanResult, error)

Scan file or directory (recursively) with archive support enabled and don’t stop the scanning when a virus is found.

func (*Clamd) ContScanFile

func (c *Clamd) ContScanFile(path string) (chan *ScanResult, error)

Scan file or directory (recursively) with archive support enabled and don’t stop the scanning when a virus is found.

func (*Clamd) MultiScanFile

func (c *Clamd) MultiScanFile(path string) (chan *ScanResult, error)

Scan file in a standard way or scan directory (recursively) using multiple threads (to make the scanning faster on SMP machines).

func (*Clamd) Ping

func (c *Clamd) Ping() error

Check the daemon's state (should reply with PONG).

func (*Clamd) RawScanFile

func (c *Clamd) RawScanFile(path string) (chan *ScanResult, error)

Scan file or directory (recursively) with archive and special file support disabled (a full path is required).

func (*Clamd) Reload

func (c *Clamd) Reload() error

Reload the databases.

func (*Clamd) ScanFile

func (c *Clamd) ScanFile(path string) (chan *ScanResult, error)

Scan file or directory (recursively) with archive support enabled (a full path is required).

func (*Clamd) ScanStream

func (c *Clamd) ScanStream(r io.Reader, abort chan bool) (chan *ScanResult, error)

Scan a stream of data. The stream is sent to clamd in chunks, after INSTREAM, on the same socket on which the command was sent. This avoids the overhead of establishing new TCP connections and problems with NAT. The format of the chunk is: <length><data> where <length> is the size of the following data in bytes expressed as a 4 byte unsigned integer in network byte order and <data> is the actual chunk. Streaming is terminated by sending a zero-length chunk. Note: do not exceed StreamMaxLength as defined in clamd.conf, otherwise clamd will reply with INSTREAM size limit exceeded and close the connection

func (*Clamd) Shutdown

func (c *Clamd) Shutdown() error

func (*Clamd) Stats

func (c *Clamd) Stats() (*Stats, error)

On this command clamd provides statistics about the scan queue, contents of scan queue, and memory usage. The exact reply format is subject to changes in future releases.

func (*Clamd) Version

func (c *Clamd) Version() (chan *ScanResult, error)

Print program and database versions.

type ScanResult

type ScanResult struct {
	Raw         string
	Description string
	Path        string
	Hash        string
	Size        int
	Status      string
}

type Stats

type Stats struct {
	Pools    string
	State    string
	Threads  string
	Memstats string
	Queue    string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL