MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / ApplyNodes

Method ApplyNodes

internal/panel/handler.go:536–568  ·  view source on GitHub ↗
(nodeIDs []string)

Source from the content-addressed store, hash-verified

534}
535
536func (h *Handler) ApplyNodes(nodeIDs []string) {
537 for _, nodeID := range nodeIDs {
538 go func(id string) {
539 client, err := h.dial(id)
540 if err != nil {
541 log.Printf("applyNodes: dial %s: %v", id, err)
542 return
543 }
544 nodeInbounds, err := h.ibStore.ListInboundsByNode(id)
545 if err != nil {
546 log.Printf("applyNodes: list inbounds %s: %v", id, err)
547 return
548 }
549 userAccesses, err := h.userStore.ListUserInboundsByNode(id)
550 if err != nil {
551 log.Printf("applyNodes: list user accesses %s: %v", id, err)
552 return
553 }
554 userIDs := collectUserIDs(userAccesses)
555 userMap, err := h.userStore.GetUsersByIDs(userIDs)
556 if err != nil {
557 log.Printf("applyNodes: get users %s: %v", id, err)
558 return
559 }
560 n, _ := h.nodeStore.Get(id)
561 ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
562 defer cancel()
563 if _, _, err := jobs.ApplyNodeUsers(ctx, client, nodeInbounds, userAccesses, userMap, h.ibStore, h.outboundStore, h.applyOpts, n); err != nil {
564 log.Printf("applyNodes: apply %s: %v", id, err)
565 }
566 }(nodeID)
567 }
568}
569
570// SyncUserInbounds reconciles a user's inbound assignments. Exported for payment webhook use.
571func (h *Handler) SyncUserInbounds(userID string, selectedInboundIDs []string) ([]string, error) {

Callers 2

apiResetTokenMethod · 0.95
RunFunction · 0.80

Calls 7

ApplyNodeUsersFunction · 0.92
dialMethod · 0.80
collectUserIDsFunction · 0.70
ListInboundsByNodeMethod · 0.65
GetUsersByIDsMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected