Development

This commit is contained in:
Matthew Grotke 2026-05-23 02:01:37 -04:00
parent 5cd469f898
commit 2d28b4b752
8 changed files with 414 additions and 351 deletions

View file

@ -207,6 +207,26 @@ def _fmt_timestamp(ts):
except Exception:
return '-'
def _relative_time(ts):
try:
diff = int(datetime.now(tz=timezone.utc).timestamp()) - int(ts)
if diff < 60:
n = max(0, diff)
return f'{n} second{"s" if n != 1 else ""} ago'
m = diff // 60
if m < 60:
return f'{m} minute{"s" if m != 1 else ""} ago'
h = m // 60
if h < 24:
return f'{h} hour{"s" if h != 1 else ""} ago'
d = h // 24
if d < 365:
return f'{d} day{"s" if d != 1 else ""} ago'
y = d // 365
return f'{y} year{"s" if y != 1 else ""} ago'
except Exception:
return ''
def _live_vpn_sessions():
rows = []
out = _run('wg show all dump 2>/dev/null')
@ -408,8 +428,9 @@ def _blocklist_stats_html(core):
try:
with open(bl_path) as f:
entries = sum(1 for _ in f)
mtime = int(os.path.getmtime(bl_path))
size_str = _fmt_bytes(os.path.getsize(bl_path))
last_refreshed = _fmt_timestamp(int(os.path.getmtime(bl_path)))
last_refreshed = f'{_fmt_timestamp(mtime)} ({_relative_time(mtime)})'
except Exception:
entries, size_str, last_refreshed = '-', '-', 'Never'
rows += (f'<tr>'