clamdproxy

package
v0.3.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 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. ConfigHash goes into the same place as "+config.<hash>".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidConfigHash added in v0.3.0

func ValidConfigHash(s string) bool

ValidConfigHash reports whether s can go into a VERSION reply: the reply uses "/" and NUL as separators, and the version is part of the cache key.

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
	// ConfigHash identifies the clamd options that change verdicts and goes
	// into VERSION as well, so that a changed option triggers rescans. Empty
	// for the default options. Hexadecimal, see ValidConfigHash.
	ConfigHash 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