Skip to content

ntp — time ​

A built-in SNTP client: it periodically asks a server for the time and keeps a clock offset.

yaml
ntp:
  server: time.cloudflare.com:123
  interval: 30m
  dial:
    detour: direct

The presence of the section enables the client; there is no enabled field.

FieldMeaningDefault
serverhost or host:port of the NTP servertime.apple.com:123
intervalHow often to check30m
write_to_systemSet the system time (needs permissions)false
dialHow to connect to the server: the dial block, including detour

The server name is resolved by the built-in DNS, and the request goes through dial.detour if it is given. An unavailable server does not get in the way: errors are written to the log.

The offset is the time of the whole process, like ntp.TimeFuncFromContext in sing-box. TLS certificates are verified by it (the ordinary client and server, uTLS, downloads of lists and subscriptions), REALITY puts a timestamp into the ClientHello and checks it against max_time_difference, and Shadowsocks 2022 writes and checks the header timestamp. This way a router without a real-time clock, which lives in the past after a reboot, still trusts fresh certificates. Until the server's first answer, and without an ntp section, the system clock applies.

With write_to_system the offset is reset to zero after the system time is written: the system clock already accounts for it.

On reload a client with unchanged settings keeps running; the clock offset is kept. If the section is removed, the process returns to the system clock.

GPL-3.0-or-later