@@ -1535,6 +1535,7 @@ detect_ipv4() {
15351535
15361536run_http_date() {
15371537 local now difftime
1538+ local spaces=" "
15381539
15391540 if [[ ! -s $HEADERFILE ]]; then
15401541 run_http_header "$1" || return 3 # this is just for the line "Testing HTTP header response"
@@ -1544,14 +1545,21 @@ run_http_date() {
15441545 out "not tested as we're not targeting HTTP"
15451546 else
15461547 if [[ -n "$HTTP_TIME" ]]; then
1547- HTTP_TIME=$(parse_date "$HTTP_TIME" "+%s" "%a, %d %b %Y %T %Z" 2>>$ERRFILE) # the trailing \r confuses BSD flavors otherwise
1548-
1549- difftime=$((HTTP_TIME - NOW_TIME))
1550- [[ $difftime != "-"* ]] && [[ $difftime != "0" ]] && difftime="+$difftime"
1551- # process was killed, so we need to add an error:
1552- [[ $HAD_SLEPT -ne 0 ]] && difftime="$difftime (± 1.5)"
1553- out "$difftime sec from localtime";
1554- fileout "http_clock_skew" "INFO" "HTTP clock skew $difftime sec from localtime"
1548+ HTTP_TIME="$(strip_lf "$HTTP_TIME")"
1549+ if "$HAS_OPENBSDDATE"; then
1550+ # we can't normalize the date under OpenBSD thus no substraction is possible
1551+ outln "remote: $HTTP_TIME"
1552+ out "${spaces}local: $(date)"
1553+ fileout "$jsonID" "INFO" "$HTTP_TIME - $(date)"
1554+ else
1555+ HTTP_TIME=$(parse_date "$HTTP_TIME" "+%s" "%a, %d %b %Y %T %Z" 2>>$ERRFILE)
1556+ difftime=$((HTTP_TIME - NOW_TIME))
1557+ [[ $difftime != "-"* ]] && [[ $difftime != "0" ]] && difftime="+$difftime"
1558+ # process was killed, so we need to add an error:
1559+ [[ $HAD_SLEPT -ne 0 ]] && difftime="$difftime (± 1.5)"
1560+ out "$difftime sec from localtime";
1561+ fileout "http_clock_skew" "INFO" "HTTP clock skew $difftime sec from localtime"
1562+ fi
15551563 else
15561564 out "Got no HTTP time, maybe try different URL?";
15571565 fileout "http_clock_skew" "INFO" "HTTP clock skew not measured. Got no HTTP time, maybe try different URL?"
0 commit comments