config

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultProfileID = "default"

DefaultProfileID is the synthetic ID used for the legacy single Profile block when no profiles: list is configured, and is what pre-multi-profile history rows are attributed to after the profile_id migration.

Variables

View Source
var Providers = []Provider{
	{ID: "gmail", Name: "Gmail", SMTPHost: "smtp.gmail.com", SMTPPort: 465, IMAPHost: "imap.gmail.com", IMAPPort: 993,
		HelpURL: "https://myaccount.google.com/apppasswords", Note: "Needs 2-Step Verification and a 16-character app password."},

	{ID: "proton", Name: "Proton Mail (Bridge, unverified)", SMTPHost: "127.0.0.1", SMTPPort: 1025, IMAPHost: "127.0.0.1", IMAPPort: 1143,
		HelpURL: "https://proton.me/mail/bridge", Note: "Requires Proton Mail Bridge running on this machine (paid plan). Use the password Bridge shows, not your Proton password. Not yet tested by the maintainers - if it works (or doesn't) for you, please say so: https://github.com/drumandbytes/eraser/issues/new?template=mail_provider.yml"},
	{ID: "fastmail", Name: "Fastmail", SMTPHost: "smtp.fastmail.com", SMTPPort: 465, IMAPHost: "imap.fastmail.com", IMAPPort: 993,
		HelpURL: "https://www.fastmail.help/", Note: "Create an app password with IMAP + SMTP access."},
	{ID: "mailbox-org", Name: "mailbox.org", SMTPHost: "smtp.mailbox.org", SMTPPort: 465, IMAPHost: "imap.mailbox.org", IMAPPort: 993,
		HelpURL: "https://kb.mailbox.org/", Note: "An application password is recommended."},
	{ID: "posteo", Name: "Posteo", SMTPHost: "posteo.de", SMTPPort: 465, IMAPHost: "posteo.de", IMAPPort: 993,
		HelpURL: "https://posteo.de/en/help", Note: "Uses your Posteo address and password."},
	{ID: "icloud", Name: "iCloud Mail", SMTPHost: "smtp.mail.me.com", SMTPPort: 587, IMAPHost: "imap.mail.me.com", IMAPPort: 993,
		HelpURL: "https://support.apple.com/en-us/102654", Note: "Needs an app-specific password."},
	{ID: "ses", Name: "Amazon SES (send only)", SMTPHost: "email-smtp.eu-west-1.amazonaws.com", SMTPPort: 465,
		HelpURL: "https://docs.aws.amazon.com/ses/latest/dg/smtp-credentials.html", Note: "Use SES SMTP credentials (username is not your address) and change the region in the host if needed. The From address must be verified in SES. SES has no inbox: monitor replies through a separate account."},
	{ID: "custom", Name: "Other (custom SMTP/IMAP)", Note: "Any provider with SMTP and IMAP access. Port 465/993 use TLS directly; other ports use STARTTLS."},
}

Providers is the preset list shown in setup, in display order. Adding a provider = one entry here (see CONTRIBUTING.md). TLS mode needs no field: it follows from the port, see ImplicitTLS.

Functions

func ApplyInboxDefaults added in v0.10.0

func ApplyInboxDefaults(inbox *InboxConfig)

