parent
bfc42cdd8e
commit
dc17e25bac
@ -387,7 +387,7 @@ impl Network {
|
|||||||
editor_public_internet.set_network_class(Some(NetworkClass::WebApp));
|
editor_public_internet.set_network_class(Some(NetworkClass::WebApp));
|
||||||
|
|
||||||
// commit routing table edits
|
// commit routing table edits
|
||||||
editor_public_internet.commit();
|
editor_public_internet.commit(true).await;
|
||||||
|
|
||||||
self.inner.lock().network_started = true;
|
self.inner.lock().network_started = true;
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -414,10 +414,11 @@ impl Network {
|
|||||||
// Drop all dial info
|
// Drop all dial info
|
||||||
routing_table
|
routing_table
|
||||||
.edit_routing_domain(RoutingDomain::PublicInternet)
|
.edit_routing_domain(RoutingDomain::PublicInternet)
|
||||||
.clear_dial_info_details()
|
.clear_dial_info_details(None, None)
|
||||||
.set_network_class(None)
|
.set_network_class(None)
|
||||||
.clear_relay_node()
|
.clear_relay_node()
|
||||||
.commit();
|
.commit(true)
|
||||||
|
.await;
|
||||||
|
|
||||||
// Cancels all async background tasks by dropping join handles
|
// Cancels all async background tasks by dropping join handles
|
||||||
*self.inner.lock() = Self::new_inner();
|
*self.inner.lock() = Self::new_inner();
|
||||||
|
@ -582,17 +582,24 @@ impl VeilidAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn debug_config(&self, args: String) -> VeilidAPIResult<String> {
|
async fn debug_config(&self, args: String) -> VeilidAPIResult<String> {
|
||||||
let config = self.config()?;
|
let mut args = args.as_str();
|
||||||
|
let mut config = self.config()?;
|
||||||
|
if !args.starts_with("insecure") {
|
||||||
|
config = config.safe_config();
|
||||||
|
} else {
|
||||||
|
args = &args[8..];
|
||||||
|
}
|
||||||
let args = args.trim_start();
|
let args = args.trim_start();
|
||||||
|
|
||||||
if args.is_empty() {
|
if args.is_empty() {
|
||||||
return config.get_key_json("");
|
return config.get_key_json("", true);
|
||||||
}
|
}
|
||||||
let (arg, rest) = args.split_once(' ').unwrap_or((args, ""));
|
let (arg, rest) = args.split_once(' ').unwrap_or((args, ""));
|
||||||
let rest = rest.trim_start().to_owned();
|
let rest = rest.trim_start().to_owned();
|
||||||
|
|
||||||
// One argument is 'config get'
|
// One argument is 'config get'
|
||||||
if rest.is_empty() {
|
if rest.is_empty() {
|
||||||
return config.get_key_json(arg);
|
return config.get_key_json(arg, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// More than one argument is 'config set'
|
// More than one argument is 'config set'
|
||||||
@ -1372,7 +1379,7 @@ peerinfo [routingdomain]
|
|||||||
entries [dead|reliable]
|
entries [dead|reliable]
|
||||||
entry <node>
|
entry <node>
|
||||||
nodeinfo
|
nodeinfo
|
||||||
config [configkey [new value]]
|
config [insecure] [configkey [new value]]
|
||||||
txtrecord
|
txtrecord
|
||||||
keypair
|
keypair
|
||||||
purge <buckets|connections|routes>
|
purge <buckets|connections|routes>
|
||||||
|
@ -576,7 +576,7 @@ impl VeilidConfig {
|
|||||||
self.inner.read()
|
self.inner.read()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn safe_config(&self) -> VeilidConfigInner {
|
fn safe_config_inner(&self) -> VeilidConfigInner {
|
||||||
let mut safe_cfg = self.inner.read().clone();
|
let mut safe_cfg = self.inner.read().clone();
|
||||||
|
|
||||||
// Remove secrets
|
// Remove secrets
|
||||||
@ -587,6 +587,20 @@ impl VeilidConfig {
|
|||||||
safe_cfg
|
safe_cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn safe_config(&self) -> VeilidConfig {
|
||||||
|
let mut safe_cfg = self.inner.read().clone();
|
||||||
|
|
||||||
|
// Remove secrets
|
||||||
|
safe_cfg.network.routing_table.node_id_secret = TypedSecretGroup::new();
|
||||||
|
safe_cfg.protected_store.device_encryption_key_password = "".to_owned();
|
||||||
|
safe_cfg.protected_store.new_device_encryption_key_password = None;
|
||||||
|
|
||||||
|
VeilidConfig {
|
||||||
|
update_cb: self.update_cb.clone(),
|
||||||
|
inner: Arc::new(RwLock::new(safe_cfg)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn with_mut<F, R>(&self, f: F) -> VeilidAPIResult<R>
|
pub fn with_mut<F, R>(&self, f: F) -> VeilidAPIResult<R>
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut VeilidConfigInner) -> VeilidAPIResult<R>,
|
F: FnOnce(&mut VeilidConfigInner) -> VeilidAPIResult<R>,
|
||||||
@ -611,14 +625,14 @@ impl VeilidConfig {
|
|||||||
|
|
||||||
// Send configuration update to clients
|
// Send configuration update to clients
|
||||||
if let Some(update_cb) = &self.update_cb {
|
if let Some(update_cb) = &self.update_cb {
|
||||||
let safe_cfg = self.safe_config();
|
let safe_cfg = self.safe_config_inner();
|
||||||
update_cb(VeilidUpdate::Config(VeilidStateConfig { config: safe_cfg }));
|
update_cb(VeilidUpdate::Config(VeilidStateConfig { config: safe_cfg }));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(out)
|
Ok(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_key_json(&self, key: &str) -> VeilidAPIResult<String> {
|
pub fn get_key_json(&self, key: &str, pretty: bool) -> VeilidAPIResult<String> {
|
||||||
let c = self.get();
|
let c = self.get();
|
||||||
|
|
||||||
// Generate json from whole config
|
// Generate json from whole config
|
||||||
@ -627,7 +641,11 @@ impl VeilidConfig {
|
|||||||
|
|
||||||
// Find requested subkey
|
// Find requested subkey
|
||||||
if key.is_empty() {
|
if key.is_empty() {
|
||||||
Ok(jvc.to_string())
|
Ok(if pretty {
|
||||||
|
jvc.pretty(2)
|
||||||
|
} else {
|
||||||
|
jvc.to_string()
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
// Split key into path parts
|
// Split key into path parts
|
||||||
let keypath: Vec<&str> = key.split('.').collect();
|
let keypath: Vec<&str> = key.split('.').collect();
|
||||||
@ -638,7 +656,11 @@ impl VeilidConfig {
|
|||||||
}
|
}
|
||||||
out = &out[k];
|
out = &out[k];
|
||||||
}
|
}
|
||||||
Ok(out.to_string())
|
Ok(if pretty {
|
||||||
|
out.pretty(2)
|
||||||
|
} else {
|
||||||
|
out.to_string()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn set_key_json(&self, key: &str, value: &str) -> VeilidAPIResult<()> {
|
pub fn set_key_json(&self, key: &str, value: &str) -> VeilidAPIResult<()> {
|
||||||
|
Loading…
Reference in New Issue
Block a user