mirror of
https://github.com/mjl-/mox.git
synced 2024-12-27 08:53:48 +03:00
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:
parent
c9190337e6
commit
994b5b9a0a
1 changed files with 7 additions and 5 deletions
|
@ -15,14 +15,16 @@ import (
|
||||||
func mtastsPolicyHandle(w http.ResponseWriter, r *http.Request) {
|
func mtastsPolicyHandle(w http.ResponseWriter, r *http.Request) {
|
||||||
log := xlog.WithCid(mox.Cid())
|
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)
|
http.NotFound(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
host, _, err := net.SplitHostPort(strings.TrimPrefix(r.Host, "mta-sts."))
|
host = strings.TrimPrefix(host, "mta-sts.")
|
||||||
if err != nil {
|
nhost, _, err := net.SplitHostPort(host)
|
||||||
http.NotFound(w, r)
|
if err == nil {
|
||||||
return
|
// Only relevant for when host has a port.
|
||||||
|
host = nhost
|
||||||
}
|
}
|
||||||
domain, err := dns.ParseDomain(host)
|
domain, err := dns.ParseDomain(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue