Documentation ¶
Overview ¶
Package daemon provides a Go implementation of the sd_notify protocol. It can be used to inform systemd of service start-up completion, watchdog events, and other status changes.
https://www.freedesktop.org/software/systemd/man/sd_notify.html#Description
Index ¶
- Constants
- func AbsInt(a int) int
- func ByteSlice2Byte32(bytes []byte) (ret [32]byte)
- func GUzip(bytesIn []byte) (ret []byte, err error)
- func GetByte(structIn interface{}) (bb []byte, err error)
- func Gzip(bytesIn []byte) (ret []byte)
- func Hash2Str(h string) string
- func RandomBytes(length int, defaults []byte) (ret []byte)
- func RandomStr(length int, defaults string) (ret string)
- func ReadYaml(filePath string, out interface{}) (err error)
- func S2TD(secs float64) time.Duration
- func SdNotify(unsetEnvironment bool, state string) (bool, error)
- func String2Float64(s string) (float64, error)
- type API_Peerinfo
- type API_Peers
- type API_SuperParams
- type API_connurl
- type API_report_peerinfo
- type API_report_peerinfo_jwt_claims
- type BoardcastPeerMsg
- type DistTable
- type DynamicRouteInfo
- type EdgeConfig
- type GraphRecalculateSetting
- type InterfaceConf
- type JWTSecret
- type LoggerInfo
- type NTPInfo
- type NextHopTable
- type P2PInfo
- type Passwords
- type PeerInfo
- type PingMsg
- type PongMsg
- type QueryPeerMsg
- type RegisterMsg
- type SUPER_Events
- type ServerCommand
- type ServerUpdateMsg
- type StateHash
- type SuperConfig
- type SuperInfo
- type SuperPeerInfo
- type Vertex
Constants ¶
const ( // SdNotifyReady tells the service manager that service startup is finished // or the service finished loading its configuration. SdNotifyReady = "READY=1" // SdNotifyStopping tells the service manager that the service is beginning // its shutdown. SdNotifyStopping = "STOPPING=1" // SdNotifyReloading tells the service manager that this service is // reloading its configuration. Note that you must call SdNotifyReady when // it completed reloading. SdNotifyReloading = "RELOADING=1" // SdNotifyWatchdog tells the service manager to update the watchdog // timestamp for the service. SdNotifyWatchdog = "WATCHDOG=1" )
const Infinity = float64(99999)
Variables ¶
This section is empty.
Functions ¶
func ByteSlice2Byte32 ¶
func RandomBytes ¶
func SdNotify ¶ added in v0.3.2
SdNotify sends a message to the init daemon. It is common to ignore the error. If `unsetEnvironment` is true, the environment variable `NOTIFY_SOCKET` will be unconditionally unset.
It returns one of the following: (false, nil) - notification not supported (i.e. NOTIFY_SOCKET is unset) (false, err) - notification supported, but failure happened (e.g. error connecting to NOTIFY_SOCKET or while sending data) (true, nil) - notification supported, data has been sent
func String2Float64 ¶ added in v0.3.3
Types ¶
type API_Peerinfo ¶
type API_Peerinfo struct { NodeID Vertex PSKey string Connurl *API_connurl }
type API_Peers ¶
type API_Peers map[string]API_Peerinfo // map[PubKey]API_Peerinfo
type API_SuperParams ¶ added in v0.3.1
type API_connurl ¶
type API_connurl struct { ExternalV4 map[string]float64 ExternalV6 map[string]float64 LocalV4 map[string]float64 LocalV6 map[string]float64 }
func (*API_connurl) GetList ¶
func (Connurl *API_connurl) GetList(UseLocal bool) (ret map[string]float64)
func (*API_connurl) IsEmpty ¶
func (Connurl *API_connurl) IsEmpty() bool
type API_report_peerinfo ¶
type API_report_peerinfo struct { Pongs []PongMsg LocalV4s map[string]float64 LocalV6s map[string]float64 }
func ParseAPI_report_peerinfo ¶
func ParseAPI_report_peerinfo(bin []byte) (StructPlace API_report_peerinfo, err error)
type API_report_peerinfo_jwt_claims ¶
type API_report_peerinfo_jwt_claims struct { PostCount uint64 BodyHash string jwt.StandardClaims }
type BoardcastPeerMsg ¶
func ParseBoardcastPeerMsg ¶
func ParseBoardcastPeerMsg(bin []byte) (StructPlace BoardcastPeerMsg, err error)
func (*BoardcastPeerMsg) ToString ¶
func (c *BoardcastPeerMsg) ToString() string
type DynamicRouteInfo ¶
type DynamicRouteInfo struct { SendPingInterval float64 `yaml:"SendPingInterval"` PeerAliveTimeout float64 `yaml:"PeerAliveTimeout"` TimeoutCheckInterval float64 `yaml:"TimeoutCheckInterval"` ConnNextTry float64 `yaml:"ConnNextTry"` DupCheckTimeout float64 `yaml:"DupCheckTimeout"` AdditionalCost float64 `yaml:"AdditionalCost"` DampingFilterRadius uint64 `yaml:"DampingFilterRadius"` SaveNewPeers bool `yaml:"SaveNewPeers"` SuperNode SuperInfo `yaml:"SuperNode"` P2P P2PInfo `yaml:"P2P"` NTPConfig NTPInfo `yaml:"NTPConfig"` }
type EdgeConfig ¶
type EdgeConfig struct { Interface InterfaceConf `yaml:"Interface"` NodeID Vertex `yaml:"NodeID"` NodeName string `yaml:"NodeName"` PostScript string `yaml:"PostScript"` DefaultTTL uint8 `yaml:"DefaultTTL"` L2FIBTimeout float64 `yaml:"L2FIBTimeout"` PrivKey string `yaml:"PrivKey"` ListenPort int `yaml:"ListenPort"` AfPrefer int `yaml:"AfPrefer"` LogLevel LoggerInfo `yaml:"LogLevel"` DynamicRoute DynamicRouteInfo `yaml:"DynamicRoute"` NextHopTable NextHopTable `yaml:"NextHopTable"` ResetEndPointInterval float64 `yaml:"ResetEndPointInterval"` Peers []PeerInfo `yaml:"Peers"` }
type GraphRecalculateSetting ¶
type GraphRecalculateSetting struct { StaticMode bool `yaml:"StaticMode"` ManualLatency DistTable `yaml:"ManualLatency"` JitterTolerance float64 `yaml:"JitterTolerance"` JitterToleranceMultiplier float64 `yaml:"JitterToleranceMultiplier"` TimeoutCheckInterval float64 `yaml:"TimeoutCheckInterval"` RecalculateCoolDown float64 `yaml:"RecalculateCoolDown"` }
type InterfaceConf ¶
type InterfaceConf struct { IType string `yaml:"IType"` Name string `yaml:"Name"` VPPIFaceID uint32 `yaml:"VPPIFaceID"` VPPBridgeID uint32 `yaml:"VPPBridgeID"` MacAddrPrefix string `yaml:"MacAddrPrefix"` IPv4CIDR string `yaml:"IPv4CIDR"` IPv6CIDR string `yaml:"IPv6CIDR"` IPv6LLPrefix string `yaml:"IPv6LLPrefix"` MTU uint16 `yaml:"MTU"` RecvAddr string `yaml:"RecvAddr"` SendAddr string `yaml:"SendAddr"` L2HeaderMode string `yaml:"L2HeaderMode"` }
type LoggerInfo ¶
type NextHopTable ¶
type P2PInfo ¶ added in v0.3.2
type P2PInfo struct { UseP2P bool `yaml:"UseP2P"` SendPeerInterval float64 `yaml:"SendPeerInterval"` GraphRecalculateSetting GraphRecalculateSetting `yaml:"GraphRecalculateSetting"` }
type PingMsg ¶
func ParsePingMsg ¶
type PongMsg ¶
type PongMsg struct { RequestID uint32 Src_nodeID Vertex Dst_nodeID Vertex Timediff float64 TimeToAlive float64 AdditionalCost float64 }
func ParsePongMsg ¶
type QueryPeerMsg ¶
type QueryPeerMsg struct {
Request_ID uint32
}
func ParseQueryPeerMsg ¶
func ParseQueryPeerMsg(bin []byte) (StructPlace QueryPeerMsg, err error)
func (*QueryPeerMsg) ToString ¶
func (c *QueryPeerMsg) ToString() string
type RegisterMsg ¶
type RegisterMsg struct { Node_id Vertex Version string PeerStateHash string NhStateHash string SuperParamStateHash string JWTSecret JWTSecret HttpPostCount uint64 }
func ParseRegisterMsg ¶
func ParseRegisterMsg(bin []byte) (StructPlace RegisterMsg, err error)
func (*RegisterMsg) ToString ¶
func (c *RegisterMsg) ToString() string
type SUPER_Events ¶
type SUPER_Events struct { Event_server_pong chan PongMsg Event_server_register chan RegisterMsg }
type ServerCommand ¶
type ServerCommand int
const ( NoAction ServerCommand = iota Shutdown ThrowError Panic UpdatePeer UpdateNhTable UpdateSuperParams )
func (*ServerCommand) ToString ¶
func (a *ServerCommand) ToString() string
type ServerUpdateMsg ¶ added in v0.3.1
type ServerUpdateMsg struct { Node_id Vertex Action ServerCommand Code int Params string }
func ParseServerUpdateMsg ¶ added in v0.3.1
func ParseServerUpdateMsg(bin []byte) (StructPlace ServerUpdateMsg, err error)
func (*ServerUpdateMsg) ToString ¶ added in v0.3.1
func (c *ServerUpdateMsg) ToString() string
type SuperConfig ¶
type SuperConfig struct { NodeName string `yaml:"NodeName"` PostScript string `yaml:"PostScript"` PrivKeyV4 string `yaml:"PrivKeyV4"` PrivKeyV6 string `yaml:"PrivKeyV6"` ListenPort int `yaml:"ListenPort"` ListenPort_EdgeAPI string `yaml:"ListenPort_EdgeAPI"` ListenPort_ManageAPI string `yaml:"ListenPort_ManageAPI"` API_Prefix string `yaml:"API_Prefix"` RePushConfigInterval float64 `yaml:"RePushConfigInterval"` HttpPostInterval float64 `yaml:"HttpPostInterval"` PeerAliveTimeout float64 `yaml:"PeerAliveTimeout"` SendPingInterval float64 `yaml:"SendPingInterval"` DampingFilterRadius uint64 `yaml:"DampingFilterRadius"` LogLevel LoggerInfo `yaml:"LogLevel"` Passwords Passwords `yaml:"Passwords"` GraphRecalculateSetting GraphRecalculateSetting `yaml:"GraphRecalculateSetting"` NextHopTable NextHopTable `yaml:"NextHopTable"` EdgeTemplate string `yaml:"EdgeTemplate"` UsePSKForInterEdge bool `yaml:"UsePSKForInterEdge"` ResetEndPointInterval float64 `yaml:"ResetEndPointInterval"` Peers []SuperPeerInfo `yaml:"Peers"` }
type SuperInfo ¶
type SuperInfo struct { UseSuperNode bool `yaml:"UseSuperNode"` PSKey string `yaml:"PSKey"` EndpointV4 string `yaml:"EndpointV4"` PubKeyV4 string `yaml:"PubKeyV4"` EndpointV6 string `yaml:"EndpointV6"` PubKeyV6 string `yaml:"PubKeyV6"` EndpointEdgeAPIUrl string `yaml:"EndpointEdgeAPIUrl"` SkipLocalIP bool `yaml:"SkipLocalIP"` AdditionalLocalIP []string `yaml:"AdditionalLocalIP"` SuperNodeInfoTimeout float64 `yaml:"SuperNodeInfoTimeout"` }
type SuperPeerInfo ¶
type SuperPeerInfo struct { NodeID Vertex `yaml:"NodeID"` Name string `yaml:"Name"` PubKey string `yaml:"PubKey"` PSKey string `yaml:"PSKey"` AdditionalCost float64 `yaml:"AdditionalCost"` SkipLocalIP bool `yaml:"SkipLocalIP"` EndPoint string `yaml:"EndPoint"` ExternalIP string `yaml:"ExternalIP"` }
type Vertex ¶
type Vertex uint16
Nonnegative integer ID of vertex
const ( NodeID_Broadcast Vertex = math.MaxUint16 - iota // Normal boardcast, boardcast with route table NodeID_Spread Vertex = math.MaxUint16 - iota // p2p mode: boardcast to every know peer and prevent dup. super mode: send to supernode NodeID_SuperNode Vertex = math.MaxUint16 - iota NodeID_Invalid Vertex = math.MaxUint16 - iota NodeID_Special Vertex = NodeID_Invalid )