servertracker

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package servertracker provides an in-memory tracker for unique email servers seen by the SMTP endpoint. It uses salted hashing for privacy — server IPs and domains are never stored in cleartext. The salt is regenerated on each process restart, so the tracker resets naturally.

The tracker writes summary counts to a JSON status file in RuntimeDirectory, which can be read by the CLI.

It distinguishes between:

  • Connection IPs: the remote IP of the connecting SMTP server
  • Domain servers: senders like user@example.com (domain = example.com)
  • IP servers: senders like user@[1.2.3.4] or user@1.2.3.4

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Status

type Status struct {
	BootTime        int64 `json:"boot_time"`
	UniqueConnIPs   int   `json:"unique_conn_ips"`
	UniqueDomains   int   `json:"unique_domains"`
	UniqueIPServers int   `json:"unique_ip_servers"`
}

Status is the JSON structure written to the status file.

func ReadStatusFile

func ReadStatusFile(runtimeDir string) (Status, error)

ReadStatusFile reads the tracker status from the status file on disk. This is used by the CLI to read counts from the running server.

type Tracker

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

Tracker holds salted hashes of unique server identifiers.

func Global

func Global() *Tracker

Global returns the singleton tracker. It is created on first call with a fresh random salt. Boot time is recorded at creation.

func (*Tracker) GetStatus

func (t *Tracker) GetStatus() Status

GetStatus returns the current counts.

func (*Tracker) RecordServer

func (t *Tracker) RecordServer(connIP, senderDomain string)

RecordServer records a connecting server IP and the sender's domain/IP. The connIP is the TCP connection's remote IP. The senderDomain is the domain part of the MAIL FROM address. Both are stored as salted hashes. Empty values are ignored.

Jump to

Keyboard shortcuts

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