Documentation ¶
Index ¶
- Variables
- func AddPortTrafficMonitor(localPort int, remoteHost string, remotePort int)
- func Decrypt(encryptedData string, key []byte) ([]byte, error)
- func DeletePortTrafficMonitor(localPort int)
- func GenerateUnusedPort() int
- func GetRandomPort() int
- func InitLog(level string, destination string)
- func PortIsUsed(port int) bool
- func ReInitLog(level string)
- func ReportStatExecutor()
- func ReportTrafficExecutor()
- func SelectAvailablePort(port *int)
- func ShellExecutor(shell Shell) []byte
- func Sign(payload interface{}, secret string) string
- func SyncLog()
- func ValidateLogDest(logDest string) error
- func ValidateLogLevel(logLevel string) error
- type Agent
- func (agent *Agent) GetConfig(key string) string
- func (agent *Agent) GetConfigWithGlobal(key string, global bool) string
- func (agent *Agent) Ready() bool
- func (agent *Agent) ReportLog(log string)
- func (agent *Agent) ReportStat(status string)
- func (agent *Agent) ReportTaskResult(taskId string, success bool, extra string)
- func (agent *Agent) ReportTraffic(traffic string)
- func (agent *Agent) Start(ctx context.Context)
- func (agent *Agent) Stop()
- func (agent *Agent) UpdateJobCron(cronKey string)
- type CPUInfo
- type ConfigChangeTask
- type ForwardTask
- type ForwardTaskHandleFunc
- type ForwardTaskResult
- type IAgent
- type IpInfo
- type Options
- type PingTask
- type RemoteWriteSyncer
- type Shell
- type ShellTask
- type Task
- type TaskHandleFunc
- type TaskResult
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Version string Config string Dir string )
View Source
var ForwardTaskHandlers = map[string]map[string]ForwardTaskHandleFunc{
"add": {
"IPTABLES": handleForwardTaskAddIptables,
"GOST": handleForwardTaskAddGOST,
},
"delete": {
"IPTABLES": handleForwardTaskDeleteIptables,
"GOST": handleForwardTaskDeleteGOST,
},
}
View Source
var JobDefinitions = map[string]any{ "AGENT_REPORT_STAT_JOB": ReportStatExecutor, "AGENT_REPORT_TRAFFIC_JOB": ReportTrafficExecutor, }
View Source
var Log *zap.Logger
View Source
var LogDestinations = []string{"console", "remote"}
View Source
var LogLevels = []string{"debug", "info", "warn", "error", "panic", "fatal"}
View Source
var LogR *zap.Logger
View Source
var TaskHandlers = map[string]TaskHandleFunc{ "hello": func(task Task) (interface{}, error) { GlobalAgent.ReportTaskResult(task.Id, true, "hello") return "hello", nil }, "config_change": handleConfigChange, "forward": handleForwardTask, "shell": handleShellTask, "ping": handlePingTask, "report_stat": func(task Task) (interface{}, error) { ReportStatExecutor() GlobalAgent.ReportTaskResult(task.Id, true, "请检查日志中的状态报告") return nil, nil }, "report_traffic": func(task Task) (interface{}, error) { ReportTrafficExecutor() GlobalAgent.ReportTaskResult(task.Id, true, "请检查日志中的流量报告") return nil, nil }, }
Functions ¶
func AddPortTrafficMonitor ¶
func DeletePortTrafficMonitor ¶
func DeletePortTrafficMonitor(localPort int)
func GenerateUnusedPort ¶
func GenerateUnusedPort() int
func GetRandomPort ¶
func GetRandomPort() int
func PortIsUsed ¶
func ReportStatExecutor ¶
func ReportStatExecutor()
func ReportTrafficExecutor ¶
func ReportTrafficExecutor()
func SelectAvailablePort ¶
func SelectAvailablePort(port *int)
func ShellExecutor ¶
func ValidateLogDest ¶
func ValidateLogLevel ¶
Types ¶
type Agent ¶
type Agent struct { AgentId string DB *redis.Client Scheduler gocron.Scheduler Jobs map[string]gocron.Job // contains filtered or unexported fields }
func (*Agent) GetConfigWithGlobal ¶
func (*Agent) ReportStat ¶
func (*Agent) ReportTaskResult ¶
func (*Agent) ReportTraffic ¶
func (*Agent) UpdateJobCron ¶
type ConfigChangeTask ¶
type ForwardTask ¶
type ForwardTaskHandleFunc ¶
type ForwardTaskHandleFunc func(forwardTask ForwardTask) (interface{}, error)
type ForwardTaskResult ¶
type ForwardTaskResult struct {
AgentPort int `json:"agentPort"`
}
type IAgent ¶
type IAgent interface { Start(ctx context.Context) Stop() Ready() bool GetConfig(key string) string GetConfigWithGlobal(key string, global bool) string ReportStat(stat string) ReportTraffic(traffic string) ReportTaskResult(taskId string, success bool, extra string) ReportLog(log string) UpdateJobCron(cronKey string) }
var GlobalAgent IAgent
type IpInfo ¶
type RemoteWriteSyncer ¶
type RemoteWriteSyncer struct { }
type TaskHandleFunc ¶
type TaskResult ¶
Click to show internal directories.
Click to hide internal directories.