diff --git a/precache_daemon.py b/precache_daemon.py index 4535fbf..ec0068c 100644 --- a/precache_daemon.py +++ b/precache_daemon.py @@ -175,19 +175,24 @@ def process_country(country, networks_count, force=False): if app_type.startswith('raw-'): format_type = app_type.split('-')[1] - + + if aggregate: + nets_out = ConfigGenerator._aggregate_networks(networks) + else: + nets_out = sorted(set(networks)) + if format_type == 'cidr_txt': - config_text = '\n'.join(networks) + config_text = '\n'.join(nets_out) elif format_type == 'newline_txt': - config_text = '\n'.join(networks) + config_text = '\n'.join(nets_out) elif format_type == 'json': config_text = json.dumps({ 'country': country, - 'networks': networks, - 'count': len(networks) + 'networks': nets_out, + 'count': len(nets_out) }, indent=2) elif format_type == 'csv': - config_text = 'network\n' + '\n'.join(networks) + config_text = 'network\n' + '\n'.join(nets_out) else: errors += 1 continue