mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-10-01 01:26:08 -04:00
integration test and config work
This commit is contained in:
parent
8818e63dc0
commit
a04d4e12c5
76
Cargo.lock
generated
76
Cargo.lock
generated
@ -1210,6 +1210,29 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d2fe95351b870527a5d09bf563ed3c97c0cffb87cf1c78a591bf48bb218d9aa"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-utils",
|
||||
"memoffset 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.19"
|
||||
@ -2816,9 +2839,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.152"
|
||||
version = "0.2.153"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
|
||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||
|
||||
[[package]]
|
||||
name = "libc-print"
|
||||
@ -2988,6 +3011,15 @@ dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memory_units"
|
||||
version = "0.4.0"
|
||||
@ -4015,6 +4047,26 @@ version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
|
||||
dependencies = [
|
||||
"either",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon-core"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
|
||||
dependencies = [
|
||||
"crossbeam-deque",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.16"
|
||||
@ -4824,16 +4876,17 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
|
||||
|
||||
[[package]]
|
||||
name = "sysinfo"
|
||||
version = "0.29.11"
|
||||
version = "0.30.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd727fc423c2060f6c92d9534cef765c65a6ed3f428a03d7def74a8c4348e666"
|
||||
checksum = "6746919caf9f2a85bff759535664c060109f21975c5ac2e8652e60102bd4d196"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
"ntapi",
|
||||
"once_cell",
|
||||
"winapi",
|
||||
"rayon",
|
||||
"windows 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -5670,6 +5723,7 @@ dependencies = [
|
||||
"socket2 0.5.5",
|
||||
"static_assertions",
|
||||
"stop-token",
|
||||
"sysinfo",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
@ -5696,7 +5750,7 @@ dependencies = [
|
||||
"webpki-roots 0.25.3",
|
||||
"wee_alloc",
|
||||
"winapi",
|
||||
"windows",
|
||||
"windows 0.51.1",
|
||||
"windows-permissions",
|
||||
"ws_stream_wasm",
|
||||
"x25519-dalek",
|
||||
@ -6180,6 +6234,16 @@ dependencies = [
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be"
|
||||
dependencies = [
|
||||
"windows-core 0.52.0",
|
||||
"windows-targets 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.51.1"
|
||||
|
@ -151,6 +151,7 @@ nix = "0.27.1"
|
||||
|
||||
# System
|
||||
async-std = { version = "1.12.0", features = ["unstable"], optional = true }
|
||||
sysinfo = { version = "^0.30.6" }
|
||||
tokio = { version = "1.35.0", features = ["full"], optional = true }
|
||||
tokio-util = { version = "0.7.10", features = ["compat"], optional = true }
|
||||
tokio-stream = { version = "0.1.14", features = ["net"], optional = true }
|
||||
|
@ -1,7 +1,22 @@
|
||||
use crate::*;
|
||||
use directories::ProjectDirs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(not(target_arch = "wasm32"))] {
|
||||
use sysinfo::System;
|
||||
use lazy_static::*;
|
||||
use directories::ProjectDirs;
|
||||
|
||||
lazy_static! {
|
||||
static ref SYSTEM:System = {
|
||||
sysinfo::System::new_with_specifics(
|
||||
sysinfo::RefreshKind::new().with_memory(sysinfo::MemoryRefreshKind::everything()),
|
||||
)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
pub type ConfigCallbackReturn = VeilidAPIResult<Box<dyn core::any::Any + Send>>;
|
||||
pub type ConfigCallback = Arc<dyn Fn(String) -> ConfigCallbackReturn + Send + Sync>;
|
||||
@ -103,8 +118,15 @@ pub struct VeilidConfigUDP {
|
||||
|
||||
impl Default for VeilidConfigUDP {
|
||||
fn default() -> Self {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_arch = "wasm32")] {
|
||||
let enabled = false;
|
||||
} else {
|
||||
let enabled = true;
|
||||
}
|
||||
}
|
||||
Self {
|
||||
enabled: true,
|
||||
enabled,
|
||||
socket_pool_size: 0,
|
||||
listen_address: String::from(""),
|
||||
public_address: None,
|
||||
@ -135,9 +157,18 @@ pub struct VeilidConfigTCP {
|
||||
|
||||
impl Default for VeilidConfigTCP {
|
||||
fn default() -> Self {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_arch = "wasm32")] {
|
||||
let connect = false;
|
||||
let listen = false;
|
||||
} else {
|
||||
let connect = true;
|
||||
let listen = true;
|
||||
}
|
||||
}
|
||||
Self {
|
||||
connect: true,
|
||||
listen: true,
|
||||
connect,
|
||||
listen,
|
||||
max_connections: 32,
|
||||
listen_address: String::from(""),
|
||||
public_address: None,
|
||||
@ -151,7 +182,7 @@ impl Default for VeilidConfigTCP {
|
||||
/// ws:
|
||||
/// connect: true
|
||||
/// listen: true
|
||||
/// max_connections: 16
|
||||
/// max_connections: 32
|
||||
/// listen_address: ':5150'
|
||||
/// path: 'ws'
|
||||
/// url: 'ws://localhost:5150/ws'
|
||||
@ -171,10 +202,19 @@ pub struct VeilidConfigWS {
|
||||
|
||||
impl Default for VeilidConfigWS {
|
||||
fn default() -> Self {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_arch = "wasm32")] {
|
||||
let connect = true;
|
||||
let listen = false;
|
||||
} else {
|
||||
let connect = true;
|
||||
let listen = true;
|
||||
}
|
||||
}
|
||||
Self {
|
||||
connect: true,
|
||||
listen: true,
|
||||
max_connections: 16,
|
||||
connect,
|
||||
listen,
|
||||
max_connections: 32,
|
||||
listen_address: String::from(""),
|
||||
path: String::from("ws"),
|
||||
url: None,
|
||||
@ -188,7 +228,7 @@ impl Default for VeilidConfigWS {
|
||||
/// wss:
|
||||
/// connect: true
|
||||
/// listen: false
|
||||
/// max_connections: 16
|
||||
/// max_connections: 32
|
||||
/// listen_address: ':5150'
|
||||
/// path: 'ws'
|
||||
/// url: ''
|
||||
@ -211,7 +251,7 @@ impl Default for VeilidConfigWSS {
|
||||
Self {
|
||||
connect: true,
|
||||
listen: false,
|
||||
max_connections: 16,
|
||||
max_connections: 32,
|
||||
listen_address: String::from(""),
|
||||
path: String::from("ws"),
|
||||
url: None,
|
||||
@ -254,28 +294,36 @@ pub struct VeilidConfigTLS {
|
||||
|
||||
impl Default for VeilidConfigTLS {
|
||||
fn default() -> Self {
|
||||
let certificate_path = get_default_ssl_directory("certs/server.crt");
|
||||
let private_key_path = get_default_ssl_directory("keys/server.key");
|
||||
Self {
|
||||
certificate_path: get_default_ssl_directory("certs/server.crt"),
|
||||
private_key_path: get_default_ssl_directory("keys/server.key"),
|
||||
certificate_path,
|
||||
private_key_path,
|
||||
connection_initial_timeout_ms: 2000,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", allow(unused_variables))]
|
||||
pub fn get_default_ssl_directory(sub_path: &str) -> String {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let default_path = PathBuf::from("/etc/veilid-server/ssl").join(sub_path);
|
||||
if default_path.exists() {
|
||||
return default_path.to_string_lossy().into();
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_arch = "wasm32")] {
|
||||
"".to_owned()
|
||||
} else {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let default_path = PathBuf::from("/etc/veilid-server/ssl").join(sub_path);
|
||||
if default_path.exists() {
|
||||
return default_path.to_string_lossy().into();
|
||||
}
|
||||
}
|
||||
ProjectDirs::from("org", "Veilid", "Veilid")
|
||||
.map(|dirs| dirs.data_local_dir().join("ssl").join(sub_path))
|
||||
.unwrap_or_else(|| PathBuf::from("./ssl").join(sub_path))
|
||||
.to_string_lossy()
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
||||
ProjectDirs::from("org", "Veilid", "Veilid")
|
||||
.map(|dirs| dirs.data_local_dir().join("ssl").join(sub_path))
|
||||
.unwrap_or_else(|| PathBuf::from("./ssl").join(sub_path))
|
||||
.to_string_lossy()
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Configure the Distributed Hash Table (DHT)
|
||||
@ -309,8 +357,33 @@ pub struct VeilidConfigDHT {
|
||||
|
||||
impl Default for VeilidConfigDHT {
|
||||
fn default() -> Self {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_arch = "wasm32")] {
|
||||
let local_subkey_cache_size = 128;
|
||||
let local_max_subkey_cache_memory_mb = 256;
|
||||
let remote_subkey_cache_size = 64;
|
||||
let remote_max_records = 64;
|
||||
let remote_max_subkey_cache_memory_mb = 256;
|
||||
let remote_max_storage_space_mb = 128;
|
||||
} else {
|
||||
let local_subkey_cache_size = 1024;
|
||||
let local_max_subkey_cache_memory_mb = if sysinfo::IS_SUPPORTED_SYSTEM {
|
||||
(SYSTEM.total_memory() / 32u64 / (1024u64 * 1024u64)) as u32
|
||||
} else {
|
||||
256
|
||||
};
|
||||
let remote_subkey_cache_size = 128;
|
||||
let remote_max_records = 128;
|
||||
let remote_max_subkey_cache_memory_mb = if sysinfo::IS_SUPPORTED_SYSTEM {
|
||||
(SYSTEM.total_memory() / 32u64 / (1024u64 * 1024u64)) as u32
|
||||
} else {
|
||||
256
|
||||
};
|
||||
let remote_max_storage_space_mb = 256;
|
||||
}
|
||||
}
|
||||
|
||||
Self {
|
||||
// Assuming some reasonable defaults
|
||||
max_find_node_count: 20,
|
||||
resolve_node_timeout_ms: 10000,
|
||||
resolve_node_count: 1,
|
||||
@ -324,12 +397,12 @@ impl Default for VeilidConfigDHT {
|
||||
min_peer_count: 20,
|
||||
min_peer_refresh_time_ms: 60000,
|
||||
validate_dial_info_receipt_time_ms: 2000,
|
||||
local_subkey_cache_size: 1024,
|
||||
local_max_subkey_cache_memory_mb: 256,
|
||||
remote_subkey_cache_size: 128,
|
||||
remote_max_records: 128,
|
||||
remote_max_subkey_cache_memory_mb: 256,
|
||||
remote_max_storage_space_mb: 256,
|
||||
local_subkey_cache_size,
|
||||
local_max_subkey_cache_memory_mb,
|
||||
remote_subkey_cache_size,
|
||||
remote_max_records,
|
||||
remote_max_subkey_cache_memory_mb,
|
||||
remote_max_storage_space_mb,
|
||||
public_watch_limit: 32,
|
||||
member_watch_limit: 8,
|
||||
max_watch_expiration_ms: 600000,
|
||||
@ -388,10 +461,18 @@ pub struct VeilidConfigRoutingTable {
|
||||
|
||||
impl Default for VeilidConfigRoutingTable {
|
||||
fn default() -> Self {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_arch = "wasm32")] {
|
||||
let bootstrap = vec!["ws://bootstrap.veilid.net:5150/ws".to_string()];
|
||||
} else {
|
||||
let bootstrap = vec!["bootstrap.veilid.net".to_string()];
|
||||
}
|
||||
}
|
||||
|
||||
Self {
|
||||
node_id: TypedKeyGroup::default(),
|
||||
node_id_secret: TypedSecretGroup::default(),
|
||||
bootstrap: vec!["bootstrap.veilid.net".to_string()],
|
||||
bootstrap,
|
||||
limit_over_attached: 64,
|
||||
limit_fully_attached: 32,
|
||||
limit_attached_strong: 16,
|
||||
@ -468,21 +549,27 @@ impl Default for VeilidConfigTableStore {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", allow(unused_variables))]
|
||||
fn get_default_store_path(store_type: &str) -> String {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let globalpath = PathBuf::from(format!("/var/db/veilid-server/{}", store_type));
|
||||
if globalpath.exists() {
|
||||
return globalpath.to_string_lossy().into();
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_arch = "wasm32")] {
|
||||
"".to_owned()
|
||||
} else {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let globalpath = PathBuf::from(format!("/var/db/veilid-server/{}", store_type));
|
||||
if globalpath.exists() {
|
||||
return globalpath.to_string_lossy().into();
|
||||
}
|
||||
}
|
||||
ProjectDirs::from("org", "Veilid", "Veilid")
|
||||
.map(|dirs| dirs.data_local_dir().to_path_buf())
|
||||
.unwrap_or_else(|| PathBuf::from("./"))
|
||||
.join(store_type)
|
||||
.to_string_lossy()
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
||||
ProjectDirs::from("org", "Veilid", "Veilid")
|
||||
.map(|dirs| dirs.data_local_dir().to_path_buf())
|
||||
.unwrap_or_else(|| PathBuf::from("./"))
|
||||
.join(store_type)
|
||||
.to_string_lossy()
|
||||
.into()
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
@ -520,7 +607,7 @@ impl Default for VeilidConfigProtectedStore {
|
||||
always_use_insecure_storage: false,
|
||||
directory: get_default_store_path("protected_store"),
|
||||
delete: false,
|
||||
device_encryption_key_password: String::from(""),
|
||||
device_encryption_key_password: "".to_owned(),
|
||||
new_device_encryption_key_password: None,
|
||||
}
|
||||
}
|
||||
|
40
veilid-flutter/example/integration_test/app_test.dart
Normal file
40
veilid-flutter/example/integration_test/app_test.dart
Normal file
@ -0,0 +1,40 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
|
||||
import 'fixtures.dart';
|
||||
import 'test_veilid_config.dart';
|
||||
|
||||
void main() {
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
group('VeilidConfig', () {
|
||||
final fixture = DefaultFixture();
|
||||
setUp(fixture.setUp);
|
||||
tearDown(fixture.tearDown);
|
||||
|
||||
test('test VeilidConfig defaults', testVeilidConfigDefaults);
|
||||
});
|
||||
|
||||
// group('end-to-end test', () {
|
||||
// testWidgets('tap on the floating action button, verify counter',
|
||||
// (tester) async {
|
||||
// // Load app widget.
|
||||
// await tester.pumpWidget(const MyApp());
|
||||
|
||||
// // Verify the counter starts at 0.
|
||||
// expect(find.text('0'), findsOneWidget);
|
||||
|
||||
// // Finds the floating action button to tap on.
|
||||
// final fab = find.byKey(const Key('increment'));
|
||||
|
||||
// // Emulate a tap on the floating action button.
|
||||
// await tester.tap(fab);
|
||||
|
||||
// // Trigger a frame.
|
||||
// await tester.pumpAndSettle();
|
||||
|
||||
// // Verify the counter increments by 1.
|
||||
// expect(find.text('1'), findsOneWidget);
|
||||
// });
|
||||
// });
|
||||
}
|
91
veilid-flutter/example/integration_test/fixtures.dart
Normal file
91
veilid-flutter/example/integration_test/fixtures.dart
Normal file
@ -0,0 +1,91 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:mutex/mutex.dart';
|
||||
import 'package:veilid/veilid.dart';
|
||||
|
||||
class DefaultFixture {
|
||||
DefaultFixture();
|
||||
|
||||
StreamSubscription<VeilidUpdate>? _updateSubscription;
|
||||
Stream<VeilidUpdate>? _updateStream;
|
||||
|
||||
static final _fixtureMutex = Mutex();
|
||||
|
||||
Future<void> setUp() async {
|
||||
await _fixtureMutex.acquire();
|
||||
|
||||
assert(_updateStream == null, 'should not set up fixture twice');
|
||||
|
||||
final Map<String, dynamic> platformConfigJson;
|
||||
if (kIsWeb) {
|
||||
const platformConfig = VeilidWASMConfig(
|
||||
logging: VeilidWASMConfigLogging(
|
||||
performance: VeilidWASMConfigLoggingPerformance(
|
||||
enabled: true,
|
||||
level: VeilidConfigLogLevel.debug,
|
||||
logsInTimings: true,
|
||||
logsInConsole: false,
|
||||
),
|
||||
api: VeilidWASMConfigLoggingApi(
|
||||
enabled: true,
|
||||
level: VeilidConfigLogLevel.info,
|
||||
)));
|
||||
platformConfigJson = platformConfig.toJson();
|
||||
} else {
|
||||
const platformConfig = VeilidFFIConfig(
|
||||
logging: VeilidFFIConfigLogging(
|
||||
terminal: VeilidFFIConfigLoggingTerminal(
|
||||
enabled: false,
|
||||
level: VeilidConfigLogLevel.debug,
|
||||
),
|
||||
otlp: VeilidFFIConfigLoggingOtlp(
|
||||
enabled: false,
|
||||
level: VeilidConfigLogLevel.trace,
|
||||
grpcEndpoint: 'localhost:4317',
|
||||
serviceName: 'Veilid Tests',
|
||||
),
|
||||
api: VeilidFFIConfigLoggingApi(
|
||||
enabled: true,
|
||||
level: VeilidConfigLogLevel.info,
|
||||
)));
|
||||
platformConfigJson = platformConfig.toJson();
|
||||
}
|
||||
Veilid.instance.initializeVeilidCore(platformConfigJson);
|
||||
|
||||
final defaultConfig = await getDefaultVeilidConfig(
|
||||
isWeb: kIsWeb, programName: 'Veilid Tests');
|
||||
|
||||
final updateStream =
|
||||
_updateStream = await Veilid.instance.startupVeilidCore(defaultConfig);
|
||||
if (_updateStream == null) {
|
||||
throw Exception('failed to start up veilid core');
|
||||
}
|
||||
|
||||
_updateSubscription = updateStream.listen((update) {
|
||||
if (update is VeilidLog) {
|
||||
} else if (update is VeilidUpdateAttachment) {
|
||||
} else if (update is VeilidUpdateConfig) {
|
||||
} else if (update is VeilidUpdateNetwork) {
|
||||
} else if (update is VeilidAppMessage) {
|
||||
} else if (update is VeilidAppCall) {
|
||||
} else if (update is VeilidUpdateValueChange) {
|
||||
} else {
|
||||
throw Exception('unexpected update: $update');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> tearDown() async {
|
||||
assert(_updateStream != null, 'should not tearDown without setUp');
|
||||
|
||||
final cancelFut = _updateSubscription?.cancel();
|
||||
await Veilid.instance.shutdownVeilidCore();
|
||||
await cancelFut;
|
||||
|
||||
_updateSubscription = null;
|
||||
_updateStream = null;
|
||||
|
||||
_fixtureMutex.release();
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:veilid/default_config.dart';
|
||||
|
||||
Future<void> testVeilidConfigDefaults() async {
|
||||
const programName = 'Veilid Tests';
|
||||
final defaultConfig =
|
||||
await getDefaultVeilidConfig(isWeb: kIsWeb, programName: programName);
|
||||
assert(defaultConfig.programName == programName, 'program name should match');
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:veilid/veilid.dart';
|
||||
import 'package:loggy/loggy.dart';
|
||||
@ -109,7 +110,8 @@ class _MyAppState extends State<MyApp> with UiLoggy {
|
||||
|
||||
Future<void> toggleStartup(bool startup) async {
|
||||
if (startup && !_startedUp) {
|
||||
var config = await getDefaultVeilidConfig("Veilid Plugin Example");
|
||||
var config = await getDefaultVeilidConfig(
|
||||
isWeb: kIsWeb, programName: "Veilid Plugin Example");
|
||||
if (const String.fromEnvironment("DELETE_TABLE_STORE") == "1") {
|
||||
config = config.copyWith(
|
||||
tableStore: config.tableStore.copyWith(delete: true));
|
||||
|
@ -11,30 +11,24 @@ void veilidInit() {
|
||||
enabled: true,
|
||||
level: VeilidConfigLogLevel.debug,
|
||||
logsInTimings: true,
|
||||
logsInConsole: false,
|
||||
ignoreLogTargets: []),
|
||||
logsInConsole: false),
|
||||
api: VeilidWASMConfigLoggingApi(
|
||||
enabled: true,
|
||||
level: VeilidConfigLogLevel.info,
|
||||
ignoreLogTargets: [])));
|
||||
enabled: true, level: VeilidConfigLogLevel.info)));
|
||||
Veilid.instance.initializeVeilidCore(platformConfig.toJson());
|
||||
} else {
|
||||
var platformConfig = const VeilidFFIConfig(
|
||||
logging: VeilidFFIConfigLogging(
|
||||
terminal: VeilidFFIConfigLoggingTerminal(
|
||||
enabled: false,
|
||||
level: VeilidConfigLogLevel.debug,
|
||||
ignoreLogTargets: []),
|
||||
enabled: false,
|
||||
level: VeilidConfigLogLevel.debug,
|
||||
),
|
||||
otlp: VeilidFFIConfigLoggingOtlp(
|
||||
enabled: false,
|
||||
level: VeilidConfigLogLevel.trace,
|
||||
grpcEndpoint: "localhost:4317",
|
||||
serviceName: "VeilidExample",
|
||||
ignoreLogTargets: []),
|
||||
serviceName: "VeilidExample"),
|
||||
api: VeilidFFIConfigLoggingApi(
|
||||
enabled: true,
|
||||
level: VeilidConfigLogLevel.info,
|
||||
ignoreLogTargets: [])));
|
||||
enabled: true, level: VeilidConfigLogLevel.info)));
|
||||
Veilid.instance.initializeVeilidCore(platformConfig.toJson());
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ EXTERNAL SOURCES:
|
||||
SPEC CHECKSUMS:
|
||||
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
|
||||
macos_window_utils: 933f91f64805e2eb91a5bd057cf97cd097276663
|
||||
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
|
||||
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
|
||||
veilid: a54f57b7bcf0e4e072fe99272d76ca126b2026d0
|
||||
|
||||
PODFILE CHECKSUM: 73d2f470b1d889e27fcfda1d6e6efec66f98af3f
|
||||
|
||||
COCOAPODS: 1.12.1
|
||||
COCOAPODS: 1.15.2
|
||||
|
@ -208,7 +208,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0920;
|
||||
LastUpgradeCheck = 1430;
|
||||
LastUpgradeCheck = 1510;
|
||||
ORGANIZATIONNAME = "";
|
||||
TargetAttributes = {
|
||||
33CC10EC2044A3C60003C045 = {
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1430"
|
||||
LastUpgradeVersion = "1510"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
@ -105,6 +105,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.0"
|
||||
fixnum:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -126,14 +134,19 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
flutter_driver:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_lints
|
||||
sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
|
||||
sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.3"
|
||||
version: "3.0.1"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@ -152,6 +165,11 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.1"
|
||||
fuchsia_remote_debug_protocol:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
globbing:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -160,6 +178,11 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
integration_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
json_annotation:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -196,10 +219,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: lints
|
||||
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
|
||||
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
version: "3.0.0"
|
||||
loggy:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -240,6 +263,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.11.0"
|
||||
mutex:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: mutex
|
||||
sha256: "8827da25de792088eb33e572115a5eb0d61d61a3c01acbc8bcbe76ed78f1a1f2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
path:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -304,14 +335,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.4"
|
||||
platform_info:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform_info
|
||||
sha256: "012e73712166cf0b56d3eb95c0d33491f56b428c169eca385f036448474147e4"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.0"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -320,6 +343,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.8"
|
||||
process:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: process
|
||||
sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.2"
|
||||
quiver:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -365,6 +396,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
sync_http:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sync_http
|
||||
sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.1"
|
||||
system_info2:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -428,6 +467,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "13.0.0"
|
||||
webdriver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webdriver
|
||||
sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -448,10 +495,18 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: xterm
|
||||
sha256: "6a02b15d03152b8186e12790902ff28c8a932fc441e89fa7255a7491661a8e69"
|
||||
sha256: "168dfedca77cba33fdb6f52e2cd001e9fde216e398e89335c19b524bb22da3a2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.5.0"
|
||||
version: "4.0.0"
|
||||
zmodem:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: zmodem
|
||||
sha256: "3b7e5b29f3a7d8aee472029b05165a68438eff2f3f7766edf13daba1e297adbf"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.0.6"
|
||||
sdks:
|
||||
dart: ">=3.3.0-279.1.beta <4.0.0"
|
||||
flutter: ">=3.10.6"
|
||||
flutter: ">=3.19.1"
|
||||
|
@ -31,27 +31,21 @@ dependencies:
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.2
|
||||
loggy: ^2.0.1+1
|
||||
path_provider: ^2.0.11
|
||||
path: ^1.8.1
|
||||
xterm: ^3.4.0
|
||||
flutter_acrylic: ^1.0.0+2
|
||||
ansicolor: ^2.0.1
|
||||
cupertino_icons: ^1.0.6
|
||||
loggy: ^2.0.3
|
||||
path_provider: ^2.1.2
|
||||
path: ^1.9.0
|
||||
xterm: ^4.0.0
|
||||
flutter_acrylic: ^1.1.3
|
||||
ansicolor: ^2.0.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
# The "flutter_lints" package below contains a set of recommended lints to
|
||||
# encourage good coding practices. The lint set provided by the package is
|
||||
# activated in the `analysis_options.yaml` file located at the root of your
|
||||
# package. See that file for information about deactivating specific lint
|
||||
# rules and activating additional ones.
|
||||
flutter_lints: ^2.0.1
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
integration_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^3.0.1
|
||||
mutex: ^3.1.0
|
||||
|
||||
# The following section is specific to Flutter.
|
||||
flutter:
|
||||
|
@ -1,192 +1,49 @@
|
||||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:system_info2/system_info2.dart' as sysinfo;
|
||||
import 'package:system_info_plus/system_info_plus.dart';
|
||||
|
||||
import 'veilid.dart';
|
||||
|
||||
const int megaByte = 1024 * 1024;
|
||||
|
||||
int getLocalSubkeyCacheSize() {
|
||||
if (kIsWeb) {
|
||||
return 128;
|
||||
}
|
||||
return 1024;
|
||||
}
|
||||
|
||||
Future<int> getLocalMaxSubkeyCacheMemoryMb() async {
|
||||
if (kIsWeb) {
|
||||
return 256;
|
||||
}
|
||||
if (Platform.isIOS || Platform.isAndroid) {
|
||||
return (await SystemInfoPlus.physicalMemory ?? 2048) ~/ 32;
|
||||
}
|
||||
return sysinfo.SysInfo.getTotalPhysicalMemory() ~/ 32 ~/ megaByte;
|
||||
}
|
||||
|
||||
int getRemoteSubkeyCacheSize() {
|
||||
if (kIsWeb) {
|
||||
return 64;
|
||||
}
|
||||
return 128;
|
||||
}
|
||||
|
||||
int getRemoteMaxRecords() {
|
||||
if (kIsWeb) {
|
||||
return 64;
|
||||
}
|
||||
return 128;
|
||||
}
|
||||
|
||||
Future<int> getRemoteMaxSubkeyCacheMemoryMb() async {
|
||||
if (kIsWeb) {
|
||||
return 256;
|
||||
}
|
||||
if (Platform.isIOS || Platform.isAndroid) {
|
||||
return (await SystemInfoPlus.physicalMemory ?? 2048) ~/ 32;
|
||||
}
|
||||
return sysinfo.SysInfo.getTotalPhysicalMemory() ~/ 32 ~/ megaByte;
|
||||
}
|
||||
|
||||
int getRemoteMaxStorageSpaceMb() {
|
||||
if (kIsWeb) {
|
||||
return 128;
|
||||
}
|
||||
return 256;
|
||||
}
|
||||
|
||||
Future<VeilidConfig> getDefaultVeilidConfig(String programName,
|
||||
{String bootstrap = ''}) async =>
|
||||
VeilidConfig(
|
||||
Future<VeilidConfig> getDefaultVeilidConfig({
|
||||
required bool isWeb,
|
||||
required String programName,
|
||||
String bootstrap = '',
|
||||
String namespace = '',
|
||||
String deviceEncryptionKeyPassword = '',
|
||||
String? newDeviceEncryptionKeyPassword,
|
||||
String networkKeyPassword = '',
|
||||
}) async {
|
||||
final defaultConfigStr = Veilid.instance.defaultVeilidConfig();
|
||||
final defaultConfig = VeilidConfig.fromJson(jsonDecode(defaultConfigStr));
|
||||
return defaultConfig.copyWith(
|
||||
programName: programName,
|
||||
namespace: '',
|
||||
capabilities: const VeilidConfigCapabilities(disable: []),
|
||||
protectedStore: const VeilidConfigProtectedStore(
|
||||
allowInsecureFallback: false,
|
||||
alwaysUseInsecureStorage: false,
|
||||
directory: '',
|
||||
delete: false,
|
||||
deviceEncryptionKeyPassword: '',
|
||||
),
|
||||
tableStore: VeilidConfigTableStore(
|
||||
directory: kIsWeb
|
||||
namespace: namespace,
|
||||
tableStore: defaultConfig.tableStore.copyWith(
|
||||
directory: isWeb
|
||||
? ''
|
||||
: p.join((await getApplicationSupportDirectory()).absolute.path,
|
||||
'table_store'),
|
||||
delete: false,
|
||||
),
|
||||
blockStore: VeilidConfigBlockStore(
|
||||
directory: kIsWeb
|
||||
blockStore: defaultConfig.blockStore.copyWith(
|
||||
directory: isWeb
|
||||
? ''
|
||||
: p.join((await getApplicationSupportDirectory()).absolute.path,
|
||||
'block_store'),
|
||||
delete: false,
|
||||
),
|
||||
network: VeilidConfigNetwork(
|
||||
connectionInitialTimeoutMs: 2000,
|
||||
connectionInactivityTimeoutMs: 60000,
|
||||
maxConnectionsPerIp4: 32,
|
||||
maxConnectionsPerIp6Prefix: 32,
|
||||
maxConnectionsPerIp6PrefixSize: 56,
|
||||
maxConnectionFrequencyPerMin: 128,
|
||||
clientAllowlistTimeoutMs: 300000,
|
||||
reverseConnectionReceiptTimeMs: 5000,
|
||||
holePunchReceiptTimeMs: 5000,
|
||||
routingTable: VeilidConfigRoutingTable(
|
||||
nodeId: [],
|
||||
nodeIdSecret: [],
|
||||
bootstrap: bootstrap.isNotEmpty
|
||||
? bootstrap.split(',')
|
||||
: (kIsWeb
|
||||
? ['ws://bootstrap.veilid.net:5150/ws']
|
||||
: ['bootstrap.veilid.net']),
|
||||
limitOverAttached: 64,
|
||||
limitFullyAttached: 32,
|
||||
limitAttachedStrong: 16,
|
||||
limitAttachedGood: 8,
|
||||
limitAttachedWeak: 4,
|
||||
),
|
||||
rpc: const VeilidConfigRPC(
|
||||
concurrency: 0,
|
||||
queueSize: 1024,
|
||||
maxTimestampBehindMs: 10000,
|
||||
maxTimestampAheadMs: 10000,
|
||||
timeoutMs: 5000,
|
||||
maxRouteHopCount: 4,
|
||||
defaultRouteHopCount: 1,
|
||||
),
|
||||
dht: VeilidConfigDHT(
|
||||
maxFindNodeCount: 20,
|
||||
resolveNodeTimeoutMs: 10000,
|
||||
resolveNodeCount: 1,
|
||||
resolveNodeFanout: 4,
|
||||
getValueTimeoutMs: 10000,
|
||||
getValueCount: 3,
|
||||
getValueFanout: 4,
|
||||
setValueTimeoutMs: 10000,
|
||||
setValueCount: 5,
|
||||
setValueFanout: 4,
|
||||
minPeerCount: 20,
|
||||
minPeerRefreshTimeMs: 60000,
|
||||
validateDialInfoReceiptTimeMs: 2000,
|
||||
localSubkeyCacheSize: getLocalSubkeyCacheSize(),
|
||||
localMaxSubkeyCacheMemoryMb: await getLocalMaxSubkeyCacheMemoryMb(),
|
||||
remoteSubkeyCacheSize: getRemoteSubkeyCacheSize(),
|
||||
remoteMaxRecords: getRemoteMaxRecords(),
|
||||
remoteMaxSubkeyCacheMemoryMb:
|
||||
await getRemoteMaxSubkeyCacheMemoryMb(),
|
||||
remoteMaxStorageSpaceMb: getRemoteMaxStorageSpaceMb(),
|
||||
publicWatchLimit: 32,
|
||||
memberWatchLimit: 8,
|
||||
maxWatchExpirationMs: 600000),
|
||||
upnp: true,
|
||||
detectAddressChanges: true,
|
||||
restrictedNatRetries: 0,
|
||||
tls: const VeilidConfigTLS(
|
||||
certificatePath: '',
|
||||
privateKeyPath: '',
|
||||
connectionInitialTimeoutMs: 2000,
|
||||
),
|
||||
application: const VeilidConfigApplication(
|
||||
https: VeilidConfigHTTPS(
|
||||
enabled: false,
|
||||
listenAddress: '',
|
||||
path: '',
|
||||
),
|
||||
http: VeilidConfigHTTP(
|
||||
enabled: false,
|
||||
listenAddress: '',
|
||||
path: '',
|
||||
)),
|
||||
protocol: const VeilidConfigProtocol(
|
||||
udp: VeilidConfigUDP(
|
||||
enabled: !kIsWeb,
|
||||
socketPoolSize: 0,
|
||||
listenAddress: '',
|
||||
),
|
||||
tcp: VeilidConfigTCP(
|
||||
connect: !kIsWeb,
|
||||
listen: !kIsWeb,
|
||||
maxConnections: 32,
|
||||
listenAddress: '',
|
||||
),
|
||||
ws: VeilidConfigWS(
|
||||
connect: true,
|
||||
listen: !kIsWeb,
|
||||
maxConnections: 32,
|
||||
listenAddress: '',
|
||||
path: 'ws',
|
||||
),
|
||||
wss: VeilidConfigWSS(
|
||||
connect: true,
|
||||
listen: false,
|
||||
maxConnections: 32,
|
||||
listenAddress: '',
|
||||
path: 'ws',
|
||||
),
|
||||
),
|
||||
protectedStore: defaultConfig.protectedStore.copyWith(
|
||||
directory: isWeb
|
||||
? ''
|
||||
: p.join((await getApplicationSupportDirectory()).absolute.path,
|
||||
'protected_store'),
|
||||
deviceEncryptionKeyPassword: deviceEncryptionKeyPassword,
|
||||
newDeviceEncryptionKeyPassword: newDeviceEncryptionKeyPassword,
|
||||
),
|
||||
);
|
||||
network: defaultConfig.network.copyWith(
|
||||
networkKeyPassword: networkKeyPassword,
|
||||
routingTable: defaultConfig.network.routingTable.copyWith(
|
||||
bootstrap: bootstrap.isNotEmpty
|
||||
? bootstrap.split(',')
|
||||
: defaultConfig.network.routingTable.bootstrap),
|
||||
dht: defaultConfig.network.dht.copyWith()));
|
||||
}
|
||||
|
@ -6,13 +6,16 @@ void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
setUp(() {});
|
||||
|
||||
tearDown(() {});
|
||||
|
||||
test('testEncodingKnownVectors', testEncodingKnownVectors);
|
||||
test('testEncodeDecodeGarbage', testEncodeDecodeGarbage);
|
||||
test('testEncodeDecodeGarbagePad', testEncodeDecodeGarbagePad);
|
||||
group('encoding', () {
|
||||
test('test encoding known vectors', testEncodingKnownVectors);
|
||||
test('test encode/decode garbage', testEncodeDecodeGarbage);
|
||||
test('test encode/decode garbage with pad', testEncodeDecodeGarbagePad);
|
||||
});
|
||||
|
||||
test('testVSR', testValueSubkeyRange);
|
||||
test('test List<ValueSubkeyRange>', testValueSubkeyRangeList);
|
||||
group('ValueSubkeyRange', () {
|
||||
test('test ValueSubkeyRange', testValueSubkeyRange);
|
||||
test('test List<ValueSubkeyRange>', testValueSubkeyRangeList);
|
||||
});
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ default-async-std = ["rt-async-std", "veilid-core/default-async-std"]
|
||||
crypto-test = ["rt-tokio", "veilid-core/crypto-test"]
|
||||
crypto-test-none = ["rt-tokio", "veilid-core/crypto-test-none"]
|
||||
|
||||
otlp-tonic = [ "opentelemetry-otlp/grpc-tonic", "opentelemetry-otlp/trace" ]
|
||||
otlp-grpc = [ "opentelemetry-otlp/grpc-sys", "opentelemetry-otlp/trace" ]
|
||||
otlp-tonic = ["opentelemetry-otlp/grpc-tonic", "opentelemetry-otlp/trace"]
|
||||
otlp-grpc = ["opentelemetry-otlp/grpc-sys", "opentelemetry-otlp/trace"]
|
||||
|
||||
rt-async-std = [
|
||||
"veilid-core/rt-async-std",
|
||||
@ -49,7 +49,7 @@ tracing-appender = "^0"
|
||||
tracing-opentelemetry = "0.21"
|
||||
# Buggy: tracing-error = "^0"
|
||||
opentelemetry = { version = "0.20" }
|
||||
opentelemetry-otlp = { version = "0.13", default-features = false, optional=true }
|
||||
opentelemetry-otlp = { version = "0.13", default-features = false, optional = true }
|
||||
opentelemetry-semantic-conventions = "0.12"
|
||||
async-std = { version = "^1", features = ["unstable"], optional = true }
|
||||
tokio = { version = "1.35.0", features = ["full", "tracing"], optional = true }
|
||||
@ -81,7 +81,7 @@ flume = { version = "^0", features = ["async"] }
|
||||
rpassword = "^7"
|
||||
hostname = "^0"
|
||||
stop-token = { version = "^0", default-features = false }
|
||||
sysinfo = { version = "^0.29.11", default-features = false }
|
||||
sysinfo = { version = "^0.30.6" }
|
||||
wg = "0.3.2"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
|
@ -7,11 +7,30 @@ use std::ffi::OsStr;
|
||||
use std::net::SocketAddr;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
use sysinfo::{DiskExt, SystemExt};
|
||||
use url::Url;
|
||||
use veilid_core::tools::*;
|
||||
use veilid_core::*;
|
||||
|
||||
use lazy_static::*;
|
||||
|
||||
lazy_static! {
|
||||
static ref SYSTEM: sysinfo::System = {
|
||||
sysinfo::System::new_with_specifics(
|
||||
sysinfo::RefreshKind::new().with_memory(sysinfo::MemoryRefreshKind::everything()),
|
||||
)
|
||||
};
|
||||
static ref DISKS: sysinfo::Disks = {
|
||||
let mut disks = sysinfo::Disks::new_with_refreshed_list();
|
||||
disks.sort_by(|a, b| {
|
||||
b.mount_point()
|
||||
.to_string_lossy()
|
||||
.len()
|
||||
.cmp(&a.mount_point().to_string_lossy().len())
|
||||
});
|
||||
disks
|
||||
};
|
||||
}
|
||||
|
||||
pub fn load_default_config() -> EyreResult<config::Config> {
|
||||
let mut default_config = String::from(
|
||||
r#"---
|
||||
@ -865,31 +884,31 @@ impl Settings {
|
||||
}
|
||||
|
||||
pub fn get_default_remote_max_subkey_cache_memory_mb() -> u32 {
|
||||
let sys = sysinfo::System::new_with_specifics(sysinfo::RefreshKind::new().with_memory());
|
||||
((sys.free_memory() / (1024u64 * 1024u64)) / 16) as u32
|
||||
if sysinfo::IS_SUPPORTED_SYSTEM {
|
||||
((SYSTEM.free_memory() / (1024u64 * 1024u64)) / 16) as u32
|
||||
} else {
|
||||
256
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_default_remote_max_storage_space_mb(inner: &SettingsInner) -> u32 {
|
||||
let mut sys = sysinfo::System::new_with_specifics(sysinfo::RefreshKind::new().with_disks());
|
||||
let dht_storage_path = inner.core.table_store.directory.clone();
|
||||
// Sort longer mount point paths first since we want the mount point closest to our table store directory
|
||||
sys.sort_disks_by(|a, b| {
|
||||
b.mount_point()
|
||||
.to_string_lossy()
|
||||
.len()
|
||||
.cmp(&a.mount_point().to_string_lossy().len())
|
||||
});
|
||||
for disk in sys.disks() {
|
||||
if dht_storage_path.starts_with(&*disk.mount_point().to_string_lossy()) {
|
||||
let available_mb = disk.available_space() / 1_000_000u64;
|
||||
if available_mb > 40_000 {
|
||||
// Default to 10GB if more than 40GB is available
|
||||
return 10_000;
|
||||
|
||||
if sysinfo::IS_SUPPORTED_SYSTEM {
|
||||
for disk in DISKS.list() {
|
||||
if dht_storage_path.starts_with(&*disk.mount_point().to_string_lossy()) {
|
||||
let available_mb = disk.available_space() / 1_000_000u64;
|
||||
if available_mb > 40_000 {
|
||||
// Default to 10GB if more than 40GB is available
|
||||
return 10_000;
|
||||
}
|
||||
// Default to 1/4 of the available space, if less than 40GB is available
|
||||
return available_mb as u32;
|
||||
}
|
||||
// Default to 1/4 of the available space, if less than 40GB is available
|
||||
return available_mb as u32;
|
||||
}
|
||||
}
|
||||
|
||||
// If we can't figure out our storage path go with 1GB of space and pray
|
||||
1_000
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user