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:
Mechiel Lukkien
2024-04-18 11:14:24 +02:00
parent baf4df55a6
commit a69887bfab
19 changed files with 1165 additions and 189 deletions

View File

@ -121,6 +121,26 @@
}
]
},
{
"Name": "DomainConfig",
"Docs": "DomainConfig returns the configuration for a domain.",
"Params": [
{
"Name": "domain",
"Typewords": [
"string"
]
}
],
"Returns": [
{
"Name": "r0",
"Typewords": [
"ConfigDomain"
]
}
]
},
{
"Name": "DomainLocalparts",
"Docs": "DomainLocalparts returns the encoded localparts and accounts configured in domain.",
@ -1528,6 +1548,73 @@
]
}
]
},
{
"Name": "Config",
"Docs": "Config returns the dynamic config.",
"Params": [],
"Returns": [
{
"Name": "r0",
"Typewords": [
"Dynamic"
]
}
]
},
{
"Name": "AccountRoutesSave",
"Docs": "AccountRoutesSave saves routes for an account.",
"Params": [
{
"Name": "accountName",
"Typewords": [
"string"
]
},
{
"Name": "routes",
"Typewords": [
"[]",
"Route"
]
}
],
"Returns": []
},
{
"Name": "DomainRoutesSave",
"Docs": "DomainRoutesSave saves routes for a domain.",
"Params": [
{
"Name": "domainName",
"Typewords": [
"string"
]
},
{
"Name": "routes",
"Typewords": [
"[]",
"Route"
]
}
],
"Returns": []
},
{
"Name": "RoutesSave",
"Docs": "RoutesSave saves global routes.",
"Params": [
{
"Name": "routes",
"Typewords": [
"[]",
"Route"
]
}
],
"Returns": []
}
],
"Sections": [],
@ -2794,6 +2881,368 @@
}
]
},
{
"Name": "ConfigDomain",
"Docs": "",
"Fields": [
{
"Name": "Description",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "ClientSettingsDomain",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "LocalpartCatchallSeparator",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "LocalpartCaseSensitive",
"Docs": "",
"Typewords": [
"bool"
]
},
{
"Name": "DKIM",
"Docs": "",
"Typewords": [
"DKIM"
]
},
{
"Name": "DMARC",
"Docs": "",
"Typewords": [
"nullable",
"DMARC"
]
},
{
"Name": "MTASTS",
"Docs": "",
"Typewords": [
"nullable",
"MTASTS"
]
},
{
"Name": "TLSRPT",
"Docs": "",
"Typewords": [
"nullable",
"TLSRPT"
]
},
{
"Name": "Routes",
"Docs": "",
"Typewords": [
"[]",
"Route"
]
}
]
},
{
"Name": "DKIM",
"Docs": "",
"Fields": [
{
"Name": "Selectors",
"Docs": "",
"Typewords": [
"{}",
"Selector"
]
},
{
"Name": "Sign",
"Docs": "",
"Typewords": [
"[]",
"string"
]
}
]
},
{
"Name": "Selector",
"Docs": "",
"Fields": [
{
"Name": "Hash",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "HashEffective",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "Canonicalization",
"Docs": "",
"Typewords": [
"Canonicalization"
]
},
{
"Name": "Headers",
"Docs": "",
"Typewords": [
"[]",
"string"
]
},
{
"Name": "HeadersEffective",
"Docs": "Used when signing. Based on Headers from config, or the reasonable default.",
"Typewords": [
"[]",
"string"
]
},
{
"Name": "DontSealHeaders",
"Docs": "",
"Typewords": [
"bool"
]
},
{
"Name": "Expiration",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "PrivateKeyFile",
"Docs": "",
"Typewords": [
"string"
]
}
]
},
{
"Name": "Canonicalization",
"Docs": "",
"Fields": [
{
"Name": "HeaderRelaxed",
"Docs": "",
"Typewords": [
"bool"
]
},
{
"Name": "BodyRelaxed",
"Docs": "",
"Typewords": [
"bool"
]
}
]
},
{
"Name": "DMARC",
"Docs": "",
"Fields": [
{
"Name": "Localpart",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "Domain",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "Account",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "Mailbox",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "ParsedLocalpart",
"Docs": "",
"Typewords": [
"Localpart"
]
},
{
"Name": "DNSDomain",
"Docs": "Effective domain, always set based on Domain field or Domain where this is configured.",
"Typewords": [
"Domain"
]
}
]
},
{
"Name": "MTASTS",
"Docs": "",
"Fields": [
{
"Name": "PolicyID",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "Mode",
"Docs": "",
"Typewords": [
"Mode"
]
},
{
"Name": "MaxAge",
"Docs": "",
"Typewords": [
"int64"
]
},
{
"Name": "MX",
"Docs": "",
"Typewords": [
"[]",
"string"
]
}
]
},
{
"Name": "TLSRPT",
"Docs": "",
"Fields": [
{
"Name": "Localpart",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "Domain",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "Account",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "Mailbox",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "ParsedLocalpart",
"Docs": "",
"Typewords": [
"Localpart"
]
},
{
"Name": "DNSDomain",
"Docs": "Effective domain, always set based on Domain field or Domain where this is configured.",
"Typewords": [
"Domain"
]
}
]
},
{
"Name": "Route",
"Docs": "",
"Fields": [
{
"Name": "FromDomain",
"Docs": "",
"Typewords": [
"[]",
"string"
]
},
{
"Name": "ToDomain",
"Docs": "",
"Typewords": [
"[]",
"string"
]
},
{
"Name": "MinimumAttempts",
"Docs": "",
"Typewords": [
"int32"
]
},
{
"Name": "Transport",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "FromDomainASCII",
"Docs": "",
"Typewords": [
"[]",
"string"
]
},
{
"Name": "ToDomainASCII",
"Docs": "",
"Typewords": [
"[]",
"string"
]
}
]
},
{
"Name": "Account",
"Docs": "",
@ -3201,58 +3650,6 @@
}
]
},
{
"Name": "Route",
"Docs": "",
"Fields": [
{
"Name": "FromDomain",
"Docs": "",
"Typewords": [
"[]",
"string"
]
},
{
"Name": "ToDomain",
"Docs": "",
"Typewords": [
"[]",
"string"
]
},
{
"Name": "MinimumAttempts",
"Docs": "",
"Typewords": [
"int32"
]
},
{
"Name": "Transport",
"Docs": "",
"Typewords": [
"string"
]
},
{
"Name": "FromDomainASCII",
"Docs": "",
"Typewords": [
"[]",
"string"
]
},
{
"Name": "ToDomainASCII",
"Docs": "",
"Typewords": [
"[]",
"string"
]
}
]
},
{
"Name": "PolicyRecord",
"Docs": "PolicyRecord is a cached policy or absence of a policy.",
@ -6153,6 +6550,68 @@
]
}
]
},
{
"Name": "Dynamic",
"Docs": "Dynamic is the parsed form of domains.conf, and is automatically reloaded when changed.",
"Fields": [
{
"Name": "Domains",
"Docs": "",
"Typewords": [
"{}",
"ConfigDomain"
]
},
{
"Name": "Accounts",
"Docs": "",
"Typewords": [
"{}",
"Account"
]
},
{
"Name": "WebDomainRedirects",
"Docs": "",
"Typewords": [
"{}",
"string"
]
},
{
"Name": "WebHandlers",
"Docs": "",
"Typewords": [
"[]",
"WebHandler"
]
},
{
"Name": "Routes",
"Docs": "",
"Typewords": [
"[]",
"Route"
]
},
{
"Name": "MonitorDNSBLs",
"Docs": "",
"Typewords": [
"[]",
"string"
]
},
{
"Name": "MonitorDNSBLZones",
"Docs": "",
"Typewords": [
"[]",
"Domain"
]
}
]
}
],
"Ints": [],
@ -6230,6 +6689,11 @@
}
]
},
{
"Name": "Localpart",
"Docs": "Localpart is a decoded local part of an email address, before the \"@\".\nFor quoted strings, values do not hold the double quote or escaping backslashes.\nAn empty string can be a valid localpart.\nLocalparts are in Unicode NFC.",
"Values": null
},
{
"Name": "PolicyType",
"Docs": "PolicyType indicates the policy success/failure results are for.",
@ -6534,11 +6998,6 @@
}
]
},
{
"Name": "Localpart",
"Docs": "Localpart is a decoded local part of an email address, before the \"@\".\nFor quoted strings, values do not hold the double quote or escaping backslashes.\nAn empty string can be a valid localpart.\nLocalparts are in Unicode NFC.",
"Values": null
},
{
"Name": "IP",
"Docs": "An IP is a single IP address, a slice of bytes.\nFunctions in this package accept either 4-byte (IPv4)\nor 16-byte (IPv6) slices as input.\n\nNote that in this documentation, referring to an\nIP address as an IPv4 address or an IPv6 address\nis a semantic property of the address, not just the\nlength of the byte slice: a 16-byte slice can still\nbe an IPv4 address.",