hub

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 23 Imported by: 0

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

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 New

func New(store *postgres.Store, cfg *config.Panel, log *slog.Logger) *Hub

func (*Hub) BuildNodeConfig

func (h *Hub) BuildNodeConfig(ctx context.Context, node *domain.Node) ([]byte, string, error)

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

func (h *Hub) FetchLogs(ctx context.Context, nodeID string, lines int) ([]string, error)

FetchLogs asks an agent for the tail of its xray log and waits for the reply.

func (*Hub) Online

func (h *Hub) Online(nodeID string) bool

Online reports whether an agent stream is currently established.

func (*Hub) OnlineNodes

func (h *Hub) OnlineNodes() []string

OnlineNodes returns the ids of every connected node.

func (*Hub) PreviewNodeConfig

func (h *Hub) PreviewNodeConfig(ctx context.Context, nodeID string) (json.RawMessage, error)

PreviewNodeConfig returns the rendered config as pretty JSON for the UI.

func (*Hub) RequestSync

func (h *Hub) RequestSync(nodeID string)

RequestSync schedules a configuration push for one node.

func (*Hub) RequestSyncAll

func (h *Hub) RequestSyncAll(ctx context.Context)

RequestSyncAll schedules a push for every node the panel knows about.

func (*Hub) RequestSyncForUser

func (h *Hub) RequestSyncForUser(ctx context.Context, userID string)

RequestSyncForUser pushes only to the nodes that can actually serve the user, derived from the profiles behind the user's squads.

func (*Hub) RequestSyncProfile

func (h *Hub) RequestSyncProfile(ctx context.Context, profileID string)

RequestSyncProfile schedules a push for every node bound to a profile.

func (*Hub) RunMaintenance

func (h *Hub) RunMaintenance(ctx context.Context)

RunMaintenance applies scheduled housekeeping: expiring users, rolling traffic counters over and pruning history.

func (*Hub) RunSyncLoop

func (h *Hub) RunSyncLoop(ctx context.Context)

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.

func (*Hub) SyncNode

func (h *Hub) SyncNode(ctx context.Context, nodeID string, force bool) error

SyncNode renders and pushes the configuration for a single node.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL