typo and bugfixes
This commit is contained in:
parent
8fbd49f0e6
commit
58ed4baff1
|
@ -139,12 +139,12 @@ function askForConfig(answers, mainCb) {
|
|||
rl.question('relay [default: telebit.cloud]: ', function (relay) {
|
||||
// TODO parse and check https://{{relay}}/.well-known/telebit.cloud/directives.json
|
||||
if (!relay) { relay = 'telebit.cloud'; }
|
||||
answers.relay = relay.trim();
|
||||
var urlstr = common.parseUrl(answers.relay) + common.apiDirectory;
|
||||
relay = relay.trim();
|
||||
var urlstr = common.parseUrl(relay) + common.apiDirectory;
|
||||
common.urequest({ url: urlstr, json: true }, function (err, resp, body) {
|
||||
if (err) {
|
||||
console.error("[Network Error] Failed to retrieve '" + urlstr + "'");
|
||||
console.error(e);
|
||||
console.error(err);
|
||||
askRelay(cb);
|
||||
return;
|
||||
}
|
||||
|
@ -168,6 +168,7 @@ function askForConfig(answers, mainCb) {
|
|||
if (body.pair_request) {
|
||||
answers._can_pair = true;
|
||||
}
|
||||
answers.relay = relay;
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -40,17 +40,18 @@ common.parseUrl = function (hostname) {
|
|||
|
||||
common.apiDirectory = '_apis/telebit.cloud/index.json';
|
||||
common.urequest = function (opts, cb) {
|
||||
var https = require('https');
|
||||
// request.js behavior:
|
||||
// encoding: null + json ? unknown
|
||||
// json => attempt to parse, fail silently
|
||||
// encoding => buffer.toString(encoding)
|
||||
// null === encoding => Buffer.concat(buffers)
|
||||
https.get(opts, function (resp) {
|
||||
https.get(opts.url, function (resp) {
|
||||
var encoding = opts.encoding;
|
||||
if (null === encoding) {
|
||||
resp._body = [];
|
||||
} else {
|
||||
resp._body = '';
|
||||
resp.body = '';
|
||||
}
|
||||
if (!resp.headers['content-length'] || 0 === parseInt(resp.headers['content-length'], 10)) {
|
||||
cb(resp);
|
||||
|
|
Loading…
Reference in New Issue