fix serving mta-sts policy files

i broke it 3 days ago when adding support for serving it through external reverse proxy.

report by mteege, thanks!
This commit is contained in:
Mechiel Lukkien 2023-02-28 20:40:52 +01:00
parent c9190337e6
commit 994b5b9a0a
No known key found for this signature in database

View file

@ -15,14 +15,16 @@ import (
func mtastsPolicyHandle(w http.ResponseWriter, r *http.Request) {
log := xlog.WithCid(mox.Cid())
if !strings.HasPrefix(r.Host, "mta-sts.") {
host := strings.ToLower(r.Host)
if !strings.HasPrefix(host, "mta-sts.") {
http.NotFound(w, r)
return
}
host, _, err := net.SplitHostPort(strings.TrimPrefix(r.Host, "mta-sts."))
if err != nil {
http.NotFound(w, r)
return
host = strings.TrimPrefix(host, "mta-sts.")
nhost, _, err := net.SplitHostPort(host)
if err == nil {
// Only relevant for when host has a port.
host = nhost
}
domain, err := dns.ParseDomain(host)
if err != nil {