fix ntfy not syncing with skip_ipvX
Build and Push Container / build-and-push (push) Successful in 42s
Build and Push Container / build-and-push (push) Successful in 42s
This commit is contained in:
@@ -136,8 +136,10 @@ def _update_route53_records(
|
||||
records: list[Route53RecordType],
|
||||
public_ipv4: str | None,
|
||||
public_ipv6: str | None,
|
||||
) -> None:
|
||||
) -> tuple[set[str], set[str]]:
|
||||
logger.info("Processing %d Route53 record(s)", len(records))
|
||||
updated_ipv4: set[str] = set()
|
||||
updated_ipv6: set[str] = set()
|
||||
|
||||
for record in records:
|
||||
logger.info(
|
||||
@@ -157,6 +159,7 @@ def _update_route53_records(
|
||||
record=record["record"],
|
||||
public_ipv4=public_ipv4,
|
||||
)
|
||||
updated_ipv4.add(record["record"])
|
||||
|
||||
if record.get("skip_ipv6"):
|
||||
logger.info("Skipping IPv6 for %s (skip_ipv6=true)", record["record"])
|
||||
@@ -169,21 +172,33 @@ def _update_route53_records(
|
||||
record=record["record"],
|
||||
public_ipv6=public_ipv6,
|
||||
)
|
||||
updated_ipv6.add(record["record"])
|
||||
|
||||
logger.info("=== Done processing Route53 record: %s ===", record["record"])
|
||||
|
||||
return updated_ipv4, updated_ipv6
|
||||
|
||||
|
||||
def _update_unifi_records(
|
||||
unifi_config: UnifiConfig,
|
||||
public_ipv4: str | None,
|
||||
public_ipv6: str | None,
|
||||
) -> None:
|
||||
) -> tuple[set[str], set[str]]:
|
||||
logger.info("Processing %d UniFi record(s)", len(unifi_config["records"]))
|
||||
updated_ipv4: set[str] = set()
|
||||
updated_ipv6: set[str] = set()
|
||||
for record in unifi_config["records"]:
|
||||
domain = record["record"]
|
||||
if public_ipv4 and not record.get("skip_ipv4"):
|
||||
updated_ipv4.add(domain)
|
||||
if public_ipv6 and not record.get("skip_ipv6"):
|
||||
updated_ipv6.add(domain)
|
||||
unifi_update_records(
|
||||
unifi_config=unifi_config,
|
||||
ipv4=public_ipv4,
|
||||
ipv6=public_ipv6,
|
||||
)
|
||||
return updated_ipv4, updated_ipv6
|
||||
|
||||
|
||||
def main() -> None:
|
||||
@@ -248,6 +263,10 @@ def main() -> None:
|
||||
|
||||
route53_success = True
|
||||
unifi_success = True
|
||||
route53_updated_ipv4: set[str] = set()
|
||||
route53_updated_ipv6: set[str] = set()
|
||||
unifi_updated_ipv4: set[str] = set()
|
||||
unifi_updated_ipv6: set[str] = set()
|
||||
|
||||
if route53_records:
|
||||
if not ROUTE53_HOSTED_ZONE_ID:
|
||||
@@ -256,7 +275,7 @@ def main() -> None:
|
||||
else:
|
||||
logger.info("=== Starting Route53 updates (hosted_zone_id=%s) ===", ROUTE53_HOSTED_ZONE_ID)
|
||||
try:
|
||||
_update_route53_records(route53_records, public_ipv4, public_ipv6)
|
||||
route53_updated_ipv4, route53_updated_ipv6 = _update_route53_records(route53_records, public_ipv4, public_ipv6)
|
||||
logger.info("=== Finished Route53 updates ===")
|
||||
except Exception as e:
|
||||
logger.error("Route53 updates failed: %s", e)
|
||||
@@ -277,7 +296,7 @@ def main() -> None:
|
||||
"records": unifi_records, # type: ignore[arg-type]
|
||||
}
|
||||
|
||||
_update_unifi_records(unifi_config, public_ipv4, public_ipv6)
|
||||
unifi_updated_ipv4, unifi_updated_ipv6 = _update_unifi_records(unifi_config, public_ipv4, public_ipv6)
|
||||
logger.info("=== Finished UniFi updates ===")
|
||||
except Exception as e:
|
||||
logger.error("UniFi updates failed: %s", e)
|
||||
@@ -289,19 +308,23 @@ def main() -> None:
|
||||
route53_lines = []
|
||||
if public_ipv4:
|
||||
for domain in route53_domains:
|
||||
route53_lines.append(f"{domain} (A): {public_ipv4}")
|
||||
if domain in route53_updated_ipv4:
|
||||
route53_lines.append(f"{domain} (A): {public_ipv4}")
|
||||
if public_ipv6:
|
||||
for domain in route53_domains:
|
||||
route53_lines.append(f"{domain} (AAAA): {public_ipv6}")
|
||||
if domain in route53_updated_ipv6:
|
||||
route53_lines.append(f"{domain} (AAAA): {public_ipv6}")
|
||||
route53_text = "\n".join(route53_lines) if route53_lines else "No IPs available"
|
||||
|
||||
unifi_lines = []
|
||||
if public_ipv4:
|
||||
for domain in unifi_domains:
|
||||
unifi_lines.append(f"{domain} (A): {public_ipv4}")
|
||||
if domain in unifi_updated_ipv4:
|
||||
unifi_lines.append(f"{domain} (A): {public_ipv4}")
|
||||
if public_ipv6:
|
||||
for domain in unifi_domains:
|
||||
unifi_lines.append(f"{domain} (AAAA): {public_ipv6}")
|
||||
if domain in unifi_updated_ipv6:
|
||||
unifi_lines.append(f"{domain} (AAAA): {public_ipv6}")
|
||||
unifi_text = "\n".join(unifi_lines) if unifi_lines else "No IPs available"
|
||||
|
||||
if route53_records:
|
||||
|
||||
Reference in New Issue
Block a user