mirror of https://github.com/waku-org/js-waku.git
Get peer connection details from command line
This commit is contained in:
parent
c3cf6462cc
commit
b4e5d6d93c
|
@ -6,6 +6,7 @@ import readline from 'readline';
|
|||
import { delay } from '../build/main/test_utils/delay';
|
||||
|
||||
;(async function() {
|
||||
const opts = processArguments();
|
||||
|
||||
const waku = await Waku.create({ listenAddresses: ['/ip4/0.0.0.0/tcp/55123'] });
|
||||
|
||||
|
@ -16,17 +17,12 @@ import { delay } from '../build/main/test_utils/delay';
|
|||
});
|
||||
|
||||
console.log('Waku started');
|
||||
// Status static node
|
||||
await waku.dial('/ip4/134.209.139.210/tcp/30303/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ');
|
||||
|
||||
// Richard's node
|
||||
// await waku.dial('/ip4/134.209.113.86/tcp/9000/p2p/16Uiu2HAmVVi6Q4j7MAKVibquW8aA27UNrA4Q8Wkz9EetGViu8ZF1');
|
||||
|
||||
// await waku.dial('/ip4/0.0.0.0/tcp/60000/p2p/16Uiu2HAmDVYacyxN4t1SYBhRSTDr6nmYwuY6qWWTgagZm558rFA6')
|
||||
|
||||
if (opts.staticNode) {
|
||||
console.log(`dialing ${opts.staticNode}`);
|
||||
await waku.dial(opts.staticNode);
|
||||
await delay(100);
|
||||
|
||||
console.log('Static node has been dialed');
|
||||
}
|
||||
|
||||
await new Promise((resolve) =>
|
||||
waku.libp2p.pubsub.once('gossipsub:heartbeat', resolve)
|
||||
|
@ -54,3 +50,26 @@ import { delay } from '../build/main/test_utils/delay';
|
|||
});
|
||||
|
||||
})();
|
||||
|
||||
interface Options {
|
||||
staticNode?: string;
|
||||
}
|
||||
|
||||
function processArguments(): Options {
|
||||
let passedArgs = process.argv.slice(2);
|
||||
|
||||
let opts: Options = {};
|
||||
|
||||
while (passedArgs.length) {
|
||||
const arg = passedArgs.shift();
|
||||
switch (arg) {
|
||||
case '--staticNode':
|
||||
opts = Object.assign(opts, { staticNode: passedArgs.shift() });
|
||||
break;
|
||||
default:
|
||||
console.log(`Argument ignored: ${arg}`);
|
||||
}
|
||||
}
|
||||
|
||||
return opts;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue