clamd

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package clamd talks to a ClamAV daemon over its socket protocol.

meles never links against libclamav (GPLv2): clamd runs as a separate process and keeps the signature database in memory once.

With a tls:// address the client talks to meles clamd-proxy instead, which adds TLS and token authentication in front of clamd: the first command on every connection is "zAUTH <token>\0", answered with "AUTH OK\0".

Index

Constants

View Source
const (
	AuthCommand = "AUTH"
	AuthOK      = "AUTH OK"
	AuthFailed  = "AUTH FAILED"
)

Authentication with meles clamd-proxy.

View Source
const MaxFileSize = 1<<31 - 1

MaxFileSize is the largest file ClamAV can scan ("technical design limitations", see clamd.conf). StreamMaxLength must be at least as large.

Variables

This section is empty.

Functions

func LoadCA

func LoadCA(file string) (*tls.Config, error)

LoadCA returns a TLS configuration that trusts only the CA certificates (PEM) in file, e.g. the CA of meles clamd-proxy.

func ParseReply

func ParseReply(resp string) (string, error)

ParseReply interprets a session reply: "<id>: stream: OK", "<id>: stream: <signature> FOUND" or "<id>: <message> ERROR".

func ParseVersion

func ParseVersion(raw string) engine.Version

ParseVersion splits a clamd VERSION reply into engine and signature database version.

Types

type Client

type Client struct {

	// Timeout bounds each step of a scan: sending a chunk and waiting for the
	// verdict. A stalled clamd fails the scan, while a large file may take
	// longer as a whole.
	Timeout time.Duration
	// TLSConfig is used for tls:// addresses. Nil means the system roots.
	TLSConfig *tls.Config
	// Token authenticates with meles clamd-proxy. It is only sent over TLS.
	Token string
	// ConnectRetry is how long refused or timed-out connections are retried.
	// A new pod may be rejected by network policies for a few seconds until
	// the CNI knows it (seen with k3s/kube-router), and clamd may just be
	// restarting.
	ConnectRetry time.Duration
	// contains filtered or unexported fields
}

Client connects to clamd. The zero value is not usable; use New.

func New

func New(addr string) (*Client, error)

New parses addr: "unix:///run/clamav/clamd.ctl", "tcp://host:3310" or "tls://host:3310" (meles clamd-proxy).

func (*Client) Open

func (c *Client) Open(ctx context.Context) (engine.Session, error)

Open starts an IDSESSION. Commands are sent one at a time, so replies arrive in order.

func (*Client) Version

func (c *Client) Version(ctx context.Context) (engine.Version, error)

Version sends VERSION, e.g. "ClamAV 1.4.3/28159/Tue Oct 20 08:24:12 2026".

Jump to

Keyboard shortcuts

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