From 9e61caaa6c2e7aff48e1de2a1f48d0a1a94fda08 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 30 Jun 2018 18:18:03 -0600 Subject: [PATCH] bugfix missing relay on init --- bin/telebit.js | 7 +++---- bin/telebitd.js | 2 +- tests/README.md | 3 +++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/telebit.js b/bin/telebit.js index 3a7bdf0..7bc35f9 100755 --- a/bin/telebit.js +++ b/bin/telebit.js @@ -494,6 +494,7 @@ function getToken(err, state) { console.error("Error while initializing config [init]:"); throw err; } + state.relay = state.config.relay; // { _otp, config: {} } common.api.token(state, { @@ -581,7 +582,7 @@ function getToken(err, state) { , end: function () { utils.putConfig('enable', [], function (err) { if (err) { console.error(err); return; } - console.info("[end] Success"); + console.info("Success"); // workaround for https://github.com/nodejs/node/issues/21319 if (state._useTty) { @@ -602,8 +603,6 @@ function getToken(err, state) { } function parseCli(/*state*/) { - //console.log(parseCli); - //console.log(argv); if (-1 !== argv.indexOf('init')) { utils.putConfig('list', []/*, function (err) { }*/); @@ -663,7 +662,6 @@ function handleConfig(err, config) { } //console.log("done questioning:", Date.now()); - state.relay = state.config.relay; if (!state.token && !state.config.token) { getToken(err, state); } else { @@ -788,6 +786,7 @@ var parsers = { state.config._otp = common.otp(); } + argv.unshift('init'); parseCb(null, state); }); } diff --git a/bin/telebitd.js b/bin/telebitd.js index 2a0f2bd..16a2229 100755 --- a/bin/telebitd.js +++ b/bin/telebitd.js @@ -175,7 +175,7 @@ function serveControlsHelper() { || 'undefined' !== typeof conf.agreeTos ) { state.config.agreeTos = conf.agreeTos || conf.agree_tos; } - state.otp = conf._otp || '0000'; // this should only be done on the client side + state.otp = conf._otp; // this should only be done on the client side state.config.relay = conf.relay || state.config.relay || ''; console.log(); console.log('conf.token', typeof conf.token, conf.token); diff --git a/tests/README.md b/tests/README.md index 6e8a418..3dda059 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,5 +1,8 @@ There are a number of conditions and whatnot that must be tested in more-or-less real-world conditions. +telebit init // fresh install +telebit init // after install complete + telebit http 3000 // have an app listening on localhost:3000 telebit http 4545 // do not have an app listening