add some more info to domain list

This commit is contained in:
AJ ONeal 2018-08-05 07:20:06 +00:00
parent 4e3e155460
commit 004908e735
2 changed files with 24 additions and 10 deletions

View File

@ -11,11 +11,13 @@ files.forEach(function (fname) {
var data;
var email;
var iat;
var mdata;
if (!/\.data$/.test(fname)) {
return;
}
data = JSON.parse(fs.readFileSync(fpath));
email = fname.replace('\.' + data.domains.join('') + '\.data', '');
mdata = JSON.parse(fs.readFileSync(path.join(basedir, email)));
if (data.iat) {
iat = new Date(data.iat).toISOString();
}
@ -23,16 +25,18 @@ files.forEach(function (fname) {
emails[email] = {
domains: []
, ports: []
, nodes: [ { issuedAt: iat, scheme: 'mailto', type: 'email', name: email } ]
, nodes: [ { createdAt: iat, scheme: 'mailto', type: 'email', name: email } ]
, jtis: []
};
}
emails[email].jtis.push(data.id);
data.domains.forEach(function (d) {
emails[email].domains.push({ issuedAt: iat, name: d });
emails[email].domains.push({ createdAt: iat, name: d, wildcard: true, hostname: mdata.hostname
, os: mdata.os_type, arch: mdata.os_arch });
});
data.ports.forEach(function (p) {
emails[email].ports.push({ issuedAt: iat, number: p });
emails[email].ports.push({ createdAt: iat, number: p, hostname: mdata.hostname
, os: mdata.os_type, arch: mdata.os_arch });
});
});
console.log('[\n' + Object.keys(emails).map(function (k) { return JSON.stringify(emails[k]); }).join(',\n') + '\n]');

View File

@ -143,15 +143,17 @@ DB.domains.available = function (name) {
return !DB._byDomain[name];
});
};
DB.domains._add = function (acc, name) {
DB.domains._add = function (acc, opts) {
// TODO verifications to change ownership of a domain
return PromiseA.resolve().then(function () {
var err;
//var acc = DB._byId[aid];
var domain = {
name: name
name: opts.domain || opts.name
, hostname: opts.hostname
, os: opts.os
, createdAt: new Date().toISOString()
, wildcard: true
, wildcard: opts.wildcard
};
var pdomain;
var parts = name.split('.').map(function (el, i) {
@ -189,11 +191,13 @@ DB.ports.available = function (number) {
return !DB._byPort[number];
});
};
DB.ports._add = function (acc, number) {
DB.ports._add = function (acc, opts) {
return PromiseA.resolve().then(function () {
//var acc = DB._byId[aid];
var port = {
number: number
number: opts.port || opts.number
, hostname: opts.hostname
, os: opts.os
, createdAt: new Date().toISOString()
};
if (DB._byPort[number]) {
@ -652,6 +656,10 @@ module.exports.pairRequest = function (opts) {
, sub: authReq.subject
, pin: pin
, hostname: authReq.hostname
, os_type: authReq.os_type
, os_platform: authReq.os_platform
, os_release: authReq.os_release
, os_arch: authReq.os_arch
};
auth = {
id: authReq.id
@ -747,8 +755,10 @@ module.exports.pairPin = function (opts) {
acc = { email: true, domains: [], ports: [], nodes: [ emailNode ] };
}
return PromiseA.all([
DB.domains._add(acc, opts.domain)
, DB.ports._add(acc, opts.port)
DB.domains._add(acc, { domain: opts.domain, wildcard: true, hostname: auth.authnData.hostname,
os: auth.authnData.os_type, arch: auth.authnData.os_arch })
, DB.ports._add(acc, { port: opts.port, hostname: auth.authnData.hostname,
os: auth.authnData.os_type, arch: auth.authnData.os_arch })
]).then(function () {
var authzData = {
id: auth.id