sites

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sites maps members' custom domains onto their homepage (the public_html that is also served at /~name).

How it works without a custom Caddy module:

  • The DB (store.domains) is the source of truth for domain→user.
  • A symlink farm at <data>/domains/<domain> -> <data>/users/<name>/public_html lets Caddy serve any mapped domain with `root * <data>/domains/{host}`.
  • AskHandler answers Caddy's on-demand-TLS query so certificates are only issued for domains that are actually mapped (no open cert relay).

A member points DNS (CNAME or A) at the BBS host; the moment a TLS handshake for that domain arrives, Caddy asks us, gets a 200, provisions a cert, and serves their homepage. See docs/custom-domains.md.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDomain = errors.New("invalid domain")

ErrInvalidDomain is returned for syntactically invalid hostnames.

Functions

func Normalize

func Normalize(d string) string

Normalize lowercases and trims a domain (drops a trailing dot, any scheme).

func Valid

func Valid(d string) bool

Valid reports whether d is a usable custom domain.

Types

type Manager

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

Manager owns the symlink farm and the on-demand-TLS ask endpoint.

func NewManager

func NewManager(st store.Store, dataDir string) (*Manager, error)

NewManager prepares the symlink farm under dataDir/domains.

func (*Manager) Add

func (m *Manager) Add(domain, username string) (string, error)

Add maps domain→username (DB row + symlink). Returns store.ErrDomainTaken if another member already owns it, or ErrInvalidDomain on a malformed host.

func (*Manager) AskHandler

func (m *Manager) AskHandler() http.Handler

AskHandler answers Caddy's on-demand-TLS query: 200 when the domain is mapped (so a cert may be issued), 404 otherwise. Caddy passes the requested host as ?domain=. Bind this to loopback only.

func (*Manager) List

func (m *Manager) List(username string) ([]string, error)

List returns the domains mapped to username.

func (*Manager) Remove

func (m *Manager) Remove(domain, username string) (string, error)

Remove unmaps a domain owned by username (DB row + symlink).

func (*Manager) ServeAsk

func (m *Manager) ServeAsk(addr string) error

ServeAsk runs the ask endpoint (blocking). Intended for a goroutine.

func (*Manager) Sync

func (m *Manager) Sync() error

Sync rebuilds the symlink farm from the DB. Run at startup so the farm survives a wiped data dir or hand edits, and so the DB stays authoritative.

Jump to

Keyboard shortcuts

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