ApplyInboxDefaults is applyInboxDefaults for configs edited at runtime (Load's defaults only run at startup).

func DefaultConfigPath

func DefaultConfigPath() string

func ImplicitTLS added in v0.10.0

func ImplicitTLS(port int) bool

ImplicitTLS reports whether port speaks TLS from the first byte (SMTPS 465, IMAPS 993). Every other port must upgrade with STARTTLS.

func ProviderIDForHosts added in v0.10.0

func ProviderIDForHosts(smtpHost, imapHost string) string

ProviderIDForHosts guesses the preset of a saved account by host (IMAP only when there's no SMTP host). Nothing saved = gmail, the historical default; an unknown host = custom.

func ProviderName added in v0.10.0

func ProviderName(smtpHost string) string

ProviderName labels an SMTP host for display: the preset name, else the host.

func Save

func Save(path string, cfg *Config) error

func SlugifyID

func SlugifyID(s string) string

SlugifyID lowercases and hyphenates s, keeping only [a-z0-9]. Every profile ID must go through it: net/http silently drops non-ASCII bytes from Set-Cookie, so an ID with diacritics breaks the web UI's profile cookie.

func SlugifyProfileID

func SlugifyProfileID(firstName, lastName string, existing []NamedProfile) string

SlugifyProfileID derives an ID from first/last name (see SlugifyID), appending -2, -3, ... when taken.

func TLSFor added in v0.10.0

func TLSFor(host string) *tls.Config

TLSFor is the TLS config for a mail server. Loopback hosts skip certificate verification: Proton Mail Bridge serves a self-signed cert on 127.0.0.1. ponytail: blanket skip on loopback; pin the exported Bridge cert if a local MITM ever matters.

Types

type Config

type Config struct {
	// Profile is the pre-0.11 single-profile block. Load/Save move it into
	// Profiles as "default", so nothing writes it any more; read profiles via
	// GetProfiles/GetProfile.
	Profile Profile `yaml:"profile,omitempty"`
	// Profiles tracks removal requests for several people against the same
	// brokers, mail account and options; history is kept per profile
	// (profile_id). Takes precedence over Profile.
	Profiles []NamedProfile `yaml:"profiles,omitempty"`
	Email    EmailConfig    `yaml:"email"`
	Options  Options        `yaml:"options"`
	Inbox    InboxConfig    `yaml:"inbox,omitempty"`
	Pipeline Pipeline       `yaml:"pipeline,omitempty"`
	Schedule Schedule       `yaml:"schedule,omitempty"`
}

func Load

func Load(path string) (*Config, error)

func (*Config) ConfiguredInboxes added in v0.8.0

func (c *Config) ConfiguredInboxes() []InboxConfig

ConfiguredInboxes returns every enabled IMAP inbox across profiles (overrides or the shared one), deduplicated by address, so `monitor` covers everyone.

func (*Config) EmailForProfile added in v0.8.0

func (c *Config) EmailForProfile(p NamedProfile) EmailConfig

EmailForProfile returns the SMTP config to use for sends made under this profile: its Mail.Email override if set, otherwise the shared top-level Email block.

func (*Config) GetProfile

func (c *Config) GetProfile(id string) (NamedProfile, error)

GetProfile resolves a profile by ID. Empty id works only when exactly one profile exists; otherwise it errors with the available IDs.

func (*Config) GetProfiles

func (c *Config) GetProfiles() []NamedProfile

GetProfiles returns every profile. The legacy profile: fallback only matters for configs built in memory; Load/Save normalize it away.

func (*Config) HasProfile added in v0.11.0

func (c *Config) HasProfile() bool

HasProfile reports whether setup has stored anyone's details yet.

func (*Config) InboxForProfile added in v0.8.0

func (c *Config) InboxForProfile(p NamedProfile) InboxConfig

InboxForProfile returns the IMAP config to use when monitoring replies for this profile: its Mail.Inbox override if set, otherwise the shared top-level Inbox block.

func (*Config) IsManualSend

func (c *Config) IsManualSend() bool

IsManualSend reports whether the user opted out of automated sending - Eraser renders the emails but never transmits them.

func (*Config) PrimaryProfile added in v0.11.0

func (c *Config) PrimaryProfile() NamedProfile

PrimaryProfile is the "default" profile if there is one, else the first: the one `eraser init` edits and fresh-profile forms prefill from.

func (*Config) Validate

func (c *Config) Validate() error

func (*Config) ValidateInbox

func (c *Config) ValidateInbox() error

ValidateInbox validates inbox configuration (only called when inbox monitoring is used)

type Email

type Email = EmailConfig

type EmailConfig

type EmailConfig struct {
	// Provider is optional and only "smtp" is accepted - SMTP is the only
	// transport. Kept so pre-0.11 configs (which all say "smtp") still load.
	Provider string     `yaml:"provider,omitempty"`
	From     string     `yaml:"from"`
	SMTP     SMTPConfig `yaml:"smtp,omitempty"`
}

func (EmailConfig) Configured added in v0.11.0

func (e EmailConfig) Configured() bool

Configured reports whether a sending account is set up at all.

type InboxConfig

type InboxConfig struct {
	Enabled       bool   `yaml:"enabled"`
	Provider      string `yaml:"provider,omitempty"` // preset id (see Providers) that fills Server/Port; optional when they're set
	Server        string `yaml:"server"`             // e.g., "imap.fastmail.com"
	Port          int    `yaml:"port"`               // 993 = implicit TLS, anything else = STARTTLS
	Email         string `yaml:"email"`              // Email address to monitor
	Password      string `yaml:"password"`           // App password (not main password)
	Folder        string `yaml:"folder"`             // Folder to monitor (default: "INBOX")
	AutoArchive   bool   `yaml:"auto_archive"`       // Automatically move processed emails to archive folder
	ArchiveFolder string `yaml:"archive_folder"`     // Folder to archive emails to (default: "Eraser")
}

InboxConfig holds IMAP settings for monitoring broker responses

type MailConfig added in v0.8.0

type MailConfig struct {
	Email *EmailConfig `yaml:"email,omitempty"`
	Inbox *InboxConfig `yaml:"inbox,omitempty"`
}

MailConfig holds one profile's email/inbox overrides. Either field may be set independently - e.g. a profile can send from its own SMTP account while still sharing the default inbox for reply monitoring.

type NamedProfile

type NamedProfile struct {
	// ID: short, lowercase, hyphenated. Stored verbatim in history.db, so
	// renaming it orphans the profile's existing history.
	ID      string `yaml:"id"`
	Profile `yaml:",inline"`
	// Mail overrides the shared email:/inbox: blocks for this profile only
	// (see EmailForProfile/InboxForProfile). nil = use the shared blocks.
	Mail *MailConfig `yaml:"mail,omitempty"`
}

NamedProfile is a person's identity plus the stable ID used by --profile, history rows and the web UI's switcher.

type Options

type Options struct {
	Template string `yaml:"template"`
	// SendMode:
	//   "" / "smtp" - Eraser sends over the configured SMTP account.
	//   "manual"    - Eraser renders the emails for you to send yourself and
	//                 record with `eraser mark-sent` / "Mark sent". No email:
	//                 block needed; for users who won't share mailbox credentials.
	SendMode    string `yaml:"send_mode,omitempty"`
	DryRun      bool   `yaml:"dry_run,omitempty"`
	RateLimitMs int    `yaml:"rate_limit_ms"`
	// DailySendLimit caps sends per rolling 24h to stay under provider limits
	// (Gmail ~500/day). 0 = 450. Bypass with --ignore-daily-limit.
	DailySendLimit int `yaml:"daily_send_limit,omitempty"`
	// BrokerList: "" / "full" (~720 entries, default) or "verified"
	// (data/brokers-verified.yaml). Overridden by `send --list`; ignored when
	// BrokerFile or --brokers is set.
	BrokerList string `yaml:"broker_list,omitempty"`
	// BrokerFile points the send-family commands at your own broker list,
	// the config equivalent of the global --brokers flag (which still wins).
	// Takes precedence over BrokerList.
	BrokerFile      string   `yaml:"broker_file,omitempty"`
	Regions         []string `yaml:"regions,omitempty"`
	ExcludedBrokers []string `yaml:"excluded_brokers,omitempty"`
	// ExcludedCategories skips brokers by category (case-insensitive), e.g.
	// "requires-id" for brokers that demand an ID document.
	ExcludedCategories []string `yaml:"excluded_categories,omitempty"`
}

type Pipeline

type Pipeline struct {
	// BrowserHeadless is a pointer so an explicit false survives loading (a
	// plain bool was forced back to true). Read it via Headless().
	BrowserHeadless   *bool `yaml:"browser_headless,omitempty"`
	BrowserTimeoutSec int   `yaml:"browser_timeout_sec"` // Browser operation timeout
}

Pipeline holds settings for the automation pipeline

func (Pipeline) Headless

func (p Pipeline) Headless() bool

Headless returns the effective headless setting, defaulting to true when BrowserHeadless was never set in the config.

type Profile

type Profile struct {
	FirstName string `yaml:"first_name"`
	// MiddleName: some brokers (background-check, financial-b2b) match on
	// full legal name.
	MiddleName string `yaml:"middle_name,omitempty"`
	LastName   string `yaml:"last_name"`
	Email      string `yaml:"email"`
	// AdditionalEmails: older addresses a broker may have indexed you under.
	AdditionalEmails []string `yaml:"additional_emails,omitempty"`
	// NameVariants covers other spellings brokers may have indexed you under -
	// e.g. a diacritic-free version of your name ("Maris" for "Māris"), a
	// maiden name, or a nickname you've used to sign up for things.
	NameVariants []string `yaml:"name_variants,omitempty"`
	// PreviousAddresses: partial ones still help, since matching keys off
	// street/city/postal code.
	PreviousAddresses []string `yaml:"previous_addresses,omitempty"`
	Address           string   `yaml:"address,omitempty"`
	City              string   `yaml:"city,omitempty"`
	State             string   `yaml:"state,omitempty"`
	ZipCode           string   `yaml:"zip_code,omitempty"`
	Country           string   `yaml:"country,omitempty"`
	Phone             string   `yaml:"phone,omitempty"`
	// AdditionalPhones covers other numbers you've used to sign up for
	// things (an old number, a work line) that a broker might have on file
	// instead of your current one.
	AdditionalPhones []string `yaml:"additional_phones,omitempty"`
	DateOfBirth      string   `yaml:"date_of_birth,omitempty"`
}

func (Profile) FullName

func (p Profile) FullName() string

type Provider added in v0.10.0

type Provider struct {
	ID       string
	Name     string
	SMTPHost string
	SMTPPort int
	IMAPHost string // "" = send-only (no mailbox, e.g. SES)
	IMAPPort int
	HelpURL  string // where to create the app/bridge password
	Note     string
}

Provider is a mail-account preset. It only prefills setup forms and fills a missing inbox server/port at load; the stored config is plain SMTP/IMAP.

func ProviderByID added in v0.10.0

func ProviderByID(id string) (Provider, bool)

ProviderByID returns the preset with that id, or false.

type SMTPConfig

type SMTPConfig struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	// UseTLS defaults to true; the mode follows the port (465 implicit TLS,
	// anything else STARTTLS). false is only for an unauthenticated local
	// relay. Read it via TLS().
	UseTLS *bool `yaml:"use_tls,omitempty"`
}

func (SMTPConfig) TLS added in v0.11.0

func (s SMTPConfig) TLS() bool

TLS returns the effective use_tls, true unless explicitly turned off.

type Schedule added in v0.9.0

type Schedule struct {
	// Enabled makes a running 'eraser serve' run a cycle every 6 hours.
	// Ignored while the OS job is installed.
	Enabled bool `yaml:"enabled,omitempty"`
}

Schedule is the in-app fallback for automated cycles when the OS scheduler ('eraser schedule install') isn't set up.

Jump to

Keyboard shortcuts

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