hiddens peers unlock
This commit is contained in:
parent
61958593a1
commit
c4bb8c5693
@ -26,6 +26,7 @@ type Identity struct {
|
|||||||
OwnedDevices PeerList `json:"owned_devices,omitempty"`
|
OwnedDevices PeerList `json:"owned_devices,omitempty"`
|
||||||
StaticMtkServerPaths []InternalServerList `json:"static_mtk_server_paths,omitempty"`
|
StaticMtkServerPaths []InternalServerList `json:"static_mtk_server_paths,omitempty"`
|
||||||
DynamicMtkServeRules []string `json:"dynamic_mtk_serve_rules,omitempty"`
|
DynamicMtkServeRules []string `json:"dynamic_mtk_serve_rules,omitempty"`
|
||||||
|
unlockedHiddenPeers PeerList
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateIdentity(nickname string) *Identity {
|
func CreateIdentity(nickname string) *Identity {
|
||||||
@ -138,3 +139,23 @@ func (id *Identity) Save() error {
|
|||||||
err = os.WriteFile(GetConfig().IdentityFile, []byte(armor), 0600)
|
err = os.WriteFile(GetConfig().IdentityFile, []byte(armor), 0600)
|
||||||
return err
|
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")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user