Documentation
¶
Index ¶
Constants ¶
View Source
const Subprotocol = "webntp.shogo82148.com"
Subprotocol is a subprotocol name for websocket.
Variables ¶
View Source
var DefaultDialer = &websocket.Dialer{ Proxy: http.ProxyFromEnvironment, Subprotocols: []string{Subprotocol}, }
DefaultDialer is a dialer for webntp.
Functions ¶
This section is empty.
Types ¶
type LeapSecond ¶
type LeapSecond struct {
// At is the time to insert/delete a leap second.
At time.Time
// Leap is offset from TAI to UTC. (**after** LeapSecond.Time)
Leap int
// Step describes next leap second is insertion or deletion.
// +1 is insertion, -1 is deletion.
Step int
}
LeapSecond is information for leap-seconds
type LeapSecondsList ¶
type LeapSecondsList struct {
LeapSeconds []LeapSecond
UpdateAt time.Time
ExpireAt time.Time
}
LeapSecondsList is the contents of leap-second.list.
func ParseLeapSecondsList ¶
func ParseLeapSecondsList(r io.Reader) (*LeapSecondsList, error)
ParseLeapSecondsList parses leap-second.list.
type Response ¶
type Response struct {
// ID is the id of the web-ntp server.
ID string `json:"id"`
// InitiateTime is the time that the request has been sent.
InitiateTime Timestamp `json:"it"`
// SendTime is the time that the response has been sent.
SendTime Timestamp `json:"st"`
// Time is a same as SendTime.
// It is for htptime compatibility.
Time Timestamp `json:"time"`
// Leap is from TAI to UTC. (**before** Response.Next)
Leap int `json:"leap"`
// Next is the time of next or last leap second event.
Next Timestamp `json:"next"`
// Step describes next or last leap second is insertion or deletion.
// +1 is insertion, -1 is deletion.
Step int `json:"step"`
}
Response is a response from webntp server.
type Result ¶
type Result struct {
Offset time.Duration
Delay time.Duration
NextLeap time.Time
TAIOffset time.Duration
Step int
}
Result is the result of synchronization.
type Server ¶
type Server struct {
Upgrader *websocket.Upgrader
// path for leap-seconds.list cache
LeapSecondsPath string
// url for leap-seconds.list
LeapSecondsURL string
// contains filtered or unexported fields
}
Server is a webntp server.
type Timestamp ¶
Timestamp is posix unix timestamp.
func (Timestamp) MarshalJSON ¶
MarshalJSON converts the timestamp to JSON number. The number is unix timestamp.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON converts JSON number to a timestamp. The number is unix timestamp.
Click to show internal directories.
Click to hide internal directories.