From 5eee2de25bdf2e46460cfa258363399e29e939e0 Mon Sep 17 00:00:00 2001 From: Marc Hoersken Date: Fri, 21 Dec 2018 19:59:54 +0100 Subject: [PATCH] Replace Secure mode with UseSMTPS and AllowInsecureAuth options --- README.md | 2 +- config.go | 22 ++++++++++++---------- main.go | 2 +- server.go | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index c8a9707..cc3866d 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,8 @@ The following YAML file is an example configuration with one virtual host: ``` Address: "localhost:25" Domain: "localhost" -Secure: true LetsEncrypt: + Agreed: true Contact: your-name@your-domain.tld Challenge: http ChallengePort: 80 diff --git a/config.go b/config.go index 9c7ffca..f83c5b8 100644 --- a/config.go +++ b/config.go @@ -47,25 +47,27 @@ type configVHost struct { } type config struct { - Address string - Domain string - Secure bool - LetsEncrypt *configAcmeLe - MaxIdleSeconds int - MaxMessageBytes int - MaxRecipients int - VirtualHosts []*configVHost - HeaderKeys []string + Address string + Domain string + UseSMTPS bool + LetsEncrypt *configAcmeLe + MaxIdleSeconds int + MaxMessageBytes int + MaxRecipients int + AllowInsecureAuth bool + VirtualHosts []*configVHost + HeaderKeys []string } func loadConfig() (*config, error) { vpr := viper.GetViper() - vpr.SetDefault("Secure", false) + vpr.SetDefault("UseSMTPS", false) vpr.SetDefault("LetsEncrypt.Agreed", false) vpr.SetDefault("LetsEncrypt.Challenge", "http") vpr.SetDefault("MaxIdleSeconds", 300) vpr.SetDefault("MaxMessageBytes", 10240000) vpr.SetDefault("MaxRecipients", 50) + vpr.SetDefault("AllowInsecureAuth", false) vpr.SetDefault("HeaderKeys", defaultHeaderKeys) vpr.SetConfigName("smtp-dkim-signer") vpr.AddConfigPath("/etc/smtp-dkim-signer/") diff --git a/main.go b/main.go index ab096c5..3df5664 100644 --- a/main.go +++ b/main.go @@ -50,7 +50,7 @@ func setupServer() (*smtp.Server, bool) { log.Fatal(err) } } - return server, cfg.Secure + return server, cfg.UseSMTPS } func main() { diff --git a/server.go b/server.go index ec4b464..d756bc9 100644 --- a/server.go +++ b/server.go @@ -34,7 +34,7 @@ func makeServer(cfg *config, be *backend) *smtp.Server { s.MaxIdleSeconds = cfg.MaxIdleSeconds s.MaxMessageBytes = cfg.MaxMessageBytes s.MaxRecipients = cfg.MaxRecipients - s.AllowInsecureAuth = !cfg.Secure + s.AllowInsecureAuth = cfg.AllowInsecureAuth return s }