Add helpful clock drift message for timestamp auth errors

This commit is contained in:
Russell Ballestrini 2025-12-28 14:36:00 -05:00
parent a4f9bfa377
commit ae8f9ee8c8
8 changed files with 79 additions and 8 deletions

11
un.php
View file

@ -162,7 +162,16 @@ function api_request($endpoint, $method = 'GET', $data = null, $keys = null) {
curl_close($ch);
if ($http_code < 200 || $http_code >= 300) {
fwrite(STDERR, RED . "Error: HTTP $http_code - $response" . RESET . "\n");
if ($http_code === 401 && stripos($response, 'timestamp') !== false) {
fwrite(STDERR, RED . "Error: Request timestamp expired (must be within 5 minutes of server time)" . RESET . "\n");
fwrite(STDERR, YELLOW . "Your computer's clock may have drifted." . RESET . "\n");
fwrite(STDERR, YELLOW . "Check your system time and sync with NTP if needed:" . RESET . "\n");
fwrite(STDERR, " Linux: sudo ntpdate -s time.nist.gov\n");
fwrite(STDERR, " macOS: sudo sntp -sS time.apple.com\n");
fwrite(STDERR, " Windows: w32tm /resync\n");
} else {
fwrite(STDERR, RED . "Error: HTTP $http_code - $response" . RESET . "\n");
}
exit(1);
}