minor bugfixes
This commit is contained in:
parent
aa53b18a9d
commit
b9537f8419
87
manager.js
87
manager.js
|
@ -17,9 +17,7 @@ Manage.create = function(opts) {
|
|||
}
|
||||
if (!opts.configFile) {
|
||||
opts.configFile = '~/.config/greenlock/manager.json';
|
||||
console.info(
|
||||
"[Manager] using default config file:\n\t'" + opts.configFile + "'"
|
||||
);
|
||||
console.info('Greenlock Manager Config File: ' + opts.configFile);
|
||||
}
|
||||
opts.configFile = opts.configFile.replace('~/', homedir + '/');
|
||||
|
||||
|
@ -29,9 +27,7 @@ Manage.create = function(opts) {
|
|||
return Manage._ping(manage, opts);
|
||||
};
|
||||
|
||||
manage._txPromise = new Promise(function(resolve) {
|
||||
resolve();
|
||||
});
|
||||
manage._txPromise = Promise.resolve();
|
||||
|
||||
manage.config = function(conf) {
|
||||
// get / set default site settings such as
|
||||
|
@ -87,7 +83,7 @@ Manage.create = function(opts) {
|
|||
config[k] = conf[k];
|
||||
});
|
||||
|
||||
return manage.save(config);
|
||||
return manage._save(config);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -129,6 +125,7 @@ Manage.create = function(opts) {
|
|||
// if the fs has changed since we last wrote, get the lastest from disk
|
||||
return Manage._getLatest(manage, opts).then(function(config) {
|
||||
// TODO move to Greenlock.add
|
||||
var subscriberEmail = args.subscriberEmail;
|
||||
var subject = args.subject || args.domain;
|
||||
var primary = subject;
|
||||
var altnames = args.altnames || args.domains;
|
||||
|
@ -160,10 +157,14 @@ Manage.create = function(opts) {
|
|||
// and to make deterministic auto-corrections
|
||||
|
||||
// TODO added, removed, moved (duplicate), changed
|
||||
site.subscriberEmail = site.subscriberEmail;
|
||||
if (subscriberEmail) {
|
||||
site.subscriberEmail = subscriberEmail;
|
||||
}
|
||||
site.subject = subject;
|
||||
site.altnames = altnames;
|
||||
site.issuedAt = site.issuedAt || 0;
|
||||
if (!site.issuedAt) {
|
||||
site.issuedAt = 0;
|
||||
}
|
||||
site.expiresAt = site.expiresAt || 0;
|
||||
site.lastAttemptAt = site.lastAttemptAt || 0;
|
||||
// re-add if this was deleted
|
||||
|
@ -183,11 +184,15 @@ Manage.create = function(opts) {
|
|||
}
|
||||
|
||||
// These should usually be empty, for most situations
|
||||
site.subscriberEmail = args.subscriberEmail;
|
||||
if (args.customerEmail) {
|
||||
site.customerEmail = args.customerEmail;
|
||||
}
|
||||
if (args.challenges) {
|
||||
site.challenges = args.challenges;
|
||||
}
|
||||
if (args.store) {
|
||||
site.store = args.store;
|
||||
console.log('[debug] save site', site);
|
||||
}
|
||||
|
||||
return manage._save(config).then(function() {
|
||||
return JSON.parse(JSON.stringify(site));
|
||||
|
@ -204,11 +209,18 @@ Manage.create = function(opts) {
|
|||
// i.e. find certs more that will expire in less than 45 days
|
||||
//args.expiresBefore = Date.now() + 45 * 24 * 60 * 60 * 1000;
|
||||
var issuedBefore = args.issuedBefore || 0;
|
||||
var expiresBefore =
|
||||
args.expiresBefore || Date.now() + 21 * 24 * 60 * 60 * 1000;
|
||||
var expiresBefore = args.expiresBefore || Infinity; //Date.now() + 21 * 24 * 60 * 60 * 1000;
|
||||
|
||||
var altnames = (args.altnames || args.domains || []).slice(0);
|
||||
if (args.servername && !altnames.includes(args.servername)) {
|
||||
altnames.push(args.servername);
|
||||
}
|
||||
if (args.subject && !altnames.includes(args.subject)) {
|
||||
altnames.push(args.subject);
|
||||
}
|
||||
|
||||
// TODO match ANY domain on any cert
|
||||
var sites = Object.keys(config.sites)
|
||||
var sites = Object.keys(config.sites || {})
|
||||
.filter(function(sub) {
|
||||
var site = config.sites[sub];
|
||||
if (
|
||||
|
@ -216,14 +228,13 @@ Manage.create = function(opts) {
|
|||
site.expiresAt < expiresBefore ||
|
||||
site.issuedAt < issuedBefore
|
||||
) {
|
||||
if (!args.subject || sub === args.subject) {
|
||||
return true;
|
||||
}
|
||||
return (site.altnames || []).some(function(name) {
|
||||
return altnames.includes(name);
|
||||
});
|
||||
}
|
||||
})
|
||||
.map(function(name) {
|
||||
var site = config.sites[name];
|
||||
console.debug('debug', site);
|
||||
return {
|
||||
subject: site.subject,
|
||||
altnames: site.altnames,
|
||||
|
@ -269,7 +280,45 @@ Manage.create = function(opts) {
|
|||
}
|
||||
|
||||
// TODO define message types
|
||||
console.info(ev, args);
|
||||
if (!manage._notify_notice) {
|
||||
console.info(
|
||||
'set greenlockOptions.notify to override the default logger'
|
||||
);
|
||||
manage._notify_notice = true;
|
||||
}
|
||||
switch (ev) {
|
||||
case 'error':
|
||||
/* falls through */
|
||||
case 'warning':
|
||||
console.error(
|
||||
'Error%s:',
|
||||
args.context ? ' ' + args.context : ''
|
||||
);
|
||||
console.error(args.message);
|
||||
if (args.description) {
|
||||
console.error(args.description);
|
||||
}
|
||||
if (args.code) {
|
||||
console.error('code:', args.code);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (/status/.test(ev)) {
|
||||
console.info(
|
||||
ev,
|
||||
args.altname || args.subject || '',
|
||||
args.status || ''
|
||||
);
|
||||
if (!args.status) {
|
||||
console.log(args);
|
||||
}
|
||||
break;
|
||||
}
|
||||
console.info(
|
||||
ev,
|
||||
'(more info available: ' + Object.keys(args).join(' ') + ')'
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
manage.errors = function(err) {
|
||||
|
|
Loading…
Reference in New Issue