ohrad

package module
v0.0.0-...-2e1f6b8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2017 License: MIT Imports: 10 Imported by: 0

README

ohrad

ohrad is a prototype for a NTP server that is highly influenced by OpenNTPD.

Documentation

Index

Constants

View Source
const (
	NtpMsgSize     int = 48 // no auth
	Jan1970            = 2208988800
	NanosPerSecond     = 1000 * 1000 * 1000
)
View Source
const (
	VersionMask = 7 << 3
	ModeMask    = 7 << 0
	ModeServer  = 4
	ModeClient  = 3
	ModeSymAct  = 1 // Symmetric active
	ModeSymPas  = 2 // Symmetric passive
)

Variables

View Source
var Log = new(Logger)

Functions

func HandleSignals

func HandleSignals(cleanup func() error)

func SendNtpMsg

func SendNtpMsg(conn *net.UDPConn, clientAddr *net.UDPAddr, msg *NtpMsg)

Types

type ErrorTimeout

type ErrorTimeout struct {
	// contains filtered or unexported fields
}

func (*ErrorTimeout) Error

func (e *ErrorTimeout) Error() string

type Logger

type Logger struct {
	*syslog.Writer
}

func (*Logger) NtpMsg

func (w *Logger) NtpMsg(msg *NtpMsg)

type NtpLong

type NtpLong struct {
	IntParl   uint32
	Fractionl uint32
}

type NtpMsg

type NtpMsg struct {
	Status     uint8
	Stratum    uint8
	Ppoll      uint8
	Precision  int8
	Rootdelay  NtpShort
	Dispersion NtpShort
	Refid      uint32
	Reftime    NtpLong
	Orgtime    NtpLong
	Rectime    NtpLong
	Xmttime    NtpLong
}

func GetNtpMsg

func GetNtpMsg(conn *net.UDPConn) (*NtpMsg, *net.UDPAddr, error)

func NewMsg

func NewMsg(buf []byte) *NtpMsg

func (*NtpMsg) Bytes

func (m *NtpMsg) Bytes() []byte

type NtpShort

type NtpShort struct {
	IntParts  uint16
	Fractions uint16
}

type Server

type Server struct {
	Addr        string
	ReadTimeout int32
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *Server

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe() error

func (*Server) Shutdown

func (srv *Server) Shutdown() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL