plugin

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BPFStats

type BPFStats struct {
	Instructions uint64 `json:"instructions"`
	Cycles       uint64 `json:"cycles"`
}

BPFStats はBPF統計

type BasePacketDef

type BasePacketDef struct {
	Type   string `json:"type"` // "hex", "base64", "zeros"
	Data   string `json:"data"`
	Length uint16 `json:"length"`
}

BasePacketDef はベースパケット定義

type ChecksumDef

type ChecksumDef struct {
	Layer      string `json:"layer"`       // "ipv4", "tcp", "udp"
	AutoUpdate bool   `json:"auto_update"` // 自動更新
	Algorithm  string `json:"algorithm,omitempty"`
}

ChecksumDef はチェックサム定義

type Constraints

type Constraints struct {
	MinLength  *uint16 `json:"min_length,omitempty"`
	MaxLength  *uint16 `json:"max_length,omitempty"`
	LayerCount *uint16 `json:"layer_count,omitempty"`
}

Constraints は制約条件

type ExpectedResults

type ExpectedResults struct {
	Checksums   map[string]bool        `json:"checksums"`
	Fields      map[string]interface{} `json:"fields"`
	Patterns    []Pattern              `json:"patterns"`
	Constraints *Constraints           `json:"constraints,omitempty"`
}

ExpectedResults は期待結果

type Field

type Field struct {
	Name   string      `json:"name"`
	Offset uint16      `json:"offset"`
	Length uint16      `json:"length"`
	Type   string      `json:"type"` // "uint32", "ipv4", "mac", etc.
	Value  interface{} `json:"value"`
	Endian string      `json:"endian,omitempty"` // "big", "little"
}

Field はフィールド定義

type GeneratorAdapter

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

GeneratorAdapter はGeneratorPluginのアダプター

func NewGeneratorAdapter

func NewGeneratorAdapter(name string, plugin *wasmPlugin) *GeneratorAdapter

func (*GeneratorAdapter) Call

func (g *GeneratorAdapter) Call(ctx context.Context, input []byte) ([]byte, error)

func (*GeneratorAdapter) Cleanup

func (g *GeneratorAdapter) Cleanup(ctx context.Context) ([]byte, error)

func (*GeneratorAdapter) GenerateTemplate

func (g *GeneratorAdapter) GenerateTemplate(ctx context.Context, input map[string]interface{}) (*guest.GeneratorProcessResponse, error)

func (*GeneratorAdapter) Initialize

func (g *GeneratorAdapter) Initialize(ctx context.Context, config []byte) ([]byte, error)

func (*GeneratorAdapter) Name

func (g *GeneratorAdapter) Name() string

type GeneratorMetadata

type GeneratorMetadata struct {
	PacketCount uint64      `json:"packet_count"`
	RatePPS     uint64      `json:"rate_pps"`
	IMIX        *IMIXConfig `json:"imix,omitempty"`
	Tags        []string    `json:"tags"`
	Description string      `json:"description,omitempty"`
}

GeneratorMetadata はジェネレーターのメタデータ

type GeneratorOutput

type GeneratorOutput struct {
	Version    string             `json:"version"`
	Template   PacketTemplateData `json:"template"`
	Metadata   GeneratorMetadata  `json:"metadata"`
	NextPlugin string             `json:"next_plugin,omitempty"`
}

GeneratorOutput はジェネレータープラグインの出力

type GeneratorPlugin

type GeneratorPlugin interface {
	Plugin

	// GenerateTemplate はパケットテンプレートを生成する
	GenerateTemplate(ctx context.Context, seq uint64, args []byte) (*GeneratorOutput, error)
}

GeneratorPlugin はパケットジェネレータープラグインのインターフェース

type GeneratorStack added in v0.3.0

type GeneratorStack struct {
	GeneratorInitRequest     []byte
	GeneratorInitResponse    []byte
	GeneratorProcessRequest  []byte
	GeneratorProcessResponse []byte
	GeneratorCleanupRequest  []byte
	GeneratorCleanupResponse []byte

	InitResponseChan    chan []byte
	ProcessResponseChan chan []byte
	CleanupResponseChan chan []byte

	RequestedShutdown atomic.Bool
}

GeneratorStack holds the data being passed between the host and the guest

type IMIXConfig

type IMIXConfig struct {
	Patterns []IMIXPattern `json:"patterns"`
}

