From f2e60dae5e47016cf01d2a72cb5f57b4e1b98f0a Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 18 Oct 2018 01:11:54 -0600 Subject: [PATCH] wip i18n cli --- bin/telebit-remote.js | 13 +++++-------- bin/telebitd.js | 6 ++++++ lib/en-us.toml | 8 ++++++++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/bin/telebit-remote.js b/bin/telebit-remote.js index b6fcb3c..3ef5ebc 100755 --- a/bin/telebit-remote.js +++ b/bin/telebit-remote.js @@ -123,13 +123,10 @@ function askForConfig(state, mainCb) { return; } if (200 !== resp.statusCode || (Buffer.isBuffer(body) || 'object' !== typeof body) || !body.api_host) { - console.warn("==================="); - console.warn(" WARNING "); - console.warn("==================="); - console.warn(""); - console.warn("[" + resp.statusCode + "] '" + urlstr + "'"); - console.warn("This server does not describe a current telebit version (but it may still work)."); - console.warn(""); + console.warn(TPLS.remote.setup.fail_relay_check + .replace(/{{\s*status_code\s*}}/, resp.statusCode) + .replace(/{{\s*url\s*}}/, urlstr) + ); console.warn(body); } else if (body && body.pair_request) { state._can_pair = true; @@ -158,7 +155,7 @@ function askForConfig(state, mainCb) { } ]; var standardSet = [ - // There are questions that we need to aks in the CLI + // There are questions that we need to ask in the CLI // if we can't guarantee that they are being asked in the web interface function askAgree(cb) { if (state.config.agreeTos) { cb(); return; } diff --git a/bin/telebitd.js b/bin/telebitd.js index 006cc41..10071d7 100755 --- a/bin/telebitd.js +++ b/bin/telebitd.js @@ -400,6 +400,12 @@ function handleApi(req, res) { res.end('{"error":{"message":"module \'init\' needs more arguments"}}'); return; } + if (!Array.isArray(opts.body)) { + // TODO + res.statusCode = 500; + res.end('{"error":{"message":"[internal error (our fault)] module \'init\' expected an array"}}'); + return; + } // relay, email, agree_tos, servernames, ports // opts.body.forEach(function (opt) { diff --git a/lib/en-us.toml b/lib/en-us.toml index 21d77e7..161d6c9 100644 --- a/lib/en-us.toml +++ b/lib/en-us.toml @@ -476,5 +476,13 @@ By using Telebit you agree to: Enter your email to agree and login/create your account: " +fail_relay_check = "=================== + WARNING +=================== + +[{{status_code}}] '{{url}}' +This server does not describe a current telebit version (but it may still work). +" + [daemon] version = "telebit daemon v{version}"