probe-cli icon indicating copy to clipboard operation
probe-cli copied to clipboard

feat: honor check-in UTC time

Open bassosimone opened this issue 1 year ago • 0 comments

This diff honors the check-in API time. We create a new package that stores the check-in API time. Because time.Time structs read from JSON do not contain a monotonic clock reading, we store a time.Time containing a monotonic clock reading as well. These two times will always have a bit of offset between them, but such as offset is smaller than the offset between the check-in API time and the probe clock when the probe clock is severely misconfigured.

We keep these times in memory. If a probe has not observed a check-in API response or the check-in API contained an empty time, we do not consider the check-in clock to be valid and so the package is basically disabled.

Otherwise, we have an API based time reference. We use this reference to:

  1. include into measurements the check-in-API based clock reading of when we created a measurement, which allows the OONI backend to determine how safe it is to keep or discard the measurement;

  2. warn the user if the offset is +- a few minutes.

See https://github.com/ooni/probe/issues/1781

bassosimone avatar Mar 21 '23 10:03 bassosimone