Documentation
¶
Index ¶
- Constants
- func AccountsHandler(deps AccountsDeps) func(string, json.RawMessage) (interface{}, int, error)
- func AllSettingsHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
- func BlocklistHandler(deps BlocklistDeps) func(string, json.RawMessage) (interface{}, int, error)
- func DNSCacheHandler(deps DNSCacheDeps) func(string, json.RawMessage) (interface{}, int, error)
- func GenericSettingHandler(settingKey string, deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
- func IrohHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
- func JitRegistrationHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
- func LogHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
- func QueueHandler(deps QueueDeps) func(string, json.RawMessage) (interface{}, int, error)
- func QuotaHandler(deps QuotaDeps) func(string, json.RawMessage) (interface{}, int, error)
- func RegistrationHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
- func ReloadHandler(deps ReloadDeps) func(string, json.RawMessage) (interface{}, int, error)
- func RestartHandler() func(method string, body json.RawMessage) (interface{}, int, error)
- func ShadowsocksHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
- func SharesHandler(deps SharesDeps) func(string, json.RawMessage) (interface{}, int, error)
- func StatusHandler(deps StatusDeps) func(method string, body json.RawMessage) (interface{}, int, error)
- func StorageHandler(deps StorageDeps) func(method string, body json.RawMessage) (interface{}, int, error)
- func TurnHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
- type AccountsDeps
- type AllSettingsResponse
- type BlocklistDeps
- type DNSCacheDeps
- type DatabaseInfo
- type DiskInfo
- type EmailServers
- type QueueDeps
- type QuotaDeps
- type ReloadDeps
- type ServiceStatus
- type SettingsToggleDeps
- type SharesDeps
- type StateDirInfo
- type StatusDeps
- type StatusResponse
- type StorageDeps
- type StorageResponse
- type TurnStatus
- type UptimeStatus
- type UsersStatus
Constants ¶
const ( KeyRegistrationOpen = "__REGISTRATION_OPEN__" KeyJitRegistrationEnabled = "__JIT_REGISTRATION_ENABLED__" KeyTurnEnabled = "__TURN_ENABLED__" KeyLogDisabled = "__LOG_DISABLED__" KeyIrohEnabled = "__IROH_ENABLED__" KeySsEnabled = "__SS_ENABLED__" // Port settings KeySMTPPort = "__SMTP_PORT__" KeySubmissionPort = "__SUBMISSION_PORT__" KeyIMAPPort = "__IMAP_PORT__" KeyTurnPort = "__TURN_PORT__" KeySaslPort = "__SASL_PORT__" KeyIrohPort = "__IROH_PORT__" KeySsPort = "__SS_PORT__" KeyHTTPPort = "__HTTP_PORT__" KeyHTTPSPort = "__HTTPS_PORT__" // Per-port access control ("true" = local only, default unset = public) KeySMTPLocalOnly = "__SMTP_LOCAL_ONLY__" KeySubmissionLocalOnly = "__SUBMISSION_LOCAL_ONLY__" KeyIMAPLocalOnly = "__IMAP_LOCAL_ONLY__" KeyTurnLocalOnly = "__TURN_LOCAL_ONLY__" KeySaslLocalOnly = "__SASL_LOCAL_ONLY__" KeyIrohLocalOnly = "__IROH_LOCAL_ONLY__" KeyHTTPLocalOnly = "__HTTP_LOCAL_ONLY__" KeyHTTPSLocalOnly = "__HTTPS_LOCAL_ONLY__" // Configuration settings KeySMTPHostname = "__SMTP_HOSTNAME__" KeyTurnRealm = "__TURN_REALM__" KeyTurnSecret = "__TURN_SECRET__" KeyTurnRelayIP = "__TURN_RELAY_IP__" KeyTurnTTL = "__TURN_TTL__" KeyIrohRelayURL = "__IROH_RELAY_URL__" KeySsCipher = "__SS_CIPHER__" KeySsPassword = "__SS_PASSWORD__" KeyAdminPath = "__ADMIN_PATH__" )
Setting key constants for all configurable values.
Variables ¶
This section is empty.
Functions ¶
func AccountsHandler ¶
func AccountsHandler(deps AccountsDeps) func(string, json.RawMessage) (interface{}, int, error)
AccountsHandler creates a handler for /admin/accounts.
func AllSettingsHandler ¶ added in v0.15.0
func AllSettingsHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
AllSettingsHandler creates a handler for GET /admin/settings that returns all settings at once.
func BlocklistHandler ¶ added in v0.15.0
func BlocklistHandler(deps BlocklistDeps) func(string, json.RawMessage) (interface{}, int, error)
BlocklistHandler creates a handler for /admin/blocklist.
func DNSCacheHandler ¶
func DNSCacheHandler(deps DNSCacheDeps) func(string, json.RawMessage) (interface{}, int, error)
DNSCacheHandler creates a handler for /admin/dns.
func GenericSettingHandler ¶ added in v0.15.0
func GenericSettingHandler(settingKey string, deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
GenericSettingHandler creates a handler for a single string-valued DB setting. Supports GET (read), POST with action "set" + "value", and POST with action "reset".
func IrohHandler ¶
func IrohHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
IrohHandler creates a handler for /admin/services/iroh.
func JitRegistrationHandler ¶
func JitRegistrationHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
JitRegistrationHandler creates a handler for /admin/registration/jit.
func LogHandler ¶ added in v0.15.0
func LogHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
LogHandler creates a handler for /admin/services/log.
func QueueHandler ¶
QueueHandler creates a handler for /admin/queue.
func QuotaHandler ¶
QuotaHandler creates a handler for /admin/quota.
func RegistrationHandler ¶
func RegistrationHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
RegistrationHandler creates a handler for /admin/registration.
func ReloadHandler ¶ added in v0.15.0
func ReloadHandler(deps ReloadDeps) func(string, json.RawMessage) (interface{}, int, error)
ReloadHandler creates a handler for POST /admin/reload. This endpoint regenerates the configuration file from DB-stored overrides and triggers a service restart via SIGUSR2 (graceful reload).
func RestartHandler ¶ added in v0.15.0
func RestartHandler() func(method string, body json.RawMessage) (interface{}, int, error)
RestartHandler creates a handler for POST /admin/restart. It schedules a service restart via systemctl after a short delay so the HTTP response can be sent back to the client first.
func ShadowsocksHandler ¶
func ShadowsocksHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
ShadowsocksHandler creates a handler for /admin/services/shadowsocks.
func SharesHandler ¶
func SharesHandler(deps SharesDeps) func(string, json.RawMessage) (interface{}, int, error)
SharesHandler creates a handler for /admin/shares.
func StatusHandler ¶
func StatusHandler(deps StatusDeps) func(method string, body json.RawMessage) (interface{}, int, error)
StatusHandler creates a handler for /admin/status.
func StorageHandler ¶
func StorageHandler(deps StorageDeps) func(method string, body json.RawMessage) (interface{}, int, error)
StorageHandler creates a handler for /admin/storage.
func TurnHandler ¶
func TurnHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
TurnHandler creates a handler for /admin/services/turn.
Types ¶
type AccountsDeps ¶
type AccountsDeps struct {
AuthDB module.PlainUserDB
Storage module.ManageableStorage
MailDomain string // Domain for email addresses (e.g., example.com)
}
AccountsDeps are the dependencies needed by the accounts resource handler.
type AllSettingsResponse ¶ added in v0.15.0
type AllSettingsResponse struct {
// Toggle settings
Registration string `json:"registration"` // "open" or "closed"
JitRegistration string `json:"jit_registration"` // "enabled" or "disabled"
TurnEnabled string `json:"turn_enabled"` // "enabled" or "disabled"
IrohEnabled string `json:"iroh_enabled"` // "enabled" or "disabled"
SsEnabled string `json:"ss_enabled"` // "enabled" or "disabled"
LogDisabled string `json:"log_disabled"` // "enabled" or "disabled"
// Port settings
SMTPPort settingValueResponse `json:"smtp_port"`
SubmissionPort settingValueResponse `json:"submission_port"`
IMAPPort settingValueResponse `json:"imap_port"`
TurnPort settingValueResponse `json:"turn_port"`
SaslPort settingValueResponse `json:"sasl_port"`
IrohPort settingValueResponse `json:"iroh_port"`
SsPort settingValueResponse `json:"ss_port"`
HTTPPort settingValueResponse `json:"http_port"`
HTTPSPort settingValueResponse `json:"https_port"`
// Per-port access control: "public" (default) or "local" (Shadowsocks only)
SMTPAccess string `json:"smtp_access"`
SubmissionAccess string `json:"submission_access"`
IMAPAccess string `json:"imap_access"`
TurnAccess string `json:"turn_access"`
SaslAccess string `json:"sasl_access"`
IrohAccess string `json:"iroh_access"`
HTTPAccess string `json:"http_access"`
HTTPSAccess string `json:"https_access"`
// Hostname / address settings
SMTPHostname settingValueResponse `json:"smtp_hostname"`
TurnRealm settingValueResponse `json:"turn_realm"`
TurnSecret settingValueResponse `json:"turn_secret"`
TurnRelayIP settingValueResponse `json:"turn_relay_ip"`
TurnTTL settingValueResponse `json:"turn_ttl"`
IrohRelayURL settingValueResponse `json:"iroh_relay_url"`
SsCipher settingValueResponse `json:"ss_cipher"`
SsPassword settingValueResponse `json:"ss_password"`
AdminPath settingValueResponse `json:"admin_path"`
}
AllSettingsResponse is the response for GET /admin/settings.
type BlocklistDeps ¶ added in v0.15.0
type BlocklistDeps struct {
Storage module.ManageableStorage
}
BlocklistDeps are the dependencies needed by the blocklist resource handler.
type DNSCacheDeps ¶
DNSCacheDeps are the dependencies needed by the DNS cache handler.
type DatabaseInfo ¶
type EmailServers ¶
type QueueDeps ¶
type QueueDeps struct {
Storage module.ManageableStorage
}
QueueDeps are the dependencies needed by the queue resource handler.
type QuotaDeps ¶
type QuotaDeps struct {
Storage module.ManageableStorage
}
QuotaDeps are the dependencies needed by the quota resource handler.
type ReloadDeps ¶ added in v0.15.0
type ReloadDeps struct {
// ReloadConfig is called to regenerate the config file and restart the service.
// It reads port/config overrides from the DB, regenerates maddy.conf, and restarts.
// Returns nil on success; the caller should expect the process to be terminated shortly after.
ReloadConfig func() error
}
ReloadDeps provides the callback for reloading the service configuration.
type ServiceStatus ¶
type SettingsToggleDeps ¶
type SettingsToggleDeps struct {
IsRegistrationOpen func() (bool, error)
SetRegistrationOpen func(bool) error
IsJitRegistrationEnabled func() (bool, error)
SetJitRegistrationEnabled func(bool) error
IsTurnEnabled func() (bool, error)
SetTurnEnabled func(bool) error
// Generic DB-backed settings (string key-value)
GetSetting func(key string) (string, bool, error)
SetSetting func(key, value string) error
DeleteSetting func(key string) error
}
SettingsToggleDeps provides methods to read/write settings flags.
type SharesDeps ¶
type SharesDeps struct {
}
SharesDeps are the dependencies needed by the shares resource handler.
type StateDirInfo ¶
type StatusDeps ¶
type StatusDeps struct {
GetUserCount func() (int, error)
GetSetting func(string) (string, bool, error)
}
StatusDeps are the dependencies needed by the status resource handler.
type StatusResponse ¶
type StatusResponse struct {
IMAP *ServiceStatus `json:"imap,omitempty"`
TURN *TurnStatus `json:"turn,omitempty"`
Shadowsocks *ServiceStatus `json:"shadowsocks,omitempty"`
Users *UsersStatus `json:"users"`
Uptime *UptimeStatus `json:"uptime"`
EmailServers *EmailServers `json:"email_servers,omitempty"`
SentMessages int64 `json:"sent_messages"`
OutboundMessages int64 `json:"outbound_messages"`
ReceivedMessages int64 `json:"received_messages"`
}
StatusResponse is the response body for /admin/status.
type StorageDeps ¶
StorageDeps are the dependencies needed by the storage resource handler.
type StorageResponse ¶
type StorageResponse struct {
Disk *DiskInfo `json:"disk"`
StateDir *StateDirInfo `json:"state_dir"`
Database *DatabaseInfo `json:"database,omitempty"`
}
StorageResponse is the response body for /admin/storage.
type TurnStatus ¶
type TurnStatus struct {
Relays int `json:"relays"`
}
type UptimeStatus ¶
type UsersStatus ¶
type UsersStatus struct {
Registered int `json:"registered"`
}