node

package
v0.3.27 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MPL-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrControlPlaneUnifiedReportUnsupported = errors.New("control plane unified report unsupported")

Functions

func EncodePrivate

func EncodePrivate(privKey *ecdsa.PrivateKey) (string, error)

func HysteriaPortForwardNeedsRepair added in v0.3.22

func HysteriaPortForwardNeedsRepair(status HysteriaPortForwardStatus) bool

func ResolveMachineNodeConfigs

func ResolveMachineNodeConfigs(ctx context.Context, cfg *conf.Conf) error

func SetHysteriaPortForwardDisabled added in v0.3.22

func SetHysteriaPortForwardDisabled()

func SetRealtimeHealthSnapshot

func SetRealtimeHealthSnapshot(snapshot RealtimeHealthSnapshot)

Types

type ControlPlane

type ControlPlane interface {
	GetNodeInfo(ctx context.Context) (*panel.NodeInfo, error)
	GetUserList(ctx context.Context) ([]panel.UserInfo, error)
	GetUserDelta(ctx context.Context, since int64) (*panel.UserDeltaBody, error)
	GetUserAlive(ctx context.Context) (map[int]int, error)
	CachedAliveMap() map[int]int
	CachedAliveSnapshot() *panel.AliveMap
	ReportUserTraffic(ctx context.Context, userTraffic []panel.UserTraffic) error
	ReportNodeOnlineUsers(ctx context.Context, data *map[int][]string) error
}

ControlPlane defines the panel-facing operations used by node controllers. It lets us swap panel implementations without touching controller logic.

type ControlPlaneFactory

type ControlPlaneFactory interface {
	New(nodeConfig *conf.NodeConfig) (ControlPlane, error)
}

type ControlPlaneRealtimeBootstrap

type ControlPlaneRealtimeBootstrap interface {
	GetRealtimeBootstrap(ctx context.Context) (*RealtimeBootstrap, error)
}

ControlPlaneRealtimeBootstrap exposes optional realtime bootstrap hints (e.g. ws_url from handshake).

type ControlPlaneUnifiedReporter

type ControlPlaneUnifiedReporter interface {
	ReportSnapshot(ctx context.Context, userTraffic []panel.UserTraffic, online map[int][]string) error
}

ControlPlaneUnifiedReporter exposes optional unified reporting capability.

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func NewController

func NewController(api *panel.Client, conf *conf.NodeConfig, info *panel.NodeInfo, realtime conf.RealtimeConfig) *Controller

NewController return a Node controller with default parameters.

func NewControllerWithControlPlane

func NewControllerWithControlPlane(controlPlane ControlPlane, conf *conf.NodeConfig, info *panel.NodeInfo, realtime conf.RealtimeConfig) *Controller

NewControllerWithControlPlane return a Node controller with a custom control plane.

func (*Controller) Close

func (c *Controller) Close() error

Close implement the Close() function of the service interface

func (*Controller) Start

func (c *Controller) Start(x *core.V2Core) error

Start implement the Start() function of the service interface

func (*Controller) StartReplacing added in v0.3.23

func (c *Controller) StartReplacing(x *core.V2Core, old *Controller) (bool, error)

type HysteriaPortForwardRuleSpec added in v0.3.22

type HysteriaPortForwardRuleSpec struct {
	Protocol   string `json:"protocol"`
	Match      string `json:"match"`
	TargetPort int    `json:"target_port"`
	Spec       string `json:"spec"`
}

type HysteriaPortForwardStatus added in v0.3.22

type HysteriaPortForwardStatus struct {
	Enabled       bool                            `json:"enabled"`
	RunningAsRoot bool                            `json:"running_as_root"`
	UpdatedAt     string                          `json:"updated_at,omitempty"`
	ExpectedRules []HysteriaPortForwardRuleSpec   `json:"expected_rules"`
	Tools         []HysteriaPortForwardToolStatus `json:"tools"`
	Errors        []string                        `json:"errors,omitempty"`
}

func CleanupHysteriaPortForward added in v0.3.22

func CleanupHysteriaPortForward(ctx context.Context) HysteriaPortForwardStatus

func GetHysteriaPortForwardStatusSnapshot added in v0.3.22

func GetHysteriaPortForwardStatusSnapshot() HysteriaPortForwardStatus

func InspectHysteriaPortForward added in v0.3.22

func InspectHysteriaPortForward(ctx context.Context, infos []*panel.NodeInfo) HysteriaPortForwardStatus

func RepairHysteriaPortForward added in v0.3.22

func RepairHysteriaPortForward(ctx context.Context, infos []*panel.NodeInfo) HysteriaPortForwardStatus

type HysteriaPortForwardToolStatus added in v0.3.22

type HysteriaPortForwardToolStatus struct {
	Tool       string   `json:"tool"`
	Available  bool     `json:"available"`
	Current    []string `json:"current"`
	Expected   []string `json:"expected"`
	Missing    []string `json:"missing"`
	Extra      []string `json:"extra"`
	StaleChain bool     `json:"stale_chain"`
	Error      string   `json:"error,omitempty"`
}

type Lego

type Lego struct {
	// contains filtered or unexported fields
}

func NewLego

func NewLego(config *panel.CertInfo) (*Lego, error)

func (*Lego) CheckCert

func (l *Lego) CheckCert(file []byte) (bool, error)

func (*Lego) CreateCert

func (l *Lego) CreateCert() (err error)

func (*Lego) RenewCert

func (l *Lego) RenewCert() error

func (*Lego) SetProvider

func (l *Lego) SetProvider() error

type MachineOptions

