| 352 | |
| 353 | |
| 354 | function startHyperTeleClient(pubkeybase64) { |
| 355 | |
| 356 | console.log("Starting hypertele with pubkeybase64: " + pubkeybase64); |
| 357 | |
| 358 | let pubkeyhex = "" |
| 359 | try { |
| 360 | pubkeyhex = new Buffer(pubkeybase64, 'base64').toString('hex'); |
| 361 | if (pubkeyhex.length != 64) { |
| 362 | console.log("Pubkey invalid length - it should be 32 bytes. Returning..."); |
| 363 | return; |
| 364 | } |
| 365 | } catch (e) { |
| 366 | console.log("caught error during decode of base64 pubkey"); |
| 367 | console.log(e); |
| 368 | return; |
| 369 | } |
| 370 | |
| 371 | console.log("Starting hypertele with pubkeyhex: " + pubkeyhex); |
| 372 | |
| 373 | argv.s = pubkeyhex; |
| 374 | argv.p = "45900"; |
| 375 | |
| 376 | const helpMsg = 'Usage:\nhypertele -p port_listen -u unix_socket ?-c conf.json ?-i identity.json ?-s peer_key' |
| 377 | |
| 378 | if (argv.help) { |
| 379 | console.log(helpMsg) |
| 380 | process.exit(-1) |
| 381 | } |
| 382 | |
| 383 | if (!argv.u && !+argv.p) { |
| 384 | console.error('Error: proxy port invalid') |
| 385 | process.exit(-1) |
| 386 | } |
| 387 | |
| 388 | if (argv.u && argv.p) { |
| 389 | console.error('Error: cannot listen to both a port and a Unix domain socket') |
| 390 | process.exit(-1) |
| 391 | } |
| 392 | const conf = {} |
| 393 | |
| 394 | const target = argv.u ? argv.u : +argv.p |
| 395 | |
| 396 | if (argv.s) { |
| 397 | conf.peer = libUtils.resolveHostToKey([], argv.s) |
| 398 | } |
| 399 | |
| 400 | if (argv.c) { |
| 401 | libUtils.readConf(conf, argv.c) |
| 402 | } |
| 403 | |
| 404 | if (!conf.keepAlive) { |
| 405 | conf.keepAlive = 5000 |
| 406 | } |
| 407 | |
| 408 | if (argv.compress) { |
| 409 | conf.compress = true |
| 410 | } |
| 411 | |