MCPcopy Index your code
hub / github.com/0xUnixIO/pulse / nodeWithOnline

Method nodeWithOnline

internal/serverapi/api.go:116–129  ·  view source on GitHub ↗

nodeWithOnline 返回包含 online 字段的节点 JSON map(嵌入原 Node + online)。

(node nodes.Node)

Source from the content-addressed store, hash-verified

114
115// nodeWithOnline 返回包含 online 字段的节点 JSON map(嵌入原 Node + online)。
116func (a *API) nodeWithOnline(node nodes.Node) map[string]any {
117 online := false
118 if a.hub != nil {
119 online = a.hub.IsOnline(node.ID)
120 }
121 b, _ := json.Marshal(node)
122 var m map[string]any
123 _ = json.Unmarshal(b, &m)
124 if m == nil {
125 m = map[string]any{}
126 }
127 m["online"] = online
128 return m
129}
130
131func RegisterUsersAPI(mux *http.ServeMux, usersStore users.Store, nodesStore nodes.Store, inboundStore inbounds.InboundStore, outboundStore outbounds.Store, dial jobs.NodeDialer, applyOpts jobs.ApplyOptions, geoDB *geoip.DB, sesStore PortalSessionStore) {
132 base := New(nodesStore)

Callers 2

handleNodesMethod · 0.95
handleNodeMethod · 0.95

Calls 1

IsOnlineMethod · 0.80

Tested by

no test coverage detected