Giter Site home page Giter Site logo

pendulum-project / ntpd-rs Goto Github PK

View Code? Open in Web Editor NEW
492.0 492.0 35.0 7.75 MB

A full-featured implementation of the Network Time Protocol, including NTS support.

Home Page: https://tweedegolf.nl/en/pendulum

License: Other

Rust 98.70% Shell 1.30%

ntpd-rs's People

Contributors

0xcrust avatar arjentz avatar bdaehlie avatar cikzh avatar davidv1992 avatar dependabot[bot] avatar erikjee avatar folkertdev avatar jauderho avatar lisetroos avatar marlonbaeten avatar mikaelurankar avatar moderation avatar paulgear avatar rnijveld avatar ros-cr avatar sanmai-nl avatar squell avatar step-security-bot avatar sylvestre avatar tdittr avatar tshepang avatar valpackett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ntpd-rs's Issues

Implement clock adjustment system calls

Preferably without dependencies on non-core crates (prefer not to use nix, see also #14). If this requires some unsafe code then that would ideally be put in a separate crate.

Discussion: Failure mode upon detecting programming errors

There are currently a few, and probably in the future will be a few more, places where we can and do do checks that essentially represent invariants that should always hold, regardless of any input provided from external sources. As such, failure of these checks directly indicate bugs in our code, and the question then becomes what should the behaviour of these checks be in release builds.

Given the specific nature of NTP, especially for an NTP client, I personally am of the opinion that the safer option is to actively blow up upon detection of such errors. This is because, assuming we detected it early enough, the system time now is hopefully reasonably correct, and in that case without corrections shouldn't drift to the point in the short term, and at the same time blowing up makes the issue very visible to whomever is managing the server running the client. However, silently ignoring the error or trying to work around it could result in incorrect steering of the clock (since the software is now in a state that was never anticipated), and incorrect steering could potentially result in significant clock deviation from UTC fairly quickly, and furthermore is far less visible to whomever is managing the server running the client, increasing the potential for a faulty situation to last for a significant time interval.

Is this the view we want to take as project, or are there arguments to the contrary that I am forgetting about here.

Add support for pools

In NTP/Chrony there is support for pools:

A pool uses multiple DNS query results to the pool address to get additional peers to connect to. A single pool can instantiate multiple peers. This is different from a traditional server directive which only instantiates a single peer connection.

Peer reset mechanism

Ensure we can reset peer measurement state after clock stepping. Includes canceling/ignoring result of current poll if already started. Peer should confirm the occurence of the reset back to where it was initiated from.

NOTE: Polling state (how often we are allowed to poll and such) should be kept intact.

Chrony replacement

We are currently using chrony to synchronize with AWS clocks. Would this tool be able to replace chrony? If so how would that work, roughly?

Client for observing state and dynamically changing configuration

we have two unix sockets, by default

/run/ntpd-rs/log-level
/run/ntpd-rs/config

the log level is unprotected, the config needs additional permissions.


we can use https://docs.rs/tokio/latest/tokio/net/struct.UnixStream.html

for sending data over the socket, use https://docs.rs/postcard/latest/postcard/ ? (or send json as bytes?)


client --set-log-level=debug

client --step-if-bigger=1000 --step-first-updates=10

then we also need some observability features, some ideas

client peers list # lists all remotes we are connected to
client peers watch # show for each connected peer its `PeerStatus`

Better error handling for well known failure scenarios that require operator intervention

Some failure modes:

  • when the client can't start up because of permissions
  • when the client can't start because of configuration failure
  • When a sudden time jump is detected in the middle of normal operation

I think we may want to try and emit specific exit codes for these well known failure modes, so that they can be distinguished from other errors and panics. We also want to specifically make sure that we emit an error level log message before exiting the program to make sure that such a message pops up in a system that monitors the log messages.

Add JSON based log output

Add a command line option/config option that enables json based output instead of the current text based format.

Implement kernel-level software timestamping

We need some way to have software timestamping work with tokio in a proper way. Would prefer to have thin unsafe wrappers for the system calls in separate crates, prefer also to have few dependencies (this shouldn't be too much code, and it is probably better to own it ourselves than have a dependency on something like nix, libc is acceptable though in my view)

Cleanup NTP-proto

Current work has created a bit of a mess, we need to

  • choose better names
  • look at where code is still dead but needed in the future
  • re-evaluate the public/private-ness of fields/functions on types

Write a readme

Write a (short) readme explaining what this repo is and what the current state of it is.

Fix race condition that may occur when to reset-all-peer events happen in short succession

The following sequence of events is possible

  • Clock controller initiates peer reset
  • Peer A resets, controller handles
  • Peer B resets, controller handles
  • Peer C resets, does measurement, but controller is busy
  • Clock controller initiates second peer reset
  • Peer C reset handled by clock controller
  • Clock steering uses peer C state from just before second reset.

Which results in the steering code using incorrect state from peer C

Logging

Setup basics for logging and add some logging in relevant places.

Add SRV record peer discovery mechanism

One easy way to discover peer addresses would be by using SRV records in DNS. This would make the client a lot easier to use in many cloud-based environments.

Clock adjustment

Implement the state machine needed for actually doing clock adjustments. (good luck)

Configuration mechanism daemon

Implement a proper mechanism for configuring the daemon. E.g. whcih parameter values as needed by proto+which servers to connect to.

Fix peer poll interval never decreasing

Due to the logic used to determine peer polling intervals, they can never decrease. As this is unwanted, figure out better logic that does allow the polling interval to decrease.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.