Documentation
¶
Index ¶
- Constants
- Variables
- func AccountsHandler(deps AccountsDeps) func(string, json.RawMessage) (interface{}, int, error)
- func AdminWebHandler(deps SettingsToggleDeps) 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 EndpointCacheHandler(deps EndpointCacheDeps) func(string, json.RawMessage) (interface{}, int, error)
- func GenericSettingHandler(settingKey string, deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
- func HTTPProxyHandler(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 NoticeHandler(deps NoticeDeps) 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 SsGrpcHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
- func SsWsHandler(deps SettingsToggleDeps) 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 EndpointCacheDeps
- type NoticeDeps
- 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__" KeySsWsEnabled = "__SS_WS_ENABLED__" KeySsGrpcEnabled = "__SS_GRPC_ENABLED__" KeyHTTPProxyEnabled = "__HTTP_PROXY_ENABLED__" KeyAdminWebEnabled = "__ADMIN_WEB_ENABLED__" // Port settings KeySMTPPort = "__SMTP_PORT__" KeySubmissionPort = "__SUBMISSION_PORT__" KeyIMAPPort = "__IMAP_PORT__" KeyTurnPort = "__TURN_PORT__" KeySaslPort = "__SASL_PORT__" KeyIrohPort = "__IROH_PORT__" KeySsPort = "__SS_PORT__" KeySsWsPort = "__SS_WS_PORT__" KeySsGrpcPort = "__SS_GRPC_PORT__" KeyHTTPPort = "__HTTP_PORT__" KeyHTTPSPort = "__HTTPS_PORT__" KeyHTTPProxyPort = "__HTTP_PROXY_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__" KeyHTTPProxyPath = "__HTTP_PROXY_PATH__" KeyHTTPProxyUsername = "__HTTP_PROXY_USERNAME__" KeyHTTPProxyPassword = "__HTTP_PROXY_PASSWORD__" KeyAdminPath = "__ADMIN_PATH__" KeyAdminWebPath = "__ADMIN_WEB_PATH__" )
Setting key constants for all configurable values.
Variables ¶
var DNSCacheHandler = EndpointCacheHandler
DNSCacheHandler is an alias for backward compatibility.
Functions ¶
func AccountsHandler ¶
func AccountsHandler(deps AccountsDeps) func(string, json.RawMessage) (interface{}, int, error)
AccountsHandler creates a handler for /admin/accounts.
func AdminWebHandler ¶ added in v0.21.0
func AdminWebHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
AdminWebHandler creates a handler for /admin/services/admin_web.
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 EndpointCacheHandler ¶ added in v0.16.0
func EndpointCacheHandler(deps EndpointCacheDeps) func(string, json.RawMessage) (interface{}, int, error)
EndpointCacheHandler creates a handler for /admin/endpoint-cache (and /admin/dns for backward compat).
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 HTTPProxyHandler ¶ added in v0.26.0
func HTTPProxyHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
HTTPProxyHandler creates a handler for /admin/services/http_proxy.
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 NoticeHandler ¶ added in v0.22.0
func NoticeHandler(deps NoticeDeps) func(string, json.RawMessage) (interface{}, int, error)
NoticeHandler creates a handler for /admin/notice. POST: Send an admin notice (unencrypted email) to one or all users. GET: Returns basic info about the notice capability.
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 SsGrpcHandler ¶ added in v0.26.0
func SsGrpcHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
SsGrpcHandler creates a handler for /admin/services/ss_grpc.
func SsWsHandler ¶ added in v0.26.0
func SsWsHandler(deps SettingsToggleDeps) func(string, json.RawMessage) (interface{}, int, error)
SsWsHandler creates a handler for /admin/services/ss_ws.
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"
AdminWebEnabled string `json:"admin_web_enabled"` // "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"`
SsWsPort settingValueResponse `json:"ss_ws_port"`
SsGrpcPort settingValueResponse `json:"ss_grpc_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"`
ShadowsocksURL string `json:"shadowsocks_url"`
// Proxy toggle settings
SsWsEnabled string `json:"ss_ws_enabled"` // "enabled" or "disabled"
SsGrpcEnabled string `json:"ss_grpc_enabled"` // "enabled" or "disabled"
HTTPProxyEnabled string `json:"http_proxy_enabled"` // "enabled" or "disabled"
// HTTP Proxy settings
HTTPProxyPort settingValueResponse `json:"http_proxy_port"`
HTTPProxyPath settingValueResponse `json:"http_proxy_path"`
HTTPProxyUsername settingValueResponse `json:"http_proxy_username"`
HTTPProxyPassword settingValueResponse `json:"http_proxy_password"`
AdminPath settingValueResponse `json:"admin_path"`
AdminWebPath settingValueResponse `json:"admin_web_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 ¶
type DNSCacheDeps = EndpointCacheDeps
DNSCacheDeps is an alias for backward compatibility.
type DatabaseInfo ¶
type EmailServers ¶
type EndpointCacheDeps ¶ added in v0.16.0
EndpointCacheDeps are the dependencies needed by the endpoint cache handler.
type NoticeDeps ¶ added in v0.22.0
type NoticeDeps struct {
AuthDB module.PlainUserDB
Storage module.ManageableStorage
MailDomain string
}
NoticeDeps are the dependencies needed by the notice resource handler.
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
DeleteSetting func(key string) error
GetShadowsocksActiveSettings func() (password, cipher, port string)
GetSetting func(key string) (string, bool, error)
SetSetting func(key, value 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"`
}