type MachineOptions struct {
	ContinueOnError bool
}

type MachinePanelNode

type MachinePanelNode struct {
	ID        int    `json:"id"`
	Code      string `json:"code"`
	Type      string `json:"type"`
	Name      string `json:"name"`
	UpdatedAt any    `json:"updated_at"`
}

type MachineRealtimeManager added in v0.3.22

type MachineRealtimeManager struct {
	// contains filtered or unexported fields
}

func NewMachineRealtimeManager added in v0.3.22

func NewMachineRealtimeManager(parent context.Context, profiles []conf.MachineProfileConfig, fallback conf.RealtimeConfig, onReload func()) *MachineRealtimeManager

func (*MachineRealtimeManager) Close added in v0.3.22

func (m *MachineRealtimeManager) Close()

func (*MachineRealtimeManager) Start added in v0.3.22

func (m *MachineRealtimeManager) Start()

type Node

type Node struct {
	NodeInfos []*panel.NodeInfo
	// contains filtered or unexported fields
}

func New

func New(nodes []conf.NodeConfig, realtime conf.RealtimeConfig) (*Node, error)

func NewMachine

func NewMachine(nodes []conf.NodeConfig, realtime conf.RealtimeConfig, opts MachineOptions) (*Node, error)

func (*Node) ActiveConfigs

func (n *Node) ActiveConfigs() []conf.NodeConfig

func (*Node) Close

func (n *Node) Close() error

func (*Node) Failures

func (n *Node) Failures() []NodeFailure

func (*Node) Reconcile

func (n *Node) Reconcile(ctx context.Context, desired []conf.NodeConfig, realtime conf.RealtimeConfig, coreInstance *core.V2Core, opts MachineOptions) (*ReconcileResult, error)

func (*Node) SetAutoHY2PortForward added in v0.3.4

func (n *Node) SetAutoHY2PortForward(enabled bool)

func (*Node) Start

func (n *Node) Start(nodes []conf.NodeConfig, core *core.V2Core) error

type NodeFailure

type NodeFailure struct {
	Config conf.NodeConfig
	Err    error
}

func FetchNodeInfos added in v0.3.22

func FetchNodeInfos(ctx context.Context, configs []conf.NodeConfig, opts MachineOptions) ([]*panel.NodeInfo, []NodeFailure, error)

FetchNodeInfos loads panel node configs without starting controllers or core.

type RealtimeBootstrap

type RealtimeBootstrap struct {
	Enabled bool
	URL     string
}

type RealtimeClient

type RealtimeClient struct {
	// contains filtered or unexported fields
}

func NewRealtimeClient

func NewRealtimeClient(parent context.Context, opts RealtimeOptions, onMessage func(realtimeMessage)) *RealtimeClient

func (*RealtimeClient) Close

func (c *RealtimeClient) Close()

func (*RealtimeClient) Send

func (c *RealtimeClient) Send(message realtimeMessage)

func (*RealtimeClient) Start

func (c *RealtimeClient) Start()

type RealtimeHealthSnapshot

type RealtimeHealthSnapshot struct {
	Status          string                  `json:"status,omitempty"`
	Ready           bool                    `json:"ready"`
	Version         string                  `json:"version,omitempty"`
	ConfigPath      string                  `json:"config_path,omitempty"`
	StartedAt       string                  `json:"started_at,omitempty"`
	UptimeSeconds   int64                   `json:"uptime_seconds,omitempty"`
	LastReloadAt    string                  `json:"last_reload_at,omitempty"`
	NodeCount       int                     `json:"node_count,omitempty"`
	RealtimeEnabled bool                    `json:"realtime_enabled"`
	HealthPort      int                     `json:"health_port,omitempty"`
	Goroutines      int                     `json:"goroutines,omitempty"`
	Runtime         RealtimeRuntimeSnapshot `json:"runtime"`
	UpdatedAt       string                  `json:"updated_at,omitempty"`
}

func GetRealtimeHealthSnapshot

func GetRealtimeHealthSnapshot() *RealtimeHealthSnapshot

type RealtimeOptions

type RealtimeOptions struct {
	URL            string
	Token          string
	NodeID         int
	MachineID      int
	NodeType       string
	PingInterval   time.Duration
	ReconnectDelay time.Duration
	LogTag         string
}

type RealtimeRuntimeSnapshot

type RealtimeRuntimeSnapshot struct {
	GoMemLimit      string `json:"gomemlimit,omitempty"`
	GoMemLimitBytes int64  `json:"gomemlimit_bytes,omitempty"`
	GOGC            int    `json:"gogc,omitempty"`
}

type ReconcileResult

type ReconcileResult struct {
	Added              int
	Removed            int
	Restarted          int
	Unchanged          int
	Skipped            int
	FullReloadRequired bool
	Failures           []NodeFailure
}

type User

type User struct {
	Email        string                 `json:"Email"`
	Registration *registration.Resource `json:"Registration"`

	KeyEncoded string `json:"Key"`
	// contains filtered or unexported fields
}

func NewLegoUser

func NewLegoUser(path string, email string) (*User, error)

func (*User) DecodePrivate

func (u *User) DecodePrivate(pemEncodedPriv string) (*ecdsa.PrivateKey, error)

func (*User) GetEmail

func (u *User) GetEmail() string

func (*User) GetPrivateKey

func (u *User) GetPrivateKey() crypto.PrivateKey

func (*User) GetRegistration

func (u *User) GetRegistration() *registration.Resource

func (*User) Load

func (u *User) Load(path string) error

func (*User) Save

func (u *User) Save(path string) error

Jump to

Keyboard shortcuts

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