Documentation
¶
Overview ¶
Package hub owns the live connections to node agents and keeps the running xray configuration of every node in sync with the panel database.
Index ¶
- type Hub
- func (h *Hub) BuildNodeConfig(ctx context.Context, node *domain.Node) ([]byte, string, error)
- func (h *Hub) Connect(stream nodev1.NodeControl_ConnectServer) error
- func (h *Hub) FetchLogs(ctx context.Context, nodeID string, lines int) ([]string, error)
- func (h *Hub) Online(nodeID string) bool
- func (h *Hub) OnlineNodes() []string
- func (h *Hub) PreviewNodeConfig(ctx context.Context, nodeID string) (json.RawMessage, error)
- func (h *Hub) RequestSync(nodeID string)
- func (h *Hub) RequestSyncAll(ctx context.Context)
- func (h *Hub) RequestSyncForUser(ctx context.Context, userID string)
- func (h *Hub) RequestSyncProfile(ctx context.Context, profileID string)
- func (h *Hub) RunMaintenance(ctx context.Context)
- func (h *Hub) RunSyncLoop(ctx context.Context)
- func (h *Hub) SendCommand(nodeID string, kind nodev1.Command_Kind) error
- func (h *Hub) SyncNode(ctx context.Context, nodeID string, force bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hub ¶
type Hub struct {
nodev1.UnimplementedNodeControlServer
// contains filtered or unexported fields
}
func (*Hub) BuildNodeConfig ¶
BuildNodeConfig renders the exact xray document a node should run.
func (*Hub) Connect ¶
func (h *Hub) Connect(stream nodev1.NodeControl_ConnectServer) error
Connect implements the agent-facing control stream. The agent dials in, authenticates with its enrolment token and then keeps the stream open for the lifetime of the process.
func (*Hub) FetchLogs ¶
FetchLogs asks an agent for the tail of its xray log and waits for the reply.
func (*Hub) OnlineNodes ¶
OnlineNodes returns the ids of every connected node.
func (*Hub) PreviewNodeConfig ¶
PreviewNodeConfig returns the rendered config as pretty JSON for the UI.
func (*Hub) RequestSync ¶
RequestSync schedules a configuration push for one node.
func (*Hub) RequestSyncAll ¶
RequestSyncAll schedules a push for every node the panel knows about.
func (*Hub) RequestSyncForUser ¶
RequestSyncForUser pushes only to the nodes that can actually serve the user, derived from the profiles behind the user's squads.
func (*Hub) RequestSyncProfile ¶
RequestSyncProfile schedules a push for every node bound to a profile.
func (*Hub) RunMaintenance ¶
RunMaintenance applies scheduled housekeeping: expiring users, rolling traffic counters over and pruning history.
func (*Hub) RunSyncLoop ¶
RunSyncLoop drains coalesced sync requests until the context is cancelled.
func (*Hub) SendCommand ¶
func (h *Hub) SendCommand(nodeID string, kind nodev1.Command_Kind) error
SendCommand asks a connected agent to perform an action.