2021-12-05 13:45:17 +00:00
|
|
|
package server
|
2021-11-20 14:30:58 +00:00
|
|
|
|
2021-12-01 21:49:48 +00:00
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
)
|
2021-11-20 14:30:58 +00:00
|
|
|
|
|
|
|
// GetHSTSHeader returns a HSTS header with includeSubdomains & preload for MainDomainSuffix and RawDomain, or an empty
|
|
|
|
// string for custom domains.
|
2021-12-05 13:45:17 +00:00
|
|
|
func GetHSTSHeader(host, mainDomainSuffix, rawDomain []byte) string {
|
|
|
|
if bytes.HasSuffix(host, mainDomainSuffix) || bytes.Equal(host, rawDomain) {
|
2021-11-20 14:30:58 +00:00
|
|
|
return "max-age=63072000; includeSubdomains; preload"
|
|
|
|
} else {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|