Archived
Publish placeholder DNS on registration
This commit is contained in:
1 parent
99c55405bc
commit
c0d82eaf26
4 files changed
+28
-16
No files matched your search
@@ -20,6 +20,7 @@ from ..settings import DdnsSettings
|
||||
from ..store import DdnsStore
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
INITIAL_PLACEHOLDER_IPV4 = "192.0.2.1"
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
@@ -79,14 +80,20 @@ class DdnsService:
|
||||
source_fallback = source_ip if _is_global_ip(source_ip) else ""
|
||||
supplied_ip = any(value and value.strip() for value in (myip, ipaddr, myipv6, ip6addr))
|
||||
if not supplied_ip and not source_fallback:
|
||||
return False
|
||||
ipv4, ipv6, update_ipv4, update_ipv6 = parse_update_ips(
|
||||
source_fallback,
|
||||
myip,
|
||||
ipaddr,
|
||||
myipv6,
|
||||
ip6addr,
|
||||
)
|
||||
ipv4 = INITIAL_PLACEHOLDER_IPV4
|
||||
ipv6 = None
|
||||
update_ipv4 = True
|
||||
update_ipv6 = False
|
||||
detail = "initial placeholder dns registered"
|
||||
else:
|
||||
ipv4, ipv6, update_ipv4, update_ipv6 = parse_update_ips(
|
||||
source_fallback,
|
||||
myip,
|
||||
ipaddr,
|
||||
myipv6,
|
||||
ip6addr,
|
||||
)
|
||||
detail = "initial dns registered"
|
||||
lock = self._lock_for(hostname)
|
||||
with lock:
|
||||
planned = self.store.preview_update(hostname, ipv4, ipv6, update_ipv4=update_ipv4, update_ipv6=update_ipv6)
|
||||
@@ -114,7 +121,7 @@ class DdnsService:
|
||||
self.store.log_update_event(hostname, ipv4, ipv6, DNS_FAILED, f"{type(exc).__name__}: {exc}", source_ip)
|
||||
raise
|
||||
result = self.store.commit_update_result(planned)
|
||||
self.store.log_update_event(hostname, result.ipv4, result.ipv6, UPDATED, "initial dns registered", source_ip)
|
||||
self.store.log_update_event(hostname, result.ipv4, result.ipv6, UPDATED, detail, source_ip)
|
||||
return True
|
||||
|
||||
def apply_update(
|
||||
|
||||
Reference in new issue
Block a user