config

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName         = "pm-cli"
	KeyringUser     = "bridge-password"
	DefaultIMAP     = "127.0.0.1"
	DefaultIMAPPort = 1143
	DefaultSMTP     = "127.0.0.1"
	DefaultSMTPPort = 1025

	// EnvBridgePassword is the environment variable consulted for the Bridge
	// password before falling back to the system keyring. This lets pm-cli run
	// on headless servers that have no D-Bus secret service available, where
	// keyring.Get fails with "org.freedesktop.secrets was not provided".
	EnvBridgePassword = "PM_CLI_BRIDGE_PASSWORD"
)

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() (string, error)

func ConfigPath

func ConfigPath() (string, error)

func DeletePassword

func DeletePassword(email string) error

func Exists

func Exists() bool

func ReleaseIdempotencyKey added in v0.2.6

func ReleaseIdempotencyKey(key string) error

ReleaseIdempotencyKey drops a reservation, so a send that failed can be retried with the same key. It is not an error to release a key that is not held.

func ReserveIdempotencyKey added in v0.2.6

func ReserveIdempotencyKey(key string) (bool, error)

ReserveIdempotencyKey atomically claims key. It returns true when the caller owns the reservation and should proceed, and false when the key is already held within the TTL, meaning this is a duplicate.

An empty key disables the mechanism and always reserves successfully.

Errors are returned rather than swallowed: if the reservation state cannot be determined, the caller must not treat that as permission to send.

func ScrubSecrets added in v0.2.6

func ScrubSecrets(env []string) []string

ScrubSecrets returns env with every pm-cli credential variable removed.

Any code spawning a child process must build its environment from this rather than from os.Environ() directly. Without it, a Bridge password supplied via EnvBridgePassword is inherited by user-supplied commands (for example `mail watch --exec`), handing the mail credential to arbitrary third-party scripts.

The input slice is not modified.

Types

type BridgeConfig

type BridgeConfig struct {
	IMAPHost string `yaml:"imap_host"`
	IMAPPort int    `yaml:"imap_port"`
	SMTPHost string `yaml:"smtp_host"`
	SMTPPort int    `yaml:"smtp_port"`
	Email    string `yaml:"email"`
}

type Config

type Config struct {
	Bridge   BridgeConfig   `yaml:"bridge"`
	Defaults DefaultsConfig `yaml:"defaults"`
}

func DefaultConfig

func DefaultConfig() *Config

func Load

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

func (*Config) GetPassword

func (c *Config) GetPassword() (string, error)

func (*Config) Save

func (c *Config) Save(path string) error

func (*Config) SetPassword

func (c *Config) SetPassword(password string) error

type DefaultsConfig

type DefaultsConfig struct {
	Mailbox string `yaml:"mailbox"`
	Limit   int    `yaml:"limit"`
	Format  string `yaml:"format"`
}

Jump to

Keyboard shortcuts

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