IMIXConfig はIMIX設定

type IMIXPattern

type IMIXPattern struct {
	Size       uint16 `json:"size"`
	Weight     uint32 `json:"weight"`
	TemplateID string `json:"template_id,omitempty"`
}

IMIXPattern はIMIXパターン

type LayerDefinition

type LayerDefinition struct {
	Type   string           `json:"type"` // "ethernet", "ipv4", "tcp", etc.
	Offset uint16           `json:"offset"`
	Length uint16           `json:"length"`
	Fields map[string]Field `json:"fields"`
}

LayerDefinition はレイヤー定義

type Manager

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

Manager is the plugin manager

func NewManager

func NewManager(pluginDir string, pluginCfg string, pluginLang string, opts ...ManagerOption) (*Manager, error)

NewManager is a function to create a new plugin manager

func (*Manager) CallPlugin

func (m *Manager) CallPlugin(ctx context.Context, name string, input []byte) ([]byte, error)

CallPlugin is a function to call a plugin's process function

func (*Manager) Close

func (m *Manager) Close(ctx context.Context) error

Close is the cleanup function for Manager

func (*Manager) GetPlugin

func (m *Manager) GetPlugin(name string) (*wasmPlugin, error)

GetPlugin はロード済みプラグインを取得する

func (*Manager) InitPlugin

func (m *Manager) InitPlugin(ctx context.Context, name string, config []byte) ([]byte, error)

InitPlugin はプラグインを初期化する

func (*Manager) ListPlugins

func (m *Manager) ListPlugins() []string

ListPlugins is the list of loaded plugins

func (*Manager) LoadPlugin

func (m *Manager) LoadPlugin(ctx context.Context, name string) error

LoadPlugin はプラグインをロードする

func (*Manager) UnloadPlugin

func (m *Manager) UnloadPlugin(ctx context.Context, name string) error

UnloadPlugin はプラグインをアンロードする

type ManagerOption added in v0.11.2

type ManagerOption func(*managerOptions)

ManagerOption is a functional option for NewManager

func WithCacheDir added in v0.11.2

func WithCacheDir(dir string) ManagerOption

WithCacheDir sets the directory for WASM compilation cache

type ModifierDef

type ModifierDef struct {
	Target    ModifierTarget    `json:"target"`
	Operation ModifierOperation `json:"operation"`
	Params    json.RawMessage   `json:"params"`
}

ModifierDef はモディファイア定義

type ModifierOperation

type ModifierOperation struct {
	Type     string `json:"type"`      // "increment", "random", "range"
	DataType string `json:"data_type"` // "uint32", "ipv4"
}

ModifierOperation はモディファイアの操作

type ModifierTarget

type ModifierTarget struct {
	Layer  string  `json:"layer,omitempty"`  // "ipv4", "tcp"
	Field  string  `json:"field,omitempty"`  // "src_ip", "dst_port"
	Offset *uint16 `json:"offset,omitempty"` // 絶対オフセット
	Length *uint16 `json:"length,omitempty"`
}

ModifierTarget はモディファイアのターゲット

type PacketTemplateData

type PacketTemplateData struct {
	BasePacket BasePacketDef       `json:"base_packet"`
	Layers     []LayerDefinition   `json:"layers"`
	Modifiers  []ModifierDef       `json:"modifiers"`
	Checksums  []ChecksumDef       `json:"checksums"`
	Variables  map[string]Variable `json:"variables"`
}

PacketTemplateData はパケットテンプレートデータ

type Pattern

type Pattern struct {
	Type   string      `json:"type"`   // "exact", "regex", "range"
	Target string      `json:"target"` // "layer.field"
	Value  interface{} `json:"value"`
	Flags  string      `json:"flags,omitempty"`
}

Pattern はパターンマッチング定義

type Plugin

type Plugin interface {
	// Name はプラグイン名を返す
	Name() string

	// Version はプラグインバージョンを返す
	Version() string

	// Initialize はプラグインを初期化する
	Initialize(ctx context.Context, config []byte) error

	// Cleanup はプラグインのリソースをクリーンアップする
	Cleanup(ctx context.Context) error
}

Plugin はプラグインの基本インターフェース

type PluginMetadata

