diff --git a/ddns-client.js b/ddns-client.js index 1bc0f1c..76927e1 100755 --- a/ddns-client.js +++ b/ddns-client.js @@ -8,7 +8,7 @@ var cli = require('cli'); cli.parse({ service: [ 's', 'The service to use for updates i.e. ns1.example.org', 'string' ] , hostname: [ 'h', 'The hostname you wish to update i.e. example.com', 'string' ] -, pathname: [ 'h', 'The api route to which to POST i.e. /api/ddns', 'string', '/api/com.daplie.dns/ddns' ] +, pathname: [ false, 'The api route to which to POST i.e. /api/ddns', 'string', '/api/com.daplie.dns/ddns' ] , type: [ 't', 'The record type i.e. A, AAAA, MX, CNAME, ANAME, FWD, etc', 'string', 'A' ] , priority: [ 'p', 'The priority (for MX and other records)', 'string' ] , port: [ false, 'The port (default https/443)', 'number', 443 ] @@ -52,7 +52,9 @@ cli.main(function (args, options) { , "value": options.answer , "type": options.type , "priority": options.priority - , "token": options.token + , "token": options.token // device should go here? + //, "ttl": options.ttl + //, "device": '' } ] }).then(function (data) { @@ -67,5 +69,9 @@ cli.main(function (args, options) { console.log(JSON.stringify(data, null, ' ')); console.log('Test with'); console.log('dig ' + options.hostname + ' ' + options.type); + }, function (err) { + console.error('[DDNS CLIENT]'); + console.error(err.stack); + console.error(err.data); }); }); diff --git a/holepunch/helpers/update-ip.js b/holepunch/helpers/update-ip.js index b1a7c53..0432987 100644 --- a/holepunch/helpers/update-ip.js +++ b/holepunch/helpers/update-ip.js @@ -38,13 +38,6 @@ module.exports.update = function (opts) { options.ca = opts.cacert; } - options.ca = (options.ca||[]).map(function (str) { - if ('string' === typeof str && str.length < 1000) { - str = fs.readFileAsync(str); - } - return str; - }); - if (opts.token || opts.jwt) { options.headers.Authorization = 'Bearer ' + (opts.token || opts.jwt); } @@ -53,6 +46,13 @@ module.exports.update = function (opts) { options.rejectUnauthorized = false; } + options.ca = (options.ca||[]).map(function (str) { + if ('string' === typeof str && str.length < 1000) { + str = fs.readFileAsync(str); + } + return str; + }); + return PromiseA.all(options.ca).then(function (cas) { options.ca = cas; options.agent = new https.Agent(options);