Skip to content

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

Recover the IP pool

lotk111cd9d8f9dd
diff --git a/core/internal/service/multi_ip_domain/config_manager.go b/core/internal/service/multi_ip_domain/config_manager.go
index 863700b5..627f5978 100644
--- a/core/internal/service/multi_ip_domain/config_manager.go
+++ b/core/internal/service/multi_ip_domain/config_manager.go
@@ -420,10 +420,11 @@ func (m *ConfigManager) modifyPostfixNetworksText(lines []string, configs []map[
return lines, fmt.Errorf("postfix-billionmail networks section not found")
}
- // Add default billionmail-network configuration
- result = append(result, " billionmail-network:")
- result = append(result, " aliases:")
- result = append(result, " - postfix")
+ // Add default billionmail-network configuration with fixed IP
+ result = append(result, " billionmail-network:")
+ result = append(result, " aliases:")
+ result = append(result, " - postfix")
+ result = append(result, " ipv4_address: 172.66.1.100")
// Add custom network configurations
for _, cfg := range configs {
@@ -439,10 +440,10 @@ func (m *ConfigManager) modifyPostfixNetworksText(lines []string, configs []map[
continue
}
- result = append(result, fmt.Sprintf(" %s:", networkName))
- result = append(result, " aliases:")
- result = append(result, fmt.Sprintf(" - %s", aliases))
- result = append(result, fmt.Sprintf(" ipv4_address: %s", postfixIP))
+ result = append(result, fmt.Sprintf(" %s:", networkName))
+ result = append(result, " aliases:")
+ result = append(result, fmt.Sprintf(" - %s", aliases))
+ result = append(result, fmt.Sprintf(" ipv4_address: %s", postfixIP))
g.Log().Debugf(context.Background(), "Added postfix network: %s -> %s (%s)", networkName, postfixIP, aliases)
}
diff --git a/core/internal/service/multi_ip_domain/multi_ip_domain.go b/core/internal/service/multi_ip_domain/multi_ip_domain.go
index 28bf7fa4..38260b16 100644
--- a/core/internal/service/multi_ip_domain/multi_ip_domain.go
+++ b/core/internal/service/multi_ip_domain/multi_ip_domain.go
@@ -270,12 +270,16 @@ func (s *MultiIPDomainService) ApplyConfigs(ctx context.Context) (appliedConfigs
// Get IDs from allActiveConfigs
appliedIDs := make([]int, 0, len(allActiveConfigs))
+ toappliedIDs := make([]int, 0, len(allActiveConfigs))
for _, config := range allActiveConfigs {
appliedIDs = append(appliedIDs, gconv.Int(config["id"]))
+ if config["status"] != "applied" {
+ toappliedIDs = append(toappliedIDs, gconv.Int(config["id"]))
+ }
}
- // Update status of all pending configurations to 'applying'
- if err := s.updateStatusByIDs(ctx, appliedIDs, "applying"); err != nil {
+ // If the state is already "applied", then do not change it to "applying".
+ if err := s.updateStatusByIDs(ctx, toappliedIDs, "applying"); err != nil {
return nil, nil, nil, gerror.Wrap(err, "failed to update configuration status to 'applying'")
}