Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- withNtpClient :: IOManager -> Tracer IO NtpTrace -> NtpSettings -> ( NtpClient -> IO a) -> IO a
-
data
NtpSettings
=
NtpSettings
{
- ntpServers :: [ String ]
- ntpRequiredNumberOfResults :: Int
- ntpResponseTimeout :: Microsecond
- ntpPollDelay :: Microsecond
- data NtpClient = NtpClient { }
-
data
NtpStatus
- = NtpDrift !NtpOffset
- | NtpSyncPending
- | NtpSyncUnavailable
- ntpQuery :: IOManager -> Tracer IO NtpTrace -> NtpSettings -> IO NtpStatus
-
data
NtpTrace
- = NtpTraceStartNtpClient
- | NtpTraceRestartDelay Int
- | NtpTraceRestartingClient
- | NtpTraceIOError IOError
- | NtpTraceLookupsFails
- | NtpTraceClientStartQuery
- | NtpTraceNoLocalAddr
- | NtpTraceResult NtpStatus
- | NtpTraceRunProtocolResults ( ResultOrFailure [NtpOffset])
- | NtpTracePacketSent SockAddr NtpPacket
- | NtpTracePacketSendError SockAddr IOException
- | NtpTracePacketDecodeError SockAddr String
- | NtpTracePacketReceived SockAddr NtpPacket
- | NtpTraceWaitingForRepliesTimeout IPVersion
- data IPVersion
-
data
ResultOrFailure
a
- = BothSucceeded !a
- | SuccessAndFailure !a ! IPVersion ! IOException
- | BothFailed ! IOException ! IOException
The API for starting an ntp client-thread.
withNtpClient :: IOManager -> Tracer IO NtpTrace -> NtpSettings -> ( NtpClient -> IO a) -> IO a Source #
data NtpSettings Source #
Settings of the ntp client.
NtpSettings | |
|
NtpClient
which recieves updates of the wall clcok drift every
ntpPollDelay
. It also allows to force engaging in ntp protocol.
NtpClient | |
|
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.
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
|
Low level interface
Running an
ntp
query
ntpQuery :: IOManager -> Tracer IO NtpTrace -> NtpSettings -> IO NtpStatus 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.
It may throw an
IOException
:
- if neither IPv4 nor IPv6 address is configured
- if network I/O errors
Logging interface
A tag which describes which version of the ip protocol was used.
data ResultOrFailure a Source #
Result of two threads running concurrently.
BothSucceeded !a |
both threads suceeded |
SuccessAndFailure !a ! IPVersion ! IOException |
one of the threads errors.
|
BothFailed ! IOException ! IOException |
both threads failed |