native

package
v4.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package native implements three of the protocol-runtime package's routes in the package itself: the protocol templates (static data), and the administrator's diagnostic task history and task detail on the kernel's v2_agent_diagnostic_task table, adopted in place (kernel.storage.adopt:v2_agent_diagnostic_task). The kernel keeps writing that table (creating a task, the agents' polls and results), so a route can switch between legacy and native at any time. Responses are byte-compatible with the legacy handlers (internal/tests/protocolruntimecompat).

The other seventeen routes stay bridged; the reasons are in the host's bridgedRoutes (packages/protocol-runtime/control/service.go). In short: node protocols live in the protected v2_node_protocol (Reality and WireGuard private keys, and the rows the kernel builds every node's configuration from without validating them again), the agent routes authenticate node credentials and keep the agents' live connections in the kernel's memory, and the Agent Control routes dispatch over the kernel's gRPC control streams.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentDiagnosticTask

type AgentDiagnosticTask struct {
	ID         uint      `gorm:"primaryKey" json:"id"`
	TaskID     string    `gorm:"size:80;uniqueIndex" json:"task_id"`
	NodeID     uint      `gorm:"index" json:"node_id"`
	Action     string    `gorm:"size:40" json:"action"`
	Params     string    `gorm:"type:text" json:"params,omitempty"`
	Status     string    `gorm:"size:20;index" json:"status"`
	Success    bool      `json:"success"`
	Output     string    `gorm:"type:text" json:"output,omitempty"`
	Error      string    `gorm:"type:text" json:"error,omitempty"`
	DurationMS int64     `json:"duration_ms"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"timestamp"`
}

AgentDiagnosticTask is a v2_agent_diagnostic_task row, as the kernel model declares it: a whitelisted diagnostic action an administrator sent to a node's agent, and the result the agent reported.

func (AgentDiagnosticTask) TableName

func (AgentDiagnosticTask) TableName() string

TableName is the adopted kernel table.

type ProtocolTemplate

type ProtocolTemplate struct {
	Type        string `json:"type"`
	Name        string `json:"name"`
	Description string `json:"description"`
	DefaultPort int    `json:"default_port"`
	Settings    string `json:"settings"`
	TLS         int    `json:"tls"`
	TLSSettings string `json:"tls_settings"`
	Transport   string `json:"transport"`
	Reality     string `json:"reality_settings"`
}

ProtocolTemplate is a quick-add protocol template, as the kernel's model.ProtocolTemplate declares it.

type Service

type Service struct {
	// Open returns the package's storage connection, on which the adopted
	// v2_agent_diagnostic_task table is visible.
	Open func(ctx context.Context) (*gorm.DB, error)
	// Now defaults to time.Now.
	Now func() time.Time
}

Service holds what the native routes need.

func (*Service) GetDiagnosticTask

func (s *Service) GetDiagnosticTask(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)

GetDiagnosticTask is GET /api/v2/admin/agent/tasks/:task_id.

func (*Service) Handlers

func (s *Service) Handlers() map[string]pluginhostsdk.NativeHandler

Handlers returns the native handlers by route id.

func (*Service) ListDiagnosticTasks

func (s *Service) ListDiagnosticTasks(ctx context.Context, request pluginhostsdk.NativeRequest) (pluginhostsdk.NativeResponse, error)

ListDiagnosticTasks is GET /api/v2/admin/agent/tasks: the newest tasks, optionally of one node. node_id and limit are read as the legacy handler reads them, strconv.Atoi with errors as 0.

func (*Service) ProtocolTemplates

ProtocolTemplates is GET /api/v2/admin/protocol-templates.

Jump to

Keyboard shortcuts

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