diff --git a/docker/routlin-dash/app/view_page.py b/docker/routlin-dash/app/view_page.py index 8731308..32f8268 100644 --- a/docker/routlin-dash/app/view_page.py +++ b/docker/routlin-dash/app/view_page.py @@ -526,40 +526,17 @@ def _read_cached_ip(): def _public_ip_info(ddns_cfg): """Return (ip_str, domains_sub, next_interval_str, last_obtained_str) for stat cards.""" - script = f'{CONFIGS_DIR}/ddns.py' - enabled_p = [p for p in ddns_cfg.get('providers', []) if p.get('enabled', True)] - all_hosts = [] + enabled_p = [p for p in ddns_cfg.get('providers', []) if p.get('enabled', True)] + all_hosts = [] for p in enabled_p: all_hosts.extend(p.get('hostnames', p.get('subdomains', []))) - domains_sub = ', '.join(all_hosts) - interval_secs = _parse_interval_to_seconds(ddns_cfg.get('general', {}).get('timer_interval', '')) - next_interval = '-' + domains_sub = ', '.join(all_hosts) - def _last_obtained(mtime): - return f'Obtained: {_relative_time(mtime)}' if mtime else '' - - # Path 1: timer healthy and within interval -> use cached IP - if interval_secs and enabled_p: - status = _run(f'python3 {script} --status 2>/dev/null') - if status: - is_enabled = '; enabled' in status - is_active = 'active (waiting)' in status or 'active (running)' in status - remaining = _parse_time_remaining(status) - if remaining is not None: - next_interval = _fmt_seconds(remaining) - if is_enabled and is_active and remaining is not None and remaining < interval_secs: - ip, mtime = _read_cached_ip() - if ip: - return ip, domains_sub, next_interval, _last_obtained(mtime) - - # Path 2: live fetch - ip = _run(f'python3 {script} --getip 2>/dev/null') - if ip and re.match(r'^\d{1,3}(\.\d{1,3}){3}$', ip): - _, mtime = _read_cached_ip() - return ip, domains_sub, next_interval, _last_obtained(mtime) - - # Path 3: offline - return 'DDNS Offline', domains_sub, next_interval, '' + ip, mtime = _read_cached_ip() + last_obtained = f'Obtained: {_relative_time(mtime)}' if mtime else '' + if ip: + return ip, domains_sub, '-', last_obtained + return 'Offline', domains_sub, '-', '' def _ddns_last_checked(): try: