peer_to_map function serde password
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
e1ae3601c4
commit
ee8510cec7
@ -895,7 +895,7 @@ pub fn main_load_recent_peers_for_ab(filter: String) -> String {
|
|||||||
if !config::APP_DIR.read().unwrap().is_empty() {
|
if !config::APP_DIR.read().unwrap().is_empty() {
|
||||||
let peers: Vec<HashMap<&str, String>> = PeerConfig::peers(id_filters)
|
let peers: Vec<HashMap<&str, String>> = PeerConfig::peers(id_filters)
|
||||||
.drain(..)
|
.drain(..)
|
||||||
.map(|(id, _, p)| peer_to_map_ab(id, p))
|
.map(|(id, _, p)| peer_to_map(id, p))
|
||||||
.collect();
|
.collect();
|
||||||
return serde_json::ser::to_string(&peers).unwrap_or("".to_owned());
|
return serde_json::ser::to_string(&peers).unwrap_or("".to_owned());
|
||||||
}
|
}
|
||||||
|
@ -625,6 +625,7 @@ pub fn discover() {
|
|||||||
|
|
||||||
#[cfg(feature = "flutter")]
|
#[cfg(feature = "flutter")]
|
||||||
pub fn peer_to_map(id: String, p: PeerConfig) -> HashMap<&'static str, String> {
|
pub fn peer_to_map(id: String, p: PeerConfig) -> HashMap<&'static str, String> {
|
||||||
|
use hbb_common::sodiumoxide::base64;
|
||||||
HashMap::<&str, String>::from_iter([
|
HashMap::<&str, String>::from_iter([
|
||||||
("id", id),
|
("id", id),
|
||||||
("username", p.info.username.clone()),
|
("username", p.info.username.clone()),
|
||||||
@ -634,18 +635,11 @@ pub fn peer_to_map(id: String, p: PeerConfig) -> HashMap<&'static str, String> {
|
|||||||
"alias",
|
"alias",
|
||||||
p.options.get("alias").unwrap_or(&"".to_owned()).to_owned(),
|
p.options.get("alias").unwrap_or(&"".to_owned()).to_owned(),
|
||||||
),
|
),
|
||||||
])
|
(
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "flutter")]
|
|
||||||
pub fn peer_to_map_ab(id: String, p: PeerConfig) -> HashMap<&'static str, String> {
|
|
||||||
use hbb_common::sodiumoxide::base64;
|
|
||||||
let mut m = peer_to_map(id, p.clone());
|
|
||||||
m.insert(
|
|
||||||
"hash",
|
"hash",
|
||||||
base64::encode(p.password, base64::Variant::Original),
|
base64::encode(p.password, base64::Variant::Original),
|
||||||
);
|
),
|
||||||
m
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "flutter")]
|
#[cfg(feature = "flutter")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user