diff --git a/client/identity.go b/client/identity.go index 6b768d7..baff818 100644 --- a/client/identity.go +++ b/client/identity.go @@ -26,6 +26,7 @@ type Identity struct { OwnedDevices PeerList `json:"owned_devices,omitempty"` StaticMtkServerPaths []InternalServerList `json:"static_mtk_server_paths,omitempty"` DynamicMtkServeRules []string `json:"dynamic_mtk_serve_rules,omitempty"` + unlockedHiddenPeers PeerList } func CreateIdentity(nickname string) *Identity { @@ -138,3 +139,23 @@ func (id *Identity) Save() error { err = os.WriteFile(GetConfig().IdentityFile, []byte(armor), 0600) return err } + +func (id *Identity) TryUnlockHidden(password string) error { + found := false + for _, encPeer := range id.HiddenPeers { + p := Peer{} + jsonPeer, err := meowlib.SymDecrypt(password, encPeer) + if err == nil { + err = json.Unmarshal(jsonPeer, &p) + if err != nil { + return err + } + id.unlockedHiddenPeers = append(id.unlockedHiddenPeers, p) + found = true + } + } + if found { + return nil + } + return errors.New("no peer found") +}