Documentation
¶
Index ¶
- Constants
- Variables
- func BuildBlacklist(cfg *SecurityConfig) []*regexp.Regexp
- func CheckDangerous(command string, patterns []*regexp.Regexp) error
- func Serve(cfg *AgentConfig) error
- func WriteFile(path string, content string, mode string) error
- type AgentConfig
- type ExecResult
- type InitResult
- type ReadResult
- type SecurityConfig
Constants ¶
View Source
const AgentVersion = "0.2.0"
AgentVersion is the current reach-agent version.
Variables ¶
View Source
var Capabilities = []string{"stats", "dryrun"}
Capabilities lists the features this agent supports beyond v0.1.0 baseline.
Functions ¶
func BuildBlacklist ¶
func BuildBlacklist(cfg *SecurityConfig) []*regexp.Regexp
BuildBlacklist 根据配置构建最终黑名单
func CheckDangerous ¶
CheckDangerous 检查命令是否在黑名单中
Types ¶
type AgentConfig ¶
type AgentConfig struct {
Port int `yaml:"port"`
Token string `yaml:"token"`
TLSCert string `yaml:"tls_cert"`
TLSKey string `yaml:"tls_key"`
MaxOutput int `yaml:"max_output"`
MaxTimeout int `yaml:"max_timeout"`
// 安全配置
Security SecurityConfig `yaml:"security"`
}
AgentConfig 对应 config.yaml
type ExecResult ¶
type ExecResult struct {
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
ExitCode int `json:"exit_code"`
Truncated bool `json:"truncated"`
}
ExecResult 命令执行结果
type InitResult ¶
type InitResult struct {
Token string
Fingerprint string
CertPath string
KeyPath string
ConfigPath string
}
InitResult 包含初始化后的关键信息
type ReadResult ¶
type ReadResult struct {
Content string `json:"content"`
Size int `json:"size"`
Truncated bool `json:"truncated"`
}
ReadResult 文件读取结果
type SecurityConfig ¶
type SecurityConfig struct {
// 命令黑名单开关 (默认 true)
CommandBlacklist *bool `yaml:"command_blacklist"`
// 自定义黑名单正则(追加到内置列表)
CustomBlacklist []string `yaml:"custom_blacklist"`
// AUTH_FAIL 日志(供 fail2ban 使用,默认 true)
AuthFailLog *bool `yaml:"auth_fail_log"`
}
SecurityConfig 安全相关可选配置
Click to show internal directories.
Click to hide internal directories.