haproxy map - revert
This commit is contained in:
@@ -1198,27 +1198,13 @@ class ConfigGenerator:
|
|||||||
config += "# " + "="*77 + "\n"
|
config += "# " + "="*77 + "\n"
|
||||||
config += "\n"
|
config += "\n"
|
||||||
|
|
||||||
# MAP BODY (aggregate per country to preserve country mapping)
|
# MAP BODY
|
||||||
for country, nets in sorted(country_networks.items()):
|
for network in all_networks:
|
||||||
if aggregate:
|
country = next((c for c, nets in country_networks.items() if network in nets), 'XX')
|
||||||
nets = ConfigGenerator._aggregate_networks(nets)
|
config += f"{network} {country}\n"
|
||||||
else:
|
|
||||||
nets = sorted(set(nets))
|
|
||||||
|
|
||||||
for network in nets:
|
return config
|
||||||
config += f"{network} {country}\n"
|
|
||||||
|
|
||||||
if redis_ips:
|
|
||||||
redis_list = list(redis_ips)
|
|
||||||
if aggregate:
|
|
||||||
redis_list = ConfigGenerator._aggregate_networks(redis_list)
|
|
||||||
else:
|
|
||||||
redis_list = sorted(set(redis_list))
|
|
||||||
|
|
||||||
for network in redis_list:
|
|
||||||
config += f"{network} REDIS\n"
|
|
||||||
|
|
||||||
return config
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_haproxy_lua(country_networks: dict, aggregate: bool = True, redis_ips: set = None) -> str:
|
def generate_haproxy_lua(country_networks: dict, aggregate: bool = True, redis_ips: set = None) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user