MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / homePluginSyncKey

Function homePluginSyncKey

sdk/cliproxy/home_plugins.go:106–133  ·  view source on GitHub ↗
(cfg *config.Config)

Source from the content-addressed store, hash-verified

104}
105
106func homePluginSyncKey(cfg *config.Config) string {
107 if cfg == nil || !cfg.Home.Enabled {
108 return ""
109 }
110 hash := sha256.New()
111 _, _ = fmt.Fprintf(hash, "enabled=%t\ndir=%s\n", cfg.Plugins.Enabled, strings.TrimSpace(cfg.Plugins.Dir))
112 ids := make([]string, 0, len(cfg.Plugins.Configs))
113 for id := range cfg.Plugins.Configs {
114 ids = append(ids, id)
115 }
116 sort.Strings(ids)
117 for _, id := range ids {
118 item := cfg.Plugins.Configs[id]
119 enabled := false
120 if item.Enabled != nil {
121 enabled = *item.Enabled
122 }
123 _, _ = fmt.Fprintf(hash, "plugin=%s\nenabled=%t\npriority=%d\n", strings.TrimSpace(id), enabled, item.Priority)
124 if item.Raw.Kind != 0 {
125 raw, errMarshal := yaml.Marshal(&item.Raw)
126 if errMarshal == nil {
127 _, _ = hash.Write(raw)
128 }
129 }
130 _, _ = hash.Write([]byte{'\n'})
131 }
132 return hex.EncodeToString(hash.Sum(nil))
133}

Callers 1

syncHomePluginsMethod · 0.85

Calls 1

WriteMethod · 0.45

Tested by

no test coverage detected