clamdproxy

package
v0.1.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package clamdproxy puts TLS, token authentication and a command filter in front of clamd, which has none of these. Clients first send "zAUTH <token>\0"; afterwards only the commands meles needs are forwarded (PING, VERSION, IDSESSION, INSTREAM, END). Everything else, in particular SHUTDOWN and SCAN <path>, closes the connection.

With RulesDir set, the proxy appends a hash of the YARA rules in clamd's database directory to the VERSION reply ("ClamAV 1.4.6/28164+rules.<hash>/ <date>"). Clients use the signature version as cache and rescan key, so changed rules count like a signature update.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

type Proxy struct {
	// Upstream is the clamd address, e.g. tcp://127.0.0.1:3310 or
	// unix:///tmp/clamd.sock.
	Upstream string
	// CertFile and KeyFile are reloaded when they change, e.g. after a
	// renewal by cert-manager.
	CertFile, KeyFile string
	// TokenFile holds the accepted tokens, one per line, so that a token can
	// be rotated without downtime. It is reloaded when it changes.
	TokenFile string
	// AuthTimeout bounds the TLS handshake and the authentication.
	AuthTimeout time.Duration
	// MaxConns limits concurrent client connections. 0 means no limit.
	MaxConns int
	// RulesDir is clamd's DatabaseDirectory; empty: VERSION is forwarded
	// unchanged.
	RulesDir string
	Logger   *slog.Logger
	// contains filtered or unexported fields
}

Proxy forwards authenticated connections to clamd.

func (*Proxy) Serve

func (p *Proxy) Serve(ctx context.Context, ln net.Listener) error

Serve accepts connections on ln until ctx is done.

Jump to

Keyboard shortcuts

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