mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-09 14:48:08 -05:00
bin/app: DEP-0007: rename allowed_transports, retrieve outbound_connect_timeout, channel_handshake_timeout, channel_heartbeat_interval from network profiles
This commit is contained in:
@@ -16,6 +16,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::{
|
||||
io::Cursor,
|
||||
sync::{Arc, Mutex as SyncMutex, OnceLock, Weak},
|
||||
time::UNIX_EPOCH,
|
||||
};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use darkfi::{
|
||||
event_graph::{
|
||||
@@ -23,7 +29,11 @@ use darkfi::{
|
||||
proto::{EventPut, ProtocolEventGraph},
|
||||
EventGraph, EventGraphPtr,
|
||||
},
|
||||
net::{session::SESSION_DEFAULT, settings::Settings as NetSettings, ChannelPtr, P2p, P2pPtr},
|
||||
net::{
|
||||
session::SESSION_DEFAULT,
|
||||
settings::{MagicBytes, NetworkProfile, Settings as NetSettings},
|
||||
ChannelPtr, P2p, P2pPtr,
|
||||
},
|
||||
system::{sleep, Subscription},
|
||||
Result as DarkFiResult,
|
||||
};
|
||||
@@ -32,12 +42,7 @@ use darkfi_serial::{
|
||||
SerialDecodable, SerialEncodable,
|
||||
};
|
||||
use sled_overlay::sled;
|
||||
use std::{
|
||||
io::Cursor,
|
||||
sync::{Arc, Mutex as SyncMutex, OnceLock, Weak},
|
||||
time::UNIX_EPOCH,
|
||||
};
|
||||
use darkfi::net::settings::MagicBytes;
|
||||
|
||||
use crate::{
|
||||
error::{Error, Result},
|
||||
prop::{BatchGuardPtr, PropertyAtomicGuard, PropertyStr, Role},
|
||||
@@ -205,9 +210,9 @@ impl DarkIrc {
|
||||
p2p_settings.app_name = "darkirc".to_string();
|
||||
if get_use_tor_filename().exists() {
|
||||
i!("Setup P2P network [tor]");
|
||||
p2p_settings.outbound_connect_timeout = 60;
|
||||
p2p_settings.channel_handshake_timeout = 55;
|
||||
p2p_settings.channel_heartbeat_interval = 90;
|
||||
let mut tor_profile = NetworkProfile::tor_default();
|
||||
tor_profile.outbound_connect_timeout = 60;
|
||||
p2p_settings.profiles.insert("tor".to_string(), tor_profile);
|
||||
p2p_settings.outbound_peer_discovery_cooloff_time = 60;
|
||||
|
||||
p2p_settings.seeds.push(
|
||||
@@ -222,17 +227,20 @@ impl DarkIrc {
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
p2p_settings.allowed_transports = vec!["tor".to_string()];
|
||||
p2p_settings.active_profiles = vec!["tor".to_string()];
|
||||
} else {
|
||||
i!("Setup P2P network [clearnet]");
|
||||
p2p_settings.outbound_connect_timeout = 40;
|
||||
p2p_settings.channel_handshake_timeout = 30;
|
||||
let mut profile = NetworkProfile::default();
|
||||
profile.outbound_connect_timeout = 40;
|
||||
profile.channel_handshake_timeout = 30;
|
||||
p2p_settings.profiles.insert("tcp+tls".to_string(), profile);
|
||||
|
||||
p2p_settings.outbound_connections = 3;
|
||||
p2p_settings.inbound_connections = 0;
|
||||
|
||||
p2p_settings.seeds.push(url::Url::parse("tcp+tls://lilith0.dark.fi:25551").unwrap());
|
||||
p2p_settings.seeds.push(url::Url::parse("tcp+tls://lilith1.dark.fi:25551").unwrap());
|
||||
p2p_settings.active_profiles = vec!["tcp+tls".to_string()];
|
||||
}
|
||||
p2p_settings.p2p_datastore = p2p_datastore_path().into_os_string().into_string().ok();
|
||||
p2p_settings.hostlist = hostlist_path().into_os_string().into_string().ok();
|
||||
|
||||
@@ -19,12 +19,15 @@
|
||||
use darkfi::{
|
||||
net::{
|
||||
session::{SESSION_DIRECT, SESSION_INBOUND},
|
||||
settings::Settings as NetSettings,
|
||||
settings::{MagicBytes, NetworkProfile, Settings as NetSettings},
|
||||
P2p, P2pPtr,
|
||||
},
|
||||
system::{sleep, Publisher, PublisherPtr},
|
||||
};
|
||||
use darkfi_serial::{Decodable, Encodable};
|
||||
use fud::{
|
||||
event::FudEvent, proto::ProtocolFud, settings::Args as FudSettings, util::hash_to_string, Fud,
|
||||
};
|
||||
use sled_overlay::sled;
|
||||
use smol::lock::Mutex;
|
||||
use std::{
|
||||
@@ -35,10 +38,6 @@ use std::{
|
||||
};
|
||||
use url::Url;
|
||||
|
||||
use fud::{
|
||||
event::FudEvent, proto::ProtocolFud, settings::Args as FudSettings, util::hash_to_string, Fud,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
error::{Error, Result},
|
||||
prop::{BatchGuardPtr, PropertyAtomicGuard, PropertyBool, Role},
|
||||
@@ -158,9 +157,9 @@ impl FudPlugin {
|
||||
p2p_settings.app_name = "fud".to_string();
|
||||
if get_use_tor_filename().exists() {
|
||||
i!("Setup P2P network [tor]");
|
||||
p2p_settings.outbound_connect_timeout = 60;
|
||||
p2p_settings.channel_handshake_timeout = 55;
|
||||
p2p_settings.channel_heartbeat_interval = 90;
|
||||
let mut tor_profile = NetworkProfile::tor_default();
|
||||
tor_profile.outbound_connect_timeout = 60;
|
||||
p2p_settings.profiles.insert("tor".to_string(), tor_profile);
|
||||
p2p_settings.outbound_peer_discovery_cooloff_time = 60;
|
||||
|
||||
p2p_settings.seeds.push(
|
||||
@@ -175,7 +174,7 @@ impl FudPlugin {
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
p2p_settings.allowed_transports = vec!["tor".to_string()];
|
||||
p2p_settings.active_profiles = vec!["tor".to_string()];
|
||||
|
||||
fud_settings.pow.btc_electrum_nodes.push(
|
||||
url::Url::parse(
|
||||
@@ -203,8 +202,11 @@ impl FudPlugin {
|
||||
);
|
||||
} else {
|
||||
i!("Setup P2P network [clearnet]");
|
||||
p2p_settings.outbound_connect_timeout = 40;
|
||||
p2p_settings.channel_handshake_timeout = 30;
|
||||
let mut profile = NetworkProfile::default();
|
||||
profile.outbound_connect_timeout = 40;
|
||||
profile.channel_handshake_timeout = 30;
|
||||
p2p_settings.profiles.insert("tcp+tls".to_string(), profile);
|
||||
p2p_settings.active_profiles = vec!["tcp+tls".to_string()];
|
||||
|
||||
p2p_settings.seeds.push(url::Url::parse("tcp+tls://lilith0.dark.fi:24441").unwrap());
|
||||
p2p_settings.seeds.push(url::Url::parse("tcp+tls://lilith1.dark.fi:24441").unwrap());
|
||||
|
||||
@@ -229,17 +229,30 @@ impl PluginSettings {
|
||||
"net.inbound_connections",
|
||||
PropertyValue::Uint32(p2p_settings.inbound_connections as u32),
|
||||
);
|
||||
//TODO: Update this when multiple active_profiles at a time is supported
|
||||
self.add_setting(
|
||||
"net.outbound_connect_timeout",
|
||||
PropertyValue::Uint32(p2p_settings.outbound_connect_timeout as u32),
|
||||
PropertyValue::Uint32(
|
||||
p2p_settings
|
||||
.outbound_connect_timeout(&p2p_settings.active_profiles.first().unwrap())
|
||||
as u32,
|
||||
),
|
||||
);
|
||||
self.add_setting(
|
||||
"net.channel_handshake_timeout",
|
||||
PropertyValue::Uint32(p2p_settings.channel_handshake_timeout as u32),
|
||||
PropertyValue::Uint32(
|
||||
p2p_settings
|
||||
.channel_handshake_timeout(&p2p_settings.active_profiles.first().unwrap())
|
||||
as u32,
|
||||
),
|
||||
);
|
||||
self.add_setting(
|
||||
"net.channel_heartbeat_interval",
|
||||
PropertyValue::Uint32(p2p_settings.channel_heartbeat_interval as u32),
|
||||
PropertyValue::Uint32(
|
||||
p2p_settings
|
||||
.channel_heartbeat_interval(&p2p_settings.active_profiles.first().unwrap())
|
||||
as u32,
|
||||
),
|
||||
);
|
||||
self.add_setting(
|
||||
"net.outbound_peer_discovery_cooloff_time",
|
||||
@@ -278,21 +291,24 @@ impl PluginSettings {
|
||||
p2p_settings.inbound_connections =
|
||||
self.get_setting("net.inbound_connections").unwrap().get_property_u32("value").unwrap()
|
||||
as usize;
|
||||
p2p_settings.outbound_connect_timeout = self
|
||||
.get_setting("net.outbound_connect_timeout")
|
||||
.unwrap()
|
||||
.get_property_u32("value")
|
||||
.unwrap() as u64;
|
||||
p2p_settings.channel_handshake_timeout = self
|
||||
.get_setting("net.channel_handshake_timeout")
|
||||
.unwrap()
|
||||
.get_property_u32("value")
|
||||
.unwrap() as u64;
|
||||
p2p_settings.channel_heartbeat_interval = self
|
||||
.get_setting("net.channel_heartbeat_interval")
|
||||
.unwrap()
|
||||
.get_property_u32("value")
|
||||
.unwrap() as u64;
|
||||
//TODO: Update this when multiple active_profiles at a time is supported
|
||||
if let Some(profile) = p2p_settings.profiles.get_mut(p2p_settings.active_profiles.first().unwrap()) {
|
||||
profile.outbound_connect_timeout = self
|
||||
.get_setting("net.outbound_connect_timeout")
|
||||
.unwrap()
|
||||
.get_property_u32("value")
|
||||
.unwrap() as u64;
|
||||
profile.channel_handshake_timeout = self
|
||||
.get_setting("net.channel_handshake_timeout")
|
||||
.unwrap()
|
||||
.get_property_u32("value")
|
||||
.unwrap() as u64;
|
||||
profile.channel_heartbeat_interval = self
|
||||
.get_setting("net.channel_heartbeat_interval")
|
||||
.unwrap()
|
||||
.get_property_u32("value")
|
||||
.unwrap() as u64;
|
||||
}
|
||||
p2p_settings.outbound_peer_discovery_cooloff_time = self
|
||||
.get_setting("net.outbound_peer_discovery_cooloff_time")
|
||||
.unwrap()
|
||||
|
||||
Reference in New Issue
Block a user