You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
170 lines
4.2 KiB
JavaScript
170 lines
4.2 KiB
JavaScript
"use strict";
|
|
|
|
const veilid = require("./");
|
|
const tmp = require("tmp-promise");
|
|
|
|
// let configJSON = JSON.stringify({
|
|
// program_name: "node-veilid-test",
|
|
// namespace: "",
|
|
// capabilities: {
|
|
// disable: []
|
|
// },
|
|
// core: {
|
|
// protected_store: {
|
|
// directory: "/tmp/node-veilid-test"
|
|
// }
|
|
// }
|
|
// });
|
|
|
|
let keypair = veilid.crypto_generateKeypair(veilid.CRYPTO_KIND_VLD0);
|
|
let formatted = veilid.crypto_formatKeypair(keypair);
|
|
console.log({formatted});
|
|
|
|
(async()=>{
|
|
let basePath = (await tmp.dir({ unsafeCleanup: true })).path;
|
|
// let path = veilid.makePath("/tmp/test");
|
|
// let keypair = veilid.crypto_generateKeypair(veilid.CRYPTO_KIND_VLD0);
|
|
var configJSON = JSON.stringify({
|
|
"program_name": "node-veilid-test",
|
|
"namespace": "",
|
|
"capabilities": {
|
|
"disable": []
|
|
},
|
|
"protected_store": {
|
|
"allow_insecure_fallback": true,
|
|
"always_use_insecure_storage": true,
|
|
"directory": `${basePath}/protected_store`,
|
|
"delete": false,
|
|
"device_encryption_key_password": "",
|
|
"new_device_encryption_key_password": null
|
|
},
|
|
"table_store": {
|
|
"directory": `${basePath}/table_store`,
|
|
"delete": false
|
|
},
|
|
"block_store": {
|
|
"directory": `${basePath}/block_store`,
|
|
"delete": false
|
|
},
|
|
"network": {
|
|
"connection_initial_timeout_ms": 2000,
|
|
"connection_inactivity_timeout_ms": 60000,
|
|
"max_connections_per_ip4": 32,
|
|
"max_connections_per_ip6_prefix": 32,
|
|
"max_connections_per_ip6_prefix_size": 56,
|
|
"max_connection_frequency_per_min": 128,
|
|
"client_whitelist_timeout_ms": 300000,
|
|
"reverse_connection_receipt_time_ms": 5000,
|
|
"hole_punch_receipt_time_ms": 5000,
|
|
"network_key_password": null,
|
|
"routing_table": {
|
|
"node_id": [ formatted.key ],
|
|
"node_id_secret": [ formatted.secret ],
|
|
"bootstrap": [
|
|
"bootstrap.veilid.net"
|
|
],
|
|
"limit_over_attached": 64,
|
|
"limit_fully_attached": 32,
|
|
"limit_attached_strong": 16,
|
|
"limit_attached_good": 8,
|
|
"limit_attached_weak": 4
|
|
},
|
|
"rpc": {
|
|
"concurrency": 0,
|
|
"queue_size": 1024,
|
|
"max_timestamp_behind_ms": 10000,
|
|
"max_timestamp_ahead_ms": 10000,
|
|
"timeout_ms": 5000,
|
|
"max_route_hop_count": 4,
|
|
"default_route_hop_count": 1
|
|
},
|
|
"dht": {
|
|
"max_find_node_count": 20,
|
|
"resolve_node_timeout_ms": 10000,
|
|
"resolve_node_count": 1,
|
|
"resolve_node_fanout": 4,
|
|
"get_value_timeout_ms": 10000,
|
|
"get_value_count": 3,
|
|
"get_value_fanout": 4,
|
|
"set_value_timeout_ms": 10000,
|
|
"set_value_count": 5,
|
|
"set_value_fanout": 4,
|
|
"min_peer_count": 20,
|
|
"min_peer_refresh_time_ms": 60000,
|
|
"validate_dial_info_receipt_time_ms": 2000,
|
|
"local_subkey_cache_size": 128,
|
|
"local_max_subkey_cache_memory_mb": 256,
|
|
"remote_subkey_cache_size": 1024,
|
|
"remote_max_records": 65536,
|
|
"remote_max_subkey_cache_memory_mb": 478,
|
|
"remote_max_storage_space_mb": 1000
|
|
},
|
|
"upnp": true,
|
|
"detect_address_changes": true,
|
|
"restricted_nat_retries": 0,
|
|
"tls": {
|
|
"certificate_path": `${basePath}/ssl/certs/server.crt`,
|
|
"private_key_path": `${basePath}/ssl/keys/server.key`,
|
|
"connection_initial_timeout_ms": 2000
|
|
},
|
|
"application": {
|
|
"https": {
|
|
"enabled": false,
|
|
"listen_address": ":443",
|
|
"path": "app",
|
|
"url": null
|
|
},
|
|
"http": {
|
|
"enabled": false,
|
|
"listen_address": ":80",
|
|
"path": "app",
|
|
"url": null
|
|
}
|
|
},
|
|
"protocol": {
|
|
"udp": {
|
|
"enabled": true,
|
|
"socket_pool_size": 0,
|
|
"listen_address": "",
|
|
"public_address": null
|
|
},
|
|
"tcp": {
|
|
"connect": true,
|
|
"listen": true,
|
|
"max_connections": 32,
|
|
"listen_address": "",
|
|
"public_address": null
|
|
},
|
|
"ws": {
|
|
"connect": true,
|
|
"listen": true,
|
|
"max_connections": 32,
|
|
"listen_address": "",
|
|
"path": "ws",
|
|
"url": null
|
|
},
|
|
"wss": {
|
|
"connect": true,
|
|
"listen": false,
|
|
"max_connections": 32,
|
|
"listen_address": "",
|
|
"path": "ws",
|
|
"url": null
|
|
}
|
|
}
|
|
}
|
|
}, null, 2);
|
|
|
|
console.log({configJSON});
|
|
|
|
let core = await veilid.libraryCore_fromJSON((update) => {
|
|
console.log("update::", update);
|
|
}, configJSON);
|
|
|
|
setInterval(() => {
|
|
console.log("keepalive", core);
|
|
}, 10000);
|
|
|
|
console.log({core});
|
|
})();
|