ntp-client-0.0.1.4: NTP client
Safe HaskellSafe-Inferred
LanguageHaskell2010

Network.NTP.Client.Query

Contents

Synopsis

Documentation

data NtpSettings Source #

Settings of the ntp client.

Constructors

NtpSettings 

Fields

  • ntpServers ∷ [String]

    List of server addresses. At least three servers are needed.

  • ntpRequiredNumberOfResultsInt

    Minimum number of results to compute the offset, this should be less or equal to the length of ntpServers (we send a single tnp packet / query to a each server, if the dns name resolves to many addresses we pick the first one).

  • ntpResponseTimeoutMicrosecond

    Timeout for receiving a response from an ntp server.

  • ntpPollDelayMicrosecond

    How long to wait between two rounds of requests. This should be set to something of an order of one hour, ntp servers should not be abused.

data NtpStatus Source #

The Ntp client state: either cached results is availbale, or the ntp client is engaged in ntp-protocol or there was a failure: e.g. connection lost, or dns lookups did not return at least ntpRequiredNumberOfResults addresses.

Constructors

NtpDrift !NtpOffset

The difference between NTP time and local system time

NtpSyncPending

NTP client has send requests to the servers

NtpSyncUnavailable

NTP is not available: the client has not received any respond within ntpResponseTimeout from at least ntpRequiredNumberOfResults servers.

Instances

Instances details
Show NtpStatus Source # 
Instance details

Defined in Network.NTP.Client.Query

Methods

showsPrecIntNtpStatusShowS #

showNtpStatusString #

showList ∷ [NtpStatus] → ShowS #

Eq NtpStatus Source # 
Instance details

Defined in Network.NTP.Client.Query

Methods

(==)NtpStatusNtpStatusBool #

(/=)NtpStatusNtpStatusBool #

data CompletedNtpStatus Source #

A version of NtpStatus specialized to the two "completed" states of that type: NtpDrift and NtpSyncUnavailable.

Constructors

CNtpDrift !NtpOffset

Corresponds to NtpDrift

CNtpSyncUnavailable

Corresponds to NtpSyncUnavailable

ntpQueryIOManagerTracer IO NtpTraceNtpSettingsIO CompletedNtpStatus Source #

Perform a series of NTP queries: one for each dns name. Resolve each dns name, get local addresses: both IPv4 and IPv6 and engage in ntp protocol towards one ip address per address family per dns name, but only for address families for which we have a local address. This is to avoid trying to send IPv4/6 requests if IPv4/6 gateway is not configured.

We produce a CompletedNtpStatus rather than an NtpStatus because we would never construct an NtpStatus using NtpSyncPending, so callers can avoid catching and killing that case.

It may throw an IOException:

  • if neither IPv4 nor IPv6 address is configured
  • if network I/O errors

Logging

data IPVersion Source #

A tag which describes which version of the ip protocol was used.

Constructors

IPv4 
IPv6 

Instances

Instances details
Show IPVersion Source # 
Instance details

Defined in Network.NTP.Client.Query

Methods

showsPrecIntIPVersionShowS #

showIPVersionString #

showList ∷ [IPVersion] → ShowS #

Eq IPVersion Source # 
Instance details

Defined in Network.NTP.Client.Query

Methods

(==)IPVersionIPVersionBool #

(/=)IPVersionIPVersionBool #

data ResultOrFailure a Source #

Result of two threads running concurrently.

Constructors

BothSucceeded !a

both threads suceeded

SuccessAndFailure !a !IPVersion !IOException

one of the threads errors. IPVersion indicates which one.

BothFailed !IOException !IOException

both threads failed

Instances

Instances details
Foldable ResultOrFailure Source # 
Instance details

Defined in Network.NTP.Client.Query

Methods

foldMonoid m ⇒ ResultOrFailure m → m #

foldMapMonoid m ⇒ (a → m) → ResultOrFailure a → m #

foldMap'Monoid m ⇒ (a → m) → ResultOrFailure a → m #

foldr ∷ (a → b → b) → b → ResultOrFailure a → b #

foldr' ∷ (a → b → b) → b → ResultOrFailure a → b #

foldl ∷ (b → a → b) → b → ResultOrFailure a → b #

foldl' ∷ (b → a → b) → b → ResultOrFailure a → b #

foldr1 ∷ (a → a → a) → ResultOrFailure a → a #

foldl1 ∷ (a → a → a) → ResultOrFailure a → a #

toListResultOrFailure a → [a] #

nullResultOrFailure a → Bool #

lengthResultOrFailure a → Int #

elemEq a ⇒ a → ResultOrFailure a → Bool #

maximumOrd a ⇒ ResultOrFailure a → a #

minimumOrd a ⇒ ResultOrFailure a → a #

sumNum a ⇒ ResultOrFailure a → a #

productNum a ⇒ ResultOrFailure a → a #

Show a ⇒ Show (ResultOrFailure a) Source # 
Instance details

Defined in Network.NTP.Client.Query

Eq a ⇒ Eq (ResultOrFailure a) Source # 
Instance details

Defined in Network.NTP.Client.Query