Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make NTP server configurable #16

Open
peter-mount opened this issue Nov 2, 2022 · 2 comments
Open

Make NTP server configurable #16

peter-mount opened this issue Nov 2, 2022 · 2 comments

Comments

@peter-mount
Copy link

Currently NTP is hardcoded to pool.ntp.org which means that whenever the clock needs to be resynced it involves accessing a service outside of the local network.

For instances where either the internet is not always accessible, or firewalled, some environments have their own ntp servers. Others might use a different ntp pool.

So a means of enabling an alternate ntp server other than the hardcoded one would be useful.

@GeoffMurray
Copy link

GeoffMurray commented Dec 4, 2022

I changed the definition line in npt.py to:

def fetch(synch_with_rtc=True, timeout=10, ntp_host="pool.ntp.org"):
#   ntp_host = "pool.ntp.org"

And then called it like this:

timestamp = ntp.fetch(True, 10, "ntp-b.nist.gov")

Seems to work.

@jimkoke
Copy link

jimkoke commented Feb 28, 2024

 DEFAULT_NTP_HOST = "pool.ntp.org"
 def fetchFromPool(synch_with_rtc=True, timeout=10, tzinfo=0,
            pool = (DEFAULT_NTP_HOST,)):
   for ntp_host in pool:
      ts = fetch(synch_with_rtc=synch_with_rtc, timeout=timeout,
              tzinfo=tzinfo, ntp_host=ntp_host)
      if ts is not None:
         return ts
   return None
 ...
 ts = fetchFromPool(True, 10, ( "ntp-b.hist.gov", DEFAULT_NTP_HOST ) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants