Versions in this module Expand all Collapse all v0 v0.5.0 Dec 3, 2026 Changes in this version + var ErrUnchanged = errors.New("forwarding rule is already in the requested state") + func Build(spec RuleSpec) (engine.Rule, error) + func Delete(rules []engine.Rule, ruleID string) ([]engine.Rule, engine.Rule, error) + func Finalize(rule *engine.Rule) error + func IsLoopbackListenAddr(addr string) bool + func MapWriteError(err error) error + func NormalizeProtocol(value string) (engine.Protocol, error) + func NormalizeRuleID(raw string) (string, error) + func ParseBandwidth(in BandwidthSpec) (*engine.BandwidthLimit, error) + func ParseQuota(in QuotaSpec) (*engine.TrafficQuota, error) + func ParseRate(value, field string) (engine.ByteRate, error) + func ParseSize(value, field string) (engine.ByteSize, error) + func SetEnabled(rules []engine.Rule, ruleID string, enabled bool) ([]engine.Rule, engine.Rule, error) + func Upsert(rules []engine.Rule, rule engine.Rule) ([]engine.Rule, bool) + type BandwidthSpec struct + Download string + Rate string + Upload string + type Client interface + Apply func(ctx context.Context, match string, draft controlapi.ConfigRulesRequest) (*controlapi.ApplyResponse, error) + ConfigRules func(ctx context.Context) (*controlapi.ConfigRulesResponse, error) + Precheck func(ctx context.Context, match string, draft controlapi.ConfigRulesRequest) (*controlapi.PrecheckResponse, error) + type Mutation struct + DryRun bool + Mutate func(rules []engine.Rule) (next []engine.Rule, result *engine.Rule, created bool, err error) + RuleID string + type NotFoundError struct + RuleID string + func (e *NotFoundError) Error() string + type QuotaSpec struct + Daily string + Monthly string + Timezone string + type Result struct + Applied bool + ApplyResult *engine.ApplyResult + Created bool + Diff []controlapi.ConfigRuleDiff + DryRun bool + Precheck *precheck.Result + Revision string + Rule *engine.Rule + Unchanged bool + func Mutate(ctx context.Context, client Client, mutation Mutation) (Result, error) + type RuleSpec struct + AllowNonLoopback bool + Bandwidth *BandwidthSpec + Domains []string + DryRun bool + Enabled *bool + IdleTimeout int + ListenAddr string + ListenPort int + MaxConn int + Name string + Protocol string + Remark string + RuleID string + SourceIPMode string + SourceIPs []string + SpeedLimit int64 + TargetAddr string + TargetPort int + TrafficQuota *QuotaSpec