Files
labca/expiration-mailer_main.patch
2020-04-13 20:02:50 +02:00

84 lines
2.4 KiB
Diff

diff --git a/cmd/expiration-mailer/main.go b/cmd/expiration-mailer/main.go
index 6d31a7033..c2ad80495 100644
--- a/cmd/expiration-mailer/main.go
+++ b/cmd/expiration-mailer/main.go
@@ -19,6 +19,7 @@ import (
"github.com/jmhodges/clock"
+ "github.com/letsencrypt/boulder/bdns"
"github.com/letsencrypt/boulder/cmd"
"github.com/letsencrypt/boulder/core"
"github.com/letsencrypt/boulder/db"
@@ -34,7 +35,7 @@ import (
const (
defaultNagCheckInterval = 24 * time.Hour
- defaultExpirationSubject = "Let's Encrypt certificate expiration notice for domain {{.ExpirationSubject}}"
+ defaultExpirationSubject = "LabCA certificate expiration notice for domain {{.ExpirationSubject}}"
)
type regStore interface {
@@ -383,6 +384,9 @@ type config struct {
TLS cmd.TLSConfig
SAService *cmd.GRPCClientConfig
+ DNSTries int
+ DNSResolvers []string
+
// Path to a file containing a list of trusted root certificates for use
// during the SMTP connection (as opposed to the gRPC connections).
SMTPTrustedRootFile string
@@ -391,6 +395,12 @@ type config struct {
}
Syslog cmd.SyslogConfig
+
+ Common struct {
+ DNSResolver string
+ DNSTimeout string
+ DNSAllowLoopbackAddresses bool
+ }
}
func initStats(stats prometheus.Registerer) mailerStats {
@@ -494,6 +504,30 @@ func main() {
cmd.FailOnError(err, "Failed to load credentials and create gRPC connection to SA")
sac := bgrpc.NewStorageAuthorityClient(sapb.NewStorageAuthorityClient(conn))
+ dnsTimeout, err := time.ParseDuration(c.Common.DNSTimeout)
+ cmd.FailOnError(err, "Couldn't parse DNS timeout")
+ dnsTries := c.Mailer.DNSTries
+ if dnsTries < 1 {
+ dnsTries = 1
+ }
+ var resolver bdns.DNSClient
+ if len(c.Common.DNSResolver) != 0 {
+ c.Mailer.DNSResolvers = append(c.Mailer.DNSResolvers, c.Common.DNSResolver)
+ }
+ if !c.Common.DNSAllowLoopbackAddresses {
+ r := bdns.NewDNSClientImpl(
+ dnsTimeout,
+ c.Mailer.DNSResolvers,
+ scope,
+ clk,
+ dnsTries,
+ logger)
+ resolver = r
+ } else {
+ r := bdns.NewTestDNSClientImpl(dnsTimeout, c.Mailer.DNSResolvers, scope, clk, dnsTries, logger)
+ resolver = r
+ }
+
var smtpRoots *x509.CertPool
if c.Mailer.SMTPTrustedRootFile != "" {
pem, err := ioutil.ReadFile(c.Mailer.SMTPTrustedRootFile)
@@ -529,6 +563,7 @@ func main() {
c.Mailer.Username,
smtpPassword,
smtpRoots,
+ resolver,
*fromAddress,
logger,
scope,