type PluginMetadata struct {
	Name         string            `json:"name"`
	Version      string            `json:"version"`
	Author       string            `json:"author"`
	Description  string            `json:"description"`
	License      string            `json:"license"`
	Type         string            `json:"type"` // "generator", "verifier"
	Capabilities map[string]bool   `json:"capabilities"`
	Requirements map[string]string `json:"requirements"`
}

PluginMetadata はプラグインメタデータ

type ProcessedPacket

type ProcessedPacket struct {
	Data       []byte            `json:"data"`
	Length     uint16            `json:"length"`
	Timestamp  int64             `json:"timestamp"`
	Sequence   uint64            `json:"sequence"`
	TemplateID string            `json:"template_id"`
	Layers     []LayerDefinition `json:"layers,omitempty"`
}

ProcessedPacket は処理済みパケット

type Variable

type Variable struct {
	Name    string      `json:"name"`
	Type    string      `json:"type"` // "counter", "random_seed"
	Value   interface{} `json:"value"`
	Scope   string      `json:"scope"`   // "global", "per_packet"
	Persist bool        `json:"persist"` // 永続化
}

Variable は変数定義

type VerificationContext

type VerificationContext struct {
	XDPAction   string                 `json:"xdp_action"`
	ProcessTime uint64                 `json:"process_time"`
	CPUCore     uint32                 `json:"cpu_core"`
	Variables   map[string]interface{} `json:"variables"`
	BPFStats    *BPFStats              `json:"bpf_stats,omitempty"`
}

VerificationContext は検証コンテキスト

type VerificationDetail

type VerificationDetail struct {
	Check    string      `json:"check"`
	Result   bool        `json:"result"`
	Expected interface{} `json:"expected"`
	Actual   interface{} `json:"actual"`
	Message  string      `json:"message"`
	Severity string      `json:"severity"` // "error", "warning", "info"
}

VerificationDetail は検証詳細

type VerificationResult

type VerificationResult struct {
	Valid    bool     `json:"valid"`
	Score    float64  `json:"score"`
	Errors   []string `json:"errors"`
	Warnings []string `json:"warnings"`
}

VerificationResult は検証結果

type VerifierAdapter

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

func NewVerifierAdapter

func NewVerifierAdapter(name, version string, plugin *wasmPlugin) *VerifierAdapter

func (*VerifierAdapter) Cleanup

func (v *VerifierAdapter) Cleanup(ctx context.Context) error

func (*VerifierAdapter) GetStats

func (v *VerifierAdapter) GetStats(ctx context.Context) (*VerifierStats, error)

GetStats は検証統計を返す

func (*VerifierAdapter) Initialize

func (v *VerifierAdapter) Initialize(ctx context.Context, config []byte) error

func (*VerifierAdapter) Name

func (v *VerifierAdapter) Name() string

func (*VerifierAdapter) VerifyPacket

func (v *VerifierAdapter) VerifyPacket(ctx context.Context, input *VerifierInput) (*VerifierOutput, error)

VerifyPacket はパケットを検証する

func (*VerifierAdapter) Version

func (v *VerifierAdapter) Version() string

type VerifierInput

type VerifierInput struct {
	Version  string              `json:"version"`
	Packet   ProcessedPacket     `json:"packet"`
	Context  VerificationContext `json:"context"`
	Expected ExpectedResults     `json:"expected"`
}

VerifierInput は検証プラグインへの入力

type VerifierOutput

type VerifierOutput struct {
	Version         string               `json:"version"`
	Result          VerificationResult   `json:"result"`
	Details         []VerificationDetail `json:"details"`
	Stats           VerifierStats        `json:"stats"`
	Recommendations []string             `json:"recommendations,omitempty"`
}

VerifierOutput は検証プラグインの出力

type VerifierPlugin

type VerifierPlugin interface {
	Plugin

	// VerifyPacket はパケットを検証する
	VerifyPacket(ctx context.Context, input *VerifierInput) (*VerifierOutput, error)

	// GetStats は検証統計を返す
	GetStats(ctx context.Context) (*VerifierStats, error)
}

VerifierPlugin はパケット検証プラグインのインターフェース

type VerifierStats

type VerifierStats struct {
	TotalChecks     uint64  `json:"total_checks"`
	Passed          uint64  `json:"passed"`
	Failed          uint64  `json:"failed"`
	Skipped         uint64  `json:"skipped"`
	ExecutionTimeMS float64 `json:"execution_time_ms"`
}

VerifierStats は検証統計

Jump to

Keyboard shortcuts

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