MCPcopy Create free account
hub / github.com/Mister-leo/fssh / LoadConfig

Function LoadConfig

internal/otp/config.go:46–68  ·  view source on GitHub ↗

LoadConfig 加载 OTP 配置

(path string)

Source from the content-addressed store, hash-verified

44
45// LoadConfig 加载 OTP 配置
46func LoadConfig(path string) (*Config, error) {
47 data, err := os.ReadFile(path)
48 if err != nil {
49 return nil, fmt.Errorf("读取配置文件失败: %w", err)
50 }
51
52 var cfg Config
53 if err := json.Unmarshal(data, &cfg); err != nil {
54 return nil, fmt.Errorf("解析配置文件失败: %w", err)
55 }
56
57 // 验证配置版本
58 if cfg.Version != "fssh-otp/v1" {
59 return nil, fmt.Errorf("不支持的配置版本: %s", cfg.Version)
60 }
61
62 // 验证必要字段
63 if cfg.EncryptedSeed == "" || cfg.SeedSalt == "" || cfg.SeedNonce == "" {
64 return nil, fmt.Errorf("配置文件损坏:缺少必要字段")
65 }
66
67 return &cfg, nil
68}
69
70// SaveConfig 保存 OTP 配置
71func SaveConfig(cfg *Config) error {

Callers 3

NewOTPProviderFunction · 0.92
deriveMasterKeyFromSeedFunction · 0.92
UpdateConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected