mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 16:24:37 +03:00
webadmin: make routes configurable: globally, per domain, per account
this simplifies some of the code that makes modifications to the config file. a few protected functions can make changes to the dynamic config, which webadmin can use. instead of having separate functions in mox-/admin.go for each type of change. this also exports the parsed full dynamic config to webadmin, so we need fewer functions for specific config fields too.
This commit is contained in:
@ -163,6 +163,14 @@ func (c *Config) loadDynamic() []error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DynamicConfig returns a shallow copy of the dynamic config. Must not be modified.
|
||||
func (c *Config) DynamicConfig() (config config.Dynamic) {
|
||||
c.withDynamicLock(func() {
|
||||
config = c.Dynamic // Shallow copy.
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Config) Domains() (l []string) {
|
||||
c.withDynamicLock(func() {
|
||||
for name := range c.Dynamic.Domains {
|
||||
@ -224,14 +232,6 @@ func (c *Config) AccountDestination(addr string) (accDests AccountDestination, o
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Config) WebServer() (r map[dns.Domain]dns.Domain, l []config.WebHandler) {
|
||||
c.withDynamicLock(func() {
|
||||
r = c.Dynamic.WebDNSDomainRedirects
|
||||
l = c.Dynamic.WebHandlers
|
||||
})
|
||||
return r, l
|
||||
}
|
||||
|
||||
func (c *Config) Routes(accountName string, domain dns.Domain) (accountRoutes, domainRoutes, globalRoutes []config.Route) {
|
||||
c.withDynamicLock(func() {
|
||||
acc := c.Dynamic.Accounts[accountName]
|
||||
@ -245,13 +245,6 @@ func (c *Config) Routes(accountName string, domain dns.Domain) (accountRoutes, d
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Config) MonitorDNSBLs() (zones []dns.Domain) {
|
||||
c.withDynamicLock(func() {
|
||||
zones = c.Dynamic.MonitorDNSBLZones
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Config) allowACMEHosts(log mlog.Log, checkACMEHosts bool) {
|
||||
for _, l := range c.Static.Listeners {
|
||||
if l.TLS == nil || l.TLS.ACME == "" {
|
||||
|
Reference in New Issue
Block a user