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
repair invalid dkim signing config file.
Jacke31d616ab95e
diff --git a/core/internal/service/domains/domains.go b/core/internal/service/domains/domains.goindex d816820f..c195866a 100644--- a/core/internal/service/domains/domains.go+++ b/core/internal/service/domains/domains.go@@ -303,9 +303,6 @@ func GetDKIMRecord(domain string, validateImmediate bool) (record v1.DNSRecord,signContent = strings.Replace(signContent, "#BT_DOMAIN_DKIM_END", signConf+"\n#BT_DOMAIN_DKIM_END", 1)- // fix selector path error- signContent = strings.ReplaceAll(signContent, consts.RSPAMD_LIB_PATH, "/var/lib/rspamd")-_, err = public.WriteFile(signConfPath, signContent)if err != nil {@@ -551,3 +548,31 @@ func GetRecordsInCache(domain string) (records v1.DNSRecords) {return}++// RepairDKIMSigningConfig repairs the DKIM signing configuration file.+func RepairDKIMSigningConfig(ctx context.Context) error {+ // Read the DKIM signing configuration file+ signConfPath := public.AbsPath(filepath.Join(consts.RSPAMD_LOCAL_D_PATH, "dkim_signing.conf"))+ signContent, err := public.ReadFile(signConfPath)++ if err != nil {+ return fmt.Errorf("Failed to read DKIM signing config: %v", err)+ }++ // Check if the config contains the DKIM domain section+ if !strings.Contains(signContent, "#BT_DOMAIN_DKIM_BEGIN") || !strings.Contains(signContent, "#BT_DOMAIN_DKIM_END") {+ return fmt.Errorf("DKIM signing config is missing domain sections")+ }++ // fix the invalid selector private key path+ signContent = strings.ReplaceAll(signContent, consts.RSPAMD_LIB_PATH, "/var/lib/rspamd")++ // Write the repaired content back to the file+ _, err = public.WriteFile(signConfPath, signContent)++ if err != nil {+ return fmt.Errorf("Failed to write DKIM signing config: %v", err)+ }++ return nil+}diff --git a/core/internal/service/timers/timers.go b/core/internal/service/timers/timers.goindex 72377f16..6729b351 100644--- a/core/internal/service/timers/timers.go+++ b/core/internal/service/timers/timers.go@@ -17,6 +17,14 @@ func Start(ctx context.Context) (err error) {// Start DNS Records checking// Ensure the DNS records are fresh on startupgtimer.AddOnce(5*time.Second, func() {+ // repair DKIM signing config+ err = domains.RepairDKIMSigningConfig(ctx)++ if err != nil {+ g.Log().Warning(ctx, "RepairDKIMSigningConfig failed: ", err)+ err = nil+ }+domains.FreshRecords(ctx)})// Check DNS Records every 5 minutes