42
oracle.js
42
oracle.js
@@ -2,6 +2,7 @@
|
||||
|
||||
import { OracleNode } from './src/oracle-node.js';
|
||||
import chalk from 'chalk';
|
||||
import { readFileSync } from 'fs';
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const options = {};
|
||||
@@ -21,6 +22,26 @@ for (let i = 0; i < args.length; i++) {
|
||||
case '--position':
|
||||
options.ringPosition = parseInt(args[++i]);
|
||||
break;
|
||||
case '--ice-servers':
|
||||
try {
|
||||
options.iceServers = JSON.parse(args[++i]);
|
||||
} catch (error) {
|
||||
console.error(chalk.red('Error parsing ICE servers JSON:'), error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
break;
|
||||
case '--config':
|
||||
try {
|
||||
const configPath = args[++i];
|
||||
const configData = JSON.parse(readFileSync(configPath, 'utf8'));
|
||||
if (configData.iceServers) {
|
||||
options.iceServers = configData.iceServers;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(chalk.red('Error loading config file:'), error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
break;
|
||||
case '--help':
|
||||
console.log(`
|
||||
${chalk.yellow('Ring Network Oracle Node')}
|
||||
@@ -28,16 +49,27 @@ ${chalk.yellow('Ring Network Oracle Node')}
|
||||
Usage: node oracle.js [options]
|
||||
|
||||
Options:
|
||||
--port <port> Port to listen on (default: random)
|
||||
--id <id> Node ID (default: auto-generated)
|
||||
--bootstrap <addr> Bootstrap node address (host:port)
|
||||
--position <pos> Initial ring position (default: 0)
|
||||
--help Show this help message
|
||||
--port <port> Port to listen on (default: random)
|
||||
--id <id> Node ID (default: auto-generated)
|
||||
--bootstrap <addr> Bootstrap node address (host:port)
|
||||
--position <pos> Initial ring position (default: 0)
|
||||
--ice-servers <json> ICE servers configuration (JSON array)
|
||||
--config <file> Load configuration from JSON file
|
||||
--help Show this help message
|
||||
|
||||
Examples:
|
||||
node oracle.js --port 8080
|
||||
node oracle.js --port 8081 --bootstrap localhost:8080
|
||||
node oracle.js --id oracle1 --port 8082 --bootstrap localhost:8080
|
||||
node oracle.js --config config/ice-servers-with-turn.json --port 8080
|
||||
|
||||
ICE Servers Example:
|
||||
--ice-servers '[{"urls":"stun:stun.l.google.com:19302"},{"urls":"turn:turn.example.com:3478","username":"user","credential":"pass"}]'
|
||||
|
||||
Config File Example:
|
||||
config/ice-servers-default.json - Default STUN servers
|
||||
config/ice-servers-with-turn.json - With TURN server
|
||||
config/ice-servers-public-turn.json - Public TURN servers
|
||||
|
||||
Oracle Services:
|
||||
- network-analysis: Analyze network topology and health
|
||||
|
||||
Referencia en una nueva incidencia
Block a user