diff --git a/main.py b/main.py index 12a2c5c..7804652 100644 --- a/main.py +++ b/main.py @@ -18,6 +18,11 @@ def get_debian_dt(trace_file_url): time_str = response_text.split('\n')[0] return datetime.strptime(time_str, "%a %b %d %H:%M:%S UTC %Y") +def get_openbsd_sec(timestamp_file_url): + """Get OpenBSD seconds since the Epoch from timestamp file""" + sec_str = requests.get(timestamp_file_url).text + return int(sec_str) + if __name__ == "__main__": # Arch try: @@ -44,3 +49,13 @@ if __name__ == "__main__": print(OUTPUT.format("Debian")) except requests.exceptions.RequestException as err: print(ERROR.format("Debian", err)) + + # OpenBSD + try: + official_sec = get_openbsd_sec("https://ftp.openbsd.org/pub/OpenBSD/timestamp") + csc_sec = get_openbsd_sec(f"{CSC_MIRROR}OpenBSD/timestamp") + # Out-of-sync by 1 day maximum + OUTPUT = SUCCESS if official_sec < csc_sec + 86400 else FAILURE + print(OUTPUT.format("OpenBSD")) + except requests.exceptions.RequestException as err: + print(ERROR.format("OpenBSD", err))