config

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package config 定义节点 Agent 配置。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Master    Master        `yaml:"master"`
	Xray      Xray          `yaml:"xray"`
	Stats     Stats         `yaml:"stats"`
	Update    Update        `yaml:"update"`
	Geo       geo.Config    `yaml:"geo"`                // geoip.dat / geosite.dat 自动更新
	Heartbeat time.Duration `yaml:"heartbeat_interval"` // 心跳间隔
	// Metrics 快车道实时指标周期(CPU/网速/连接数/每用户速率)。主控未下发
	// agent_settings.metrics_interval_sec 时用它兜底;缺键 = 默认 3s(Load 先套
	// Default() 再反序列化,存量 agent.yaml 不需要为此改文件)。
	Metrics      time.Duration `yaml:"metrics_interval"`
	ReconnectMax time.Duration `yaml:"reconnect_max"` // 重连退避上限
	// Phase T:内部账户与证书
	AccountsPath string `yaml:"accounts_path"` // relay 内部账户持久化文件
	CertsDir     string `yaml:"certs_dir"`     // push_cert 落盘根目录
	// OutboxPath 流量上报发件箱(审计 F1):采集到的增量先落盘成批次,收到主控落库回执才删批。
	// 空 = 纯内存(不落盘,进程重启即丢待上报流量),生产必须给路径。
	OutboxPath string `yaml:"outbox_path"`
}

Config Agent 配置(对应 agent.yaml)。

func Default

func Default() *Config

Default 返回内置默认值。

func Load

func Load(path string) (*Config, error)

Load 读取并校验配置。

type Master

type Master struct {
	URL    string `yaml:"url"` // 主控 ws 地址(不含 query),如 ws://127.0.0.1:18082/node/ws
	NodeID string `yaml:"node_id"`
	Secret string `yaml:"secret"`
}

type Stats

type Stats struct {
	APIAddr         string        `yaml:"api_addr"`         // xray gRPC 地址,如 127.0.0.1:10085
	CollectInterval time.Duration `yaml:"collect_interval"` // 采集周期
	ReportInterval  time.Duration `yaml:"report_interval"`  // 上报周期
}

Stats 流量采集(对应 xray 配置中的 api 段)。

type Update

type Update struct {
	Repo   string `yaml:"repo"`   // owner/repo,空 = 内置默认
	Mirror string `yaml:"mirror"` // 首选镜像/代理前缀,置顶尝试;失败自动切换内置候选列表
	// DownloadTimeout 单镜像单次资产下载超时,0 = 默认 10m(慢链路可调大)。
	DownloadTimeout time.Duration `yaml:"download_timeout"`
}

Update 自升级下载源(默认 GitHub: acdc-awa/XPanel-Node Releases)。

type Xray

type Xray struct {
	Bin        string `yaml:"bin"`         // xray 可执行文件路径
	ConfigPath string `yaml:"config_path"` // 配置落盘路径
	LogPath    string `yaml:"log_path"`    // xray stdout/stderr 日志
	PidFile    string `yaml:"pid_file"`    // pid 文件
	// LogMaxSizeMB 日志单文件上限(MB):agent 把 xray 的 stdout/stderr 写进 LogPath,
	// 超过该体积即按大小滑动(保留尾部一半),不压缩、不留多份——日志时效性强,
	// 留最近一段够排查。0 = 不限制(旧行为)。
	LogMaxSizeMB int `yaml:"log_max_size_mb"`
}

func (Xray) LogMaxBytes added in v0.2.0

func (x Xray) LogMaxBytes() int64

LogMaxBytes 转成字节数(0 = 不限制)。

Jump to

Keyboard shortcuts

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