BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr
Update go-build.sh. Added SNI support.
Jackb0787fb68ff3
diff --git a/core/go-build.sh b/core/go-build.shindex a1da738a..d612c95d 100644--- a/core/go-build.sh+++ b/core/go-build.sh@@ -49,6 +49,8 @@ if [ ! -f "main.go" ]; thenexit 1fi+go mod tidy+if [[ "$PLATFORMS" == "all" || "$PLATFORMS" == "x86" ]]; then# amd64diff --git a/core/internal/cmd/cmd.go b/core/internal/cmd/cmd.goindex 8321fcfa..878dd680 100644--- a/core/internal/cmd/cmd.go+++ b/core/internal/cmd/cmd.go@@ -32,11 +32,11 @@ import ("billionmail-core/internal/service/rspamd""billionmail-core/internal/service/timers""context"+ "crypto/tls""fmt""net/http""net/http/httputil""net/url"- "path/filepath""strings""sync""time"@@ -369,7 +369,52 @@ var (public.SelfSignedCert().Generate()// Enable HTTPS- s.EnableHTTPS(public.AbsPath(filepath.Join(consts.SSL_PATH, "cert.pem")), public.AbsPath(filepath.Join(consts.SSL_PATH, "key.pem")))+ defaultCrtPair, _ := tls.LoadX509KeyPair(public.AbsPath(consts.SSL_PATH, "cert.pem"), public.AbsPath(consts.SSL_PATH, "key.pem"))+ crtMap := make(map[string]*tls.Certificate)+ crtMapMutex := sync.RWMutex{}+ s.EnableHTTPS(public.AbsPath(consts.SSL_PATH, "cert.pem"), public.AbsPath(consts.SSL_PATH, "key.pem"), &tls.Config{+ GetCertificate: func(info *tls.ClientHelloInfo) (*tls.Certificate, error) {+ domain := info.ServerName++ crtMapMutex.RLock()+ if crtPair, ok := crtMap[domain]; ok {+ crtMapMutex.RUnlock()+ return crtPair, nil+ }+ crtMapMutex.RUnlock()++ if exists, _ := g.DB().Model("domain").Where("a_record", public.FormatMX(domain)).Exist(); !exists {+ return &defaultCrtPair, nil+ }++ g.Log().Debug(ctx, "Get TLS certificate for domain", domain)++ crtMapMutex.Lock()+ defer crtMapMutex.Unlock()++ if crt, ok := crtMap[domain]; ok {+ return crt, nil+ }++ crtPath := public.AbsPath(consts.SSL_PATH, public.FormatMX(domain), "fullchain.pem")+ keyPath := public.AbsPath(consts.SSL_PATH, public.FormatMX(domain), "privkey.pem")++ if !public.FileExists(crtPath) || !public.FileExists(keyPath) {+ return &defaultCrtPair, nil+ }++ crtPair, err := tls.LoadX509KeyPair(crtPath, keyPath)++ if err != nil {+ g.Log().Warning(ctx, "Failed to load TLS certificate for domain", domain, err)+ return &defaultCrtPair, nil+ }++ crtMap[domain] = &crtPair++ return &crtPair, nil+ },+ })// attempt add http portif httpPort, err := public.DockerEnv("HTTP_PORT"); err == nil && httpPort != "" {