feat(mail): operator-tunable IMAP/POP3 email seed (DEBT-026)
IMAP_EMAIL_SEED / POP3_EMAIL_SEED accept a directory (rglob *.eml + *.json) or a single .json/.eml. Loaded entries CONCATENATE with the hardcoded _BAIT_EMAILS — additive to the realism-engine emailgen output rather than replacing it. JSON dicts require from_addr / to_addr / subject / body; bare bodies are wrapped into RFC 5322 on load. compose_fragment reads service_cfg["email_seed"] and bind-mounts the host path read-only at /var/spool/decnet-emails/seed.
This commit is contained in:
@@ -4,11 +4,18 @@ from decnet.services.base import BaseService
|
||||
TEMPLATES_DIR = Path(__file__).parent.parent / "templates" / "imap"
|
||||
|
||||
|
||||
_SEED_CONTAINER_PATH = "/var/spool/decnet-emails/seed"
|
||||
|
||||
|
||||
class IMAPService(BaseService):
|
||||
name = "imap"
|
||||
ports = [143, 993]
|
||||
default_image = "build"
|
||||
# config_schema: no user-tunable fields yet — TODO add when compose_fragment grows cfg reads
|
||||
# Optional config:
|
||||
# email_seed: host path to a directory of .eml/.json files OR a
|
||||
# single .json/.eml. Mounted read-only into the
|
||||
# container; entries concatenate with the hardcoded
|
||||
# bait list (additive to realism-engine output).
|
||||
|
||||
def compose_fragment(self, decky_name: str, log_target: str | None = None, service_cfg: dict | None = None) -> dict:
|
||||
fragment: dict = {
|
||||
@@ -19,6 +26,14 @@ class IMAPService(BaseService):
|
||||
}
|
||||
if log_target:
|
||||
fragment["environment"]["LOG_TARGET"] = log_target
|
||||
if service_cfg:
|
||||
seed = service_cfg.get("email_seed")
|
||||
if seed:
|
||||
host_path = str(Path(str(seed)).expanduser().resolve())
|
||||
fragment["environment"]["IMAP_EMAIL_SEED"] = _SEED_CONTAINER_PATH
|
||||
fragment.setdefault("volumes", []).append(
|
||||
f"{host_path}:{_SEED_CONTAINER_PATH}:ro"
|
||||
)
|
||||
return fragment
|
||||
|
||||
def dockerfile_context(self) -> Path | None:
|
||||
|
||||
@@ -4,11 +4,17 @@ from decnet.services.base import BaseService
|
||||
TEMPLATES_DIR = Path(__file__).parent.parent / "templates" / "pop3"
|
||||
|
||||
|
||||
_SEED_CONTAINER_PATH = "/var/spool/decnet-emails/seed"
|
||||
|
||||
|
||||
class POP3Service(BaseService):
|
||||
name = "pop3"
|
||||
ports = [110, 995]
|
||||
default_image = "build"
|
||||
# config_schema: no user-tunable fields yet — TODO add when compose_fragment grows cfg reads
|
||||
# Optional config:
|
||||
# email_seed: host path to a directory of .eml/.json files OR a
|
||||
# single .json/.eml. Mounted read-only; entries
|
||||
# concatenate with the hardcoded bait list.
|
||||
|
||||
def compose_fragment(self, decky_name: str, log_target: str | None = None, service_cfg: dict | None = None) -> dict:
|
||||
fragment: dict = {
|
||||
@@ -19,6 +25,14 @@ class POP3Service(BaseService):
|
||||
}
|
||||
if log_target:
|
||||
fragment["environment"]["LOG_TARGET"] = log_target
|
||||
if service_cfg:
|
||||
seed = service_cfg.get("email_seed")
|
||||
if seed:
|
||||
host_path = str(Path(str(seed)).expanduser().resolve())
|
||||
fragment["environment"]["POP3_EMAIL_SEED"] = _SEED_CONTAINER_PATH
|
||||
fragment.setdefault("volumes", []).append(
|
||||
f"{host_path}:{_SEED_CONTAINER_PATH}:ro"
|
||||
)
|
||||
return fragment
|
||||
|
||||
def dockerfile_context(self) -> Path | None:
|
||||
|
||||
Reference in New Issue
Block a user