refactor cmd arch & auth func

This commit is contained in:
naiba
2024-10-20 22:54:48 +08:00
parent 134c8c5acb
commit f0c2a7a766
11 changed files with 114 additions and 214 deletions
+2 -1
View File
@@ -6,10 +6,11 @@ import (
type AuthHandler struct {
ClientSecret string
ClientUUID string
}
func (a *AuthHandler) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {
return map[string]string{"client_secret": a.ClientSecret}, nil
return map[string]string{"client_secret": a.ClientSecret, "client_uuid": a.ClientUUID}, nil
}
func (a *AuthHandler) RequireTransportSecurity() bool {
+24 -7
View File
@@ -8,13 +8,30 @@ import (
)
type AgentConfig struct {
HardDrivePartitionAllowlist []string
NICAllowlist map[string]bool
DNS []string
GPU bool
Temperature bool
Debug bool
v *viper.Viper
Debug bool `json:"debug,omitempty"`
Server string `json:"server,omitempty"` // 服务器地址
ClientSecret string `json:"client_secret,omitempty"` // 客户端密钥
UUID string `json:"uuid,omitempty"`
HardDrivePartitionAllowlist []string `json:"hard_drive_partition_allowlist,omitempty"`
NICAllowlist map[string]bool `json:"nic_allowlist,omitempty"`
DNS []string `json:"dns,omitempty"`
GPU bool `json:"gpu,omitempty"` // 是否检查GPU
Temperature bool `json:"temperature,omitempty"` // 是否检查温度
SkipConnectionCount bool `json:"skip_connection_count,omitempty"` // 跳过连接数检查
SkipProcsCount bool `json:"skip_procs_count,omitempty"` // 跳过进程数量检查
DisableAutoUpdate bool `json:"disable_auto_update,omitempty"` // 关闭自动更新
DisableForceUpdate bool `json:"disable_force_update,omitempty"` // 关闭强制更新
DisableCommandExecute bool `json:"disable_command_execute,omitempty"` // 关闭命令执行
ReportDelay int `json:"report_delay,omitempty"` // 报告间隔
TLS bool `json:"tls,omitempty"` // 是否使用TLS加密传输至服务端
InsecureTLS bool `json:"insecure_tls,omitempty"` // 是否禁用证书检查
UseIPv6CountryCode bool `json:"use_i_pv_6_country_code,omitempty"` // 默认优先展示IPv6旗帜
UseGiteeToUpgrade bool `json:"use_gitee_to_upgrade,omitempty"` // 强制从Gitee获取更新
IPReportPeriod uint32 `json:"ip_report_period,omitempty"` // IP上报周期
v *viper.Viper
}
// Read 从给定的文件目录加载配置文件