lodge

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lodge serves maild as lodge's mail app on its app socket (docs/specs/lodge-app.md, ADR-0041): /health, the /api WebSocket as caller session, and /content/ for reader pages, parts and whole messages, which lodge-content serves to the reader's frame and to downloads.

Index

Constants

View Source
const (
	MaxPages     = 64
	MaxPageBytes = 64 << 20
)

Limits on the reader pages kept for the content route; past either, the least recently kept page goes.

View Source
const (
	PagePolicy = "default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:; " +
		"base-uri 'none'; form-action 'none'; sandbox allow-popups allow-popups-to-escape-sandbox"
	PartPolicy = "default-src 'none'; img-src data:; style-src 'unsafe-inline'; sandbox"
)

The policies maild sends beside lodge's on content responses. A reader page may open the tabs its links ask for (the manifest's contentLinks); neither runs scripts or loads anything but data: URLs.

View Source
const ID = "mail"

ID is the mail app's id in lodge: its socket's name and URL segment.

Variables

This section is empty.

Functions

func Caller

func Caller(c lodgeapp.Caller) api.Caller

Caller is the RPC caller of a session lodge sent to /api.

func Listen

func Listen() (*lodgeapp.Listener, error)

Listen opens maild's lodge socket: one systemd passed, else /run/lodge/apps/mail.sock, or the same under LODGE_ROOT (docs/specs/lodge-app.md, Listeners). It admits lodge's uid only. lodge runs on Linux, so elsewhere (a Windows install) it refuses.

func NewServer

func NewServer(o Options) *lodgeapp.Server

NewServer is maild's side of lodge's app socket, through the kit: /health, /api as caller session, /content/ as caller content and /mcp as caller agent. lodge's other routes answer 404.

Types

type Blobs

type Blobs interface {
	Open(id string) (io.ReadCloser, error)
}

Blobs opens a stored message by its blob ID (blob.Store).

type Content

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

Content is what maild serves under /content/: reader pages kept in memory, and files of the parts cache and stored messages named by a MAC under a key drawn at start, so content paths are unguessable and end with the process.

func NewContent

func NewContent(parts *render.PartsCache, blobs Blobs) (*Content, error)

NewContent serves parts from parts and messages' sources from blobs.

func (*Content) KeepPage

func (c *Content) KeepPage(body []byte) string

KeepPage keeps a reader page and returns its content path, r/<token>.html, or "" for a page larger than MaxPageBytes.

func (*Content) PartPath

func (c *Content) PartPath(rel string) string

PartPath is the content path of rel, a path in the parts cache: p/<mac>/<rel with each segment percent-encoded>.

func (*Content) ServeHTTP

func (c *Content) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves GET and HEAD /content/<content path>. lodge has checked the caller; the socket's mux sends only caller content here.

func (*Content) SourcePath

func (c *Content) SourcePath(blobID, name string) string

SourcePath is the content path of a stored message, the blob blobID, saved as name: m/<mac>/<blobID>/<name percent-encoded>. The MAC covers the name too, so a path names one file name.

type Options

type Options struct {
	// Ctx bounds the agents' connections to maild, which outlive the
	// request that opened their MCP session, and the MCP sessions' janitor:
	// maild's own context.
	Ctx context.Context
	// Version is maild's, for /health.
	Version string
	// RPC and Router serve /api, as the private socket does.
	RPC    *rpcserver.Server
	Router *api.Router
	// Content serves /content/.
	Content *Content
	Log     *slog.Logger
	// Now is the MCP tools' clock; nil is time.Now.
	Now func() time.Time
	// Unread is the count for lodge's rail badge (lodge ADR-0020): the
	// unread messages in every inbox. nil sends no badge.
	Unread func(ctx context.Context) (int, error)
}

Options are what maild's lodge socket serves.

Jump to

Keyboard shortcuts

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