Router: Time initialization fixes and cleanups

Most changes are relevant only if NTP is disabled or failed at startup.

- Require two peers that agree for transports to initialize time
- Briefly ban skewed peer when not initialized, so another peer will be the second sample
- Allow SSU2 to initialize time even for large skews
- Do not allow NTCP2 inbound to initialize time for large skews
- Disable SSU1 time initialization when SSU2 is enabled
- When SSU2 is disabled, allow SSU1 time initialization even for large skews
- Don't adjust to large inbound NTCP2 skews when not initialized
- Round time sent in NTCP2 DateTime block
- Adjust SSU2 skew for RTT
- Don't sort by absolute skew on SSU /peers tab so we can find median
- Only call System.currentTimeMillis() once in RouterClock.setOffset()
- Log tweaks
This commit is contained in:
zzz
2022-12-19 06:45:30 -05:00
parent 51d567ecb4
commit 6092e35b65
9 changed files with 87 additions and 37 deletions

View File

@@ -155,7 +155,7 @@ class UDPSorters {
static class SkewComparator extends PeerComparator {
@Override
public int compare(PeerState l, PeerState r) {
long rv = Math.abs(l.getClockSkew()) - Math.abs(r.getClockSkew());
long rv = l.getClockSkew() - r.getClockSkew();
if (rv == 0) // fallback on alpha
return super.compare(l, r);
else