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

Method loadMetas

internal/agent/secure_agent.go:48–70  ·  view source on GitHub ↗

loadMetas 动态加载所有加密私钥的元数据

()

Source from the content-addressed store, hash-verified

46
47// loadMetas 动态加载所有加密私钥的元数据
48func (a *secureAgent) loadMetas() ([]store.EncryptedFile, error) {
49 dir := store.KeysDir()
50 entries, err := os.ReadDir(dir)
51 if err != nil && !os.IsNotExist(err) {
52 return nil, err
53 }
54 var metas []store.EncryptedFile
55 for _, e := range entries {
56 if e.IsDir() || filepath.Ext(e.Name()) != ".enc" {
57 continue
58 }
59 b, err := os.ReadFile(filepath.Join(dir, e.Name()))
60 if err != nil {
61 continue
62 }
63 var m store.EncryptedFile
64 if err := jsonUnmarshal(b, &m); err != nil {
65 continue
66 }
67 metas = append(metas, m)
68 }
69 return metas, nil
70}
71
72func (a *secureAgent) List() ([]*xagent.Key, error) {
73 // 动态加载最新的密钥列表

Callers 4

newSecureAgentWithTTLFunction · 0.95
ListMethod · 0.95
SignMethod · 0.95
SignWithFlagsMethod · 0.95

Calls 2

KeysDirFunction · 0.92
jsonUnmarshalFunction · 0.85

Tested by

no test coverage detected