feat(mail-admin): read-only account view for mail.produktor.io (#74)
- admin/: Go stdlib-only HTTP viewer, lists accounts from config/postfix-accounts.cf with per-mailbox message counts (INBOX and total, same numbers doveadm reports) and storage; quota from dovecot-quotas.cf; Basic Auth from .env; offline tests vs fixtures (go test -race ./...) - compose: mail-admin service, build admin/Dockerfile, publishes 127.0.0.1:19945 / 172.17.0.1:19945; config and mail-data mounted :ro, no docker socket - NPM proxy host 66: location /admin/ -> 172.17.0.1:19945 - README: account admin section
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// Package main implements mail-admin, a read-only web view of the
|
||||
// docker-mailserver accounts on mail.produktor.io.
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Account is one mailbox from postfix-accounts.cf.
|
||||
type Account struct {
|
||||
Email string // full address, e.g. info@produktor.io
|
||||
Hash string // SHA512-CRYPT hash from the accounts file (never displayed)
|
||||
}
|
||||
|
||||
// parseAccounts reads a docker-mailserver postfix-accounts.cf file: one
|
||||
// "email|hash" per line, '#' comments and blank lines skipped. Malformed
|
||||
// lines are skipped, not fatal: a broken line must not hide the other
|
||||
// accounts.
|
||||
func parseAccounts(r io.Reader) ([]Account, error) {
|
||||
sc := bufio.NewScanner(r)
|
||||
var out []Account
|
||||
for sc.Scan() {
|
||||
line := strings.TrimSpace(sc.Text())
|
||||
if line == "" || strings.HasPrefix(line, "#") {
|
||||
continue
|
||||
}
|
||||
email, hash, ok := strings.Cut(line, "|")
|
||||
email = strings.TrimSpace(email)
|
||||
if !ok || email == "" {
|
||||
continue
|
||||
}
|
||||
out = append(out, Account{Email: email, Hash: strings.TrimSpace(hash)})
|
||||
}
|
||||
return out, sc.Err()
|
||||
}
|
||||
Reference in New Issue
Block a user