refactor addressbook sync

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-08-02 22:25:54 +08:00
parent 6fa48b4ada
commit cd5658f01d
10 changed files with 365 additions and 66 deletions

View File

@@ -3,7 +3,9 @@ use hbb_common::password_security;
use hbb_common::{
allow_err,
config::{self, Config, LocalConfig, PeerConfig},
directories_next, log, tokio,
directories_next, log,
sodiumoxide::base64,
tokio,
};
use hbb_common::{
bytes::Bytes,
@@ -610,6 +612,16 @@ pub fn peer_to_map(id: String, p: PeerConfig) -> HashMap<&'static str, String> {
])
}
#[cfg(feature = "flutter")]
pub fn peer_to_map_ab(id: String, p: PeerConfig) -> HashMap<&'static str, String> {
let mut m = peer_to_map(id, p.clone());
m.insert(
"hash",
base64::encode(p.password, base64::Variant::Original),
);
m
}
#[inline]
pub fn get_lan_peers() -> Vec<HashMap<&'static str, String>> {
config::LanPeers::load()