diff --git a/.gitignore b/.gitignore index a4181dd..573fa1e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,4 @@ -redirects.json -Caddyfile -sites-available -sites-enabled -dyndns-token.js -vhosts -certs .*.sw* -packages -var # Logs logs diff --git a/boot/master.js b/boot/master.js index b4aa74b..ab1b2c8 100644 --- a/boot/master.js +++ b/boot/master.js @@ -14,8 +14,8 @@ var path = require('path'); //var minWorkers = 2; var numCores = 2; // Math.max(minWorkers, require('os').cpus().length); var workers = []; -var caddypath = '/usr/local/bin/caddy'; -var useCaddy = require('fs').existsSync(caddypath); +var config = require('../../config'); +var useCaddy = require('fs').existsSync(config.caddy.bin); var conf = { localPort: process.argv[2] || (useCaddy ? 4080 : 443) // system / local network , insecurePort: process.argv[3] || (useCaddy ? 80 : 80) // meh @@ -24,7 +24,7 @@ var conf = { // TODO externalInsecurePort? , locked: false // TODO XXX , ipcKey: null -, caddyfilepath: path.join(__dirname, '..', '..', 'Caddyfile') +, caddyfilepath: config.caddy.conf , sitespath: path.join(__dirname, '..', '..', 'sites-enabled') }; var state = {}; @@ -45,7 +45,6 @@ cluster.on('online', function (worker) { // TODO XXX Should these be configurable? If so, where? var certPaths = [path.join(__dirname, '..', '..', 'certs', 'live')]; var info; - var config = require('../../config'); conf.ddns = config.ddns; conf.redirects = config.redirects; @@ -87,8 +86,8 @@ cluster.on('online', function (worker) { info.conf.sqlite3Sock = conf.sqlite3Sock; // TODO get this from db config instead var config = require('../../config'); - info.conf.primaryNameserver = config.primaryNameserver; - info.conf.nameservers = config.nameservers; + info.conf.primaryNameserver = config.ddns.primaryNameserver; + info.conf.nameservers = config.ddns.nameservers; // TODO get this from db config instead info.conf.privkey = config.privkey; info.conf.pubkey = config.pubkey; diff --git a/ddns-redirects.js b/ddns-redirects.js deleted file mode 100644 index d9f6bbf..0000000 --- a/ddns-redirects.js +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env node -'use strict'; - -// TODO have a quick timeout -require('ipify')(function (err, ip) { - console.log('ip', ip); - - var path = require('path'); - // dig -p 53 @redirect-www.org pi.nadal.daplie.com A - var updateIp = require('./holepunch/helpers/update-ip.js').update; - - var redirects = require('./redirects'); - var ddns = []; - var ddnsMap = {}; - - function add(hostname) { - ddns.push({ - "name": hostname - , "answer": ip - }); - } - - redirects.forEach(function (r) { - if (!ddnsMap[r.from.hostname.toLowerCase()]) { - add(r.from.hostname); - } - if (!ddnsMap[r.to.hostname.toLowerCase()]) { - add(r.to.hostname); - } - }); - - return updateIp({ - updater: 'ns1.redirect-www.org' - , port: 65443 - , cacert: path.join(__dirname, 'certs/ca/ns1-test.root.crt.pem') - , ddns: ddns - , token: token - }).then(function (data) { - if ('string' === typeof data) { - try { - data = JSON.parse(data); - } catch(e) { - console.error('[ERROR] bad json response'); - console.error(data); - } - } - - console.log(JSON.stringify(data, null, ' ')); - console.log('Test with'); - console.log('dig <> A'); - }); -}); diff --git a/dyndns-token.sample.js b/dyndns-token.sample.js deleted file mode 100644 index b5cefe5..0000000 --- a/dyndns-token.sample.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = { token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" };