veilid/veilid-flutter/lib/default_config.dart

184 lines
4.9 KiB
Dart
Raw Normal View History

2022-12-26 21:33:48 +00:00
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart' as p;
2023-05-29 19:24:57 +00:00
import 'package:system_info2/system_info2.dart' as sysinfo;
2022-12-26 21:33:48 +00:00
import 'veilid.dart';
2023-05-29 19:24:57 +00:00
const int megaByte = 1024 * 1024;
int getLocalSubkeyCacheSize() {
if (kIsWeb) {
return 128;
}
return 1024;
}
int getLocalMaxSubkeyCacheMemoryMb() {
if (kIsWeb) {
return 256;
}
return sysinfo.SysInfo.getTotalPhysicalMemory() ~/ 32 ~/ megaByte;
}
int getRemoteSubkeyCacheSize() {
if (kIsWeb) {
return 64;
}
return 128;
}
int getRemoteMaxRecords() {
if (kIsWeb) {
return 64;
}
return 128;
}
int getRemoteMaxSubkeyCacheMemoryMb() {
if (kIsWeb) {
return 256;
}
return sysinfo.SysInfo.getTotalPhysicalMemory() ~/ 32 ~/ megaByte;
}
int getRemoteMaxStorageSpaceMb() {
if (kIsWeb) {
return 128;
}
return 256;
}
2022-12-26 21:33:48 +00:00
Future<VeilidConfig> getDefaultVeilidConfig(String programName) async {
return VeilidConfig(
programName: programName,
namespace: "",
2023-07-06 03:53:08 +00:00
capabilities: const VeilidConfigCapabilities(disable: []),
protectedStore: const VeilidConfigProtectedStore(
2022-12-26 21:33:48 +00:00
allowInsecureFallback: false,
alwaysUseInsecureStorage: false,
2023-05-29 19:24:57 +00:00
directory: "",
2022-12-26 21:33:48 +00:00
delete: false,
2023-05-30 00:40:49 +00:00
deviceEncryptionKeyPassword: "",
newDeviceEncryptionKeyPassword: null,
2022-12-26 21:33:48 +00:00
),
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,
clientWhitelistTimeoutMs: 300000,
reverseConnectionReceiptTimeMs: 5000,
holePunchReceiptTimeMs: 5000,
2023-07-06 03:53:08 +00:00
routingTable: const VeilidConfigRoutingTable(
2023-03-12 16:24:21 +00:00
nodeId: [],
nodeIdSecret: [],
bootstrap: kIsWeb
2023-06-22 21:42:34 +00:00
? ["ws://bootstrap.veilid.net:5150/ws"]
: ["bootstrap.veilid.net"],
2022-12-26 21:33:48 +00:00
limitOverAttached: 64,
limitFullyAttached: 32,
limitAttachedStrong: 16,
limitAttachedGood: 8,
limitAttachedWeak: 4,
),
2023-07-06 03:53:08 +00:00
rpc: const VeilidConfigRPC(
2022-12-26 21:33:48 +00:00
concurrency: 0,
queueSize: 1024,
maxTimestampBehindMs: 10000,
maxTimestampAheadMs: 10000,
2023-05-29 19:24:57 +00:00
timeoutMs: 5000,
2022-12-26 21:33:48 +00:00
maxRouteHopCount: 4,
defaultRouteHopCount: 1,
),
dht: VeilidConfigDHT(
2023-05-29 19:24:57 +00:00
resolveNodeTimeoutMs: 10000,
resolveNodeCount: 20,
resolveNodeFanout: 3,
maxFindNodeCount: 20,
getValueTimeoutMs: 10000,
getValueCount: 20,
getValueFanout: 3,
setValueTimeoutMs: 10000,
setValueCount: 20,
setValueFanout: 5,
minPeerCount: 20,
2023-07-19 14:07:51 +00:00
minPeerRefreshTimeMs: 60000,
2023-05-29 19:24:57 +00:00
validateDialInfoReceiptTimeMs: 2000,
localSubkeyCacheSize: getLocalSubkeyCacheSize(),
localMaxSubkeyCacheMemoryMb: getLocalMaxSubkeyCacheMemoryMb(),
remoteSubkeyCacheSize: getRemoteSubkeyCacheSize(),
remoteMaxRecords: getRemoteMaxRecords(),
remoteMaxSubkeyCacheMemoryMb: getRemoteMaxSubkeyCacheMemoryMb(),
remoteMaxStorageSpaceMb: getRemoteMaxStorageSpaceMb()),
2022-12-26 21:33:48 +00:00
upnp: true,
detectAddressChanges: true,
restrictedNatRetries: 0,
2023-07-06 03:53:08 +00:00
tls: const VeilidConfigTLS(
2022-12-26 21:33:48 +00:00
certificatePath: "",
privateKeyPath: "",
connectionInitialTimeoutMs: 2000,
),
2023-07-06 03:53:08 +00:00
application: const VeilidConfigApplication(
2022-12-26 21:33:48 +00:00
https: VeilidConfigHTTPS(
enabled: false,
listenAddress: "",
path: "",
url: null,
),
http: VeilidConfigHTTP(
enabled: false,
listenAddress: "",
path: "",
url: null,
)),
2023-07-06 03:53:08 +00:00
protocol: const VeilidConfigProtocol(
2022-12-26 21:33:48 +00:00
udp: VeilidConfigUDP(
enabled: !kIsWeb,
socketPoolSize: 0,
listenAddress: "",
publicAddress: null,
),
tcp: VeilidConfigTCP(
connect: !kIsWeb,
listen: !kIsWeb,
maxConnections: 32,
listenAddress: "",
publicAddress: null,
),
ws: VeilidConfigWS(
connect: true,
listen: !kIsWeb,
maxConnections: 16,
listenAddress: "",
path: "ws",
url: null,
),
wss: VeilidConfigWSS(
connect: true,
listen: false,
maxConnections: 16,
listenAddress: "",
path: "ws",
url: null,
),
),
),
);
}