engine

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyAction

type ApplyAction string
const (
	ApplyActionStarted   ApplyAction = "started"
	ApplyActionRestarted ApplyAction = "restarted"
	ApplyActionStopped   ApplyAction = "stopped"
	ApplyActionRemoved   ApplyAction = "removed"
	ApplyActionUnchanged ApplyAction = "unchanged"
	ApplyActionFailed    ApplyAction = "failed"
)

type ApplyItemResult

type ApplyItemResult struct {
	RuleID   string      `json:"rule_id"`
	Revision int64       `json:"revision,omitempty"`
	Action   ApplyAction `json:"action"`
	Status   string      `json:"status"`
	Error    string      `json:"error,omitempty"`
}

type ApplyResult

type ApplyResult struct {
	AppliedRules int               `json:"applied_rules"`
	StoppedRules int               `json:"stopped_rules"`
	FailedRules  int               `json:"failed_rules"`
	TotalRules   int               `json:"total_rules"`
	Items        []ApplyItemResult `json:"items"`
}

type ApplySnapshotOptions

type ApplySnapshotOptions struct {
	ReplaceAll bool `json:"replace_all"`
}

type CertProvider

type CertProvider interface {
	GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)
	Obtain(ctx context.Context, domains []string) error
}

type Collector

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

func NewCollector

func NewCollector() *Collector

func (*Collector) AddDownload

func (collector *Collector) AddDownload(ruleID string, n int64)

func (*Collector) AddUpload

func (collector *Collector) AddUpload(ruleID string, n int64)

func (*Collector) DecConns

func (collector *Collector) DecConns(ruleID string)

func (*Collector) EnsureRule

func (collector *Collector) EnsureRule(ruleID string)

func (*Collector) IncConns

func (collector *Collector) IncConns(ruleID string)

func (*Collector) RemoveRule

func (collector *Collector) RemoveRule(ruleID string)

func (*Collector) SetConns

func (collector *Collector) SetConns(ruleID string, value int64)

func (*Collector) Snapshot

func (collector *Collector) Snapshot(ruleID string) TrafficSnapshot

func (*Collector) SnapshotAll

func (collector *Collector) SnapshotAll() []TrafficSnapshot

type Manager

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

func NewManager

func NewManager(collector *Collector) *Manager

func NewManagerWithCert

func NewManagerWithCert(collector *Collector, certMgr CertProvider) *Manager

func (*Manager) ApplySnapshot

func (manager *Manager) ApplySnapshot(rules []Rule, opts ApplySnapshotOptions) ApplyResult

func (*Manager) RemoveRule

func (manager *Manager) RemoveRule(ruleID string)

func (*Manager) RestartRule

func (manager *Manager) RestartRule(rule Rule) error

func (*Manager) RunningCount

func (manager *Manager) RunningCount() int

func (*Manager) RunningRules

func (manager *Manager) RunningRules() []Rule

func (*Manager) Snapshot

func (manager *Manager) Snapshot(ruleID string) TrafficSnapshot

func (*Manager) SnapshotAll

func (manager *Manager) SnapshotAll() []TrafficSnapshot

func (*Manager) StartRule

func (manager *Manager) StartRule(rule Rule) error

func (*Manager) StopAll

func (manager *Manager) StopAll()

func (*Manager) StopRule

func (manager *Manager) StopRule(ruleID string)

type Protocol

type Protocol string
const (
	ProtocolTCP    Protocol = "tcp"
	ProtocolUDP    Protocol = "udp"
	ProtocolTCPUDP Protocol = "tcp+udp"
	ProtocolHTTP   Protocol = "http"
	ProtocolHTTPS  Protocol = "https"
)

type Rule

type Rule struct {
	RuleID      string   `json:"rule_id" yaml:"rule_id"`
	Name        string   `json:"name" yaml:"name"`
	Protocol    Protocol `json:"protocol" yaml:"protocol"`
	ListenAddr  string   `json:"listen_addr" yaml:"listen_addr"`
	ListenPort  int      `json:"listen_port" yaml:"listen_port"`
	TargetAddr  string   `json:"target_addr" yaml:"target_addr"`
	TargetPort  int      `json:"target_port" yaml:"target_port"`
	Enabled     bool     `json:"enabled" yaml:"enabled"`
	SpeedLimit  int64    `json:"speed_limit" yaml:"speed_limit"`
	MaxConn     int      `json:"max_conn" yaml:"max_conn"`
	Domains     []string `json:"domains,omitempty" yaml:"domains,omitempty"`
	Remark      string   `json:"remark,omitempty" yaml:"remark,omitempty"`
	Revision    int64    `json:"revision,omitempty" yaml:"revision,omitempty"`
	CreatedTime int64    `json:"created_time,omitempty" yaml:"created_time,omitempty"`
	UpdatedTime int64    `json:"updated_time,omitempty" yaml:"updated_time,omitempty"`
}

func (Rule) RuntimeEqual

func (rule Rule) RuntimeEqual(other Rule) bool

func (Rule) Standardize

func (rule Rule) Standardize() Rule

func (Rule) Validate

func (rule Rule) Validate() error

type Runner

type Runner interface {
	Start() error
	Stop()
}

type TrafficSnapshot

type TrafficSnapshot struct {
	RuleID        string `json:"rule_id"`
	UploadBytes   int64  `json:"upload_bytes"`
	DownloadBytes int64  `json:"download_bytes"`
	Conns         int64  `json:"conns"`
	UpdatedTime   int64  `json:"updated_time"`
}

Jump to

Keyboard shortcuts

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