nodeWithOnline 返回包含 online 字段的节点 JSON map(嵌入原 Node + online)。
(node nodes.Node)
| 114 | |
| 115 | // nodeWithOnline 返回包含 online 字段的节点 JSON map(嵌入原 Node + online)。 |
| 116 | func (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 | |
| 131 | func 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) |
no test coverage detected