mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-02-25 18:55:38 -06:00
add default veilid config to the api
This commit is contained in:
@@ -58,136 +58,135 @@ int getRemoteMaxStorageSpaceMb() {
|
||||
return 256;
|
||||
}
|
||||
|
||||
Future<VeilidConfig> getDefaultVeilidConfig(String programName) async {
|
||||
// ignore: do_not_use_environment
|
||||
const bootstrap = String.fromEnvironment('BOOTSTRAP');
|
||||
return VeilidConfig(
|
||||
programName: programName,
|
||||
namespace: '',
|
||||
capabilities: const VeilidConfigCapabilities(disable: []),
|
||||
protectedStore: const VeilidConfigProtectedStore(
|
||||
allowInsecureFallback: false,
|
||||
alwaysUseInsecureStorage: false,
|
||||
directory: '',
|
||||
delete: false,
|
||||
deviceEncryptionKeyPassword: '',
|
||||
),
|
||||
tableStore: VeilidConfigTableStore(
|
||||
directory: kIsWeb
|
||||
? ''
|
||||
: p.join((await getApplicationSupportDirectory()).absolute.path,
|
||||
'table_store'),
|
||||
delete: false,
|
||||
),
|
||||
blockStore: VeilidConfigBlockStore(
|
||||
directory: kIsWeb
|
||||
? ''
|
||||
: 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,
|
||||
Future<VeilidConfig> getDefaultVeilidConfig(String programName,
|
||||
{String bootstrap = ''}) async =>
|
||||
VeilidConfig(
|
||||
programName: programName,
|
||||
namespace: '',
|
||||
capabilities: const VeilidConfigCapabilities(disable: []),
|
||||
protectedStore: const VeilidConfigProtectedStore(
|
||||
allowInsecureFallback: false,
|
||||
alwaysUseInsecureStorage: false,
|
||||
directory: '',
|
||||
delete: false,
|
||||
deviceEncryptionKeyPassword: '',
|
||||
),
|
||||
rpc: const VeilidConfigRPC(
|
||||
concurrency: 0,
|
||||
queueSize: 1024,
|
||||
maxTimestampBehindMs: 10000,
|
||||
maxTimestampAheadMs: 10000,
|
||||
timeoutMs: 5000,
|
||||
maxRouteHopCount: 4,
|
||||
defaultRouteHopCount: 1,
|
||||
tableStore: VeilidConfigTableStore(
|
||||
directory: kIsWeb
|
||||
? ''
|
||||
: p.join((await getApplicationSupportDirectory()).absolute.path,
|
||||
'table_store'),
|
||||
delete: false,
|
||||
),
|
||||
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: '',
|
||||
blockStore: VeilidConfigBlockStore(
|
||||
directory: kIsWeb
|
||||
? ''
|
||||
: p.join((await getApplicationSupportDirectory()).absolute.path,
|
||||
'block_store'),
|
||||
delete: false,
|
||||
),
|
||||
network: VeilidConfigNetwork(
|
||||
connectionInitialTimeoutMs: 2000,
|
||||
),
|
||||
application: const VeilidConfigApplication(
|
||||
https: VeilidConfigHTTPS(
|
||||
enabled: false,
|
||||
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: '',
|
||||
path: '',
|
||||
),
|
||||
http: VeilidConfigHTTP(
|
||||
enabled: false,
|
||||
tcp: VeilidConfigTCP(
|
||||
connect: !kIsWeb,
|
||||
listen: !kIsWeb,
|
||||
maxConnections: 32,
|
||||
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',
|
||||
),
|
||||
ws: VeilidConfigWS(
|
||||
connect: true,
|
||||
listen: !kIsWeb,
|
||||
maxConnections: 32,
|
||||
listenAddress: '',
|
||||
path: 'ws',
|
||||
),
|
||||
wss: VeilidConfigWSS(
|
||||
connect: true,
|
||||
listen: false,
|
||||
maxConnections: 32,
|
||||
listenAddress: '',
|
||||
path: 'ws',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -162,5 +162,6 @@ abstract class Veilid {
|
||||
Timestamp now();
|
||||
String veilidVersionString();
|
||||
VeilidVersion veilidVersion();
|
||||
String defaultVeilidConfig();
|
||||
Future<String> debug(String command);
|
||||
}
|
||||
|
||||
@@ -235,6 +235,9 @@ final class VeilidVersionFFI extends Struct {
|
||||
|
||||
typedef _VeilidVersionDart = VeilidVersionFFI Function();
|
||||
|
||||
// fn default_veilid_config() -> *mut c_char
|
||||
typedef _DefaultVeilidConfigDart = Pointer<Utf8> Function();
|
||||
|
||||
// Async message types
|
||||
const int messageOk = 0;
|
||||
const int messageErr = 1;
|
||||
@@ -1388,7 +1391,9 @@ class VeilidFFI extends Veilid {
|
||||
_veilidVersionString = dylib.lookupFunction<Pointer<Utf8> Function(),
|
||||
_VeilidVersionStringDart>('veilid_version_string'),
|
||||
_veilidVersion = dylib.lookupFunction<VeilidVersionFFI Function(),
|
||||
_VeilidVersionDart>('veilid_version') {
|
||||
_VeilidVersionDart>('veilid_version'),
|
||||
_defaultVeilidConfig = dylib.lookupFunction<Pointer<Utf8> Function(),
|
||||
_DefaultVeilidConfigDart>('default_veilid_config') {
|
||||
// Get veilid_flutter initializer
|
||||
final initializeVeilidFlutter = _dylib.lookupFunction<
|
||||
Void Function(Pointer<_DartPostCObject>),
|
||||
@@ -1481,6 +1486,7 @@ class VeilidFFI extends Veilid {
|
||||
final _DebugDart _debug;
|
||||
final _VeilidVersionStringDart _veilidVersionString;
|
||||
final _VeilidVersionDart _veilidVersion;
|
||||
final _DefaultVeilidConfigDart _defaultVeilidConfig;
|
||||
|
||||
@override
|
||||
void initializeVeilidCore(Map<String, dynamic> platformConfigJson) {
|
||||
@@ -1714,4 +1720,12 @@ class VeilidFFI extends Veilid {
|
||||
version.patch,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String defaultVeilidConfig() {
|
||||
final defaultVeilidConfig = _defaultVeilidConfig();
|
||||
final ret = defaultVeilidConfig.toDartString();
|
||||
_freeString(defaultVeilidConfig);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,4 +705,8 @@ class VeilidJS extends Veilid {
|
||||
return VeilidVersion(jsonVersion['major'] as int,
|
||||
jsonVersion['minor'] as int, jsonVersion['patch'] as int);
|
||||
}
|
||||
|
||||
@override
|
||||
String defaultVeilidConfig() =>
|
||||
js_util.callMethod(wasm, 'default_veilid_config', []);
|
||||
}
|
||||
|
||||
@@ -1765,3 +1765,8 @@ pub extern "C" fn veilid_version() -> VeilidVersion {
|
||||
patch,
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn default_veilid_config() -> *mut c_char {
|
||||
veilid_core::default_veilid_config().into_ffi_value()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user