add some more info to domain list
This commit is contained in:
parent
4e3e155460
commit
004908e735
|
@ -11,11 +11,13 @@ files.forEach(function (fname) {
|
||||||
var data;
|
var data;
|
||||||
var email;
|
var email;
|
||||||
var iat;
|
var iat;
|
||||||
|
var mdata;
|
||||||
if (!/\.data$/.test(fname)) {
|
if (!/\.data$/.test(fname)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data = JSON.parse(fs.readFileSync(fpath));
|
data = JSON.parse(fs.readFileSync(fpath));
|
||||||
email = fname.replace('\.' + data.domains.join('') + '\.data', '');
|
email = fname.replace('\.' + data.domains.join('') + '\.data', '');
|
||||||
|
mdata = JSON.parse(fs.readFileSync(path.join(basedir, email)));
|
||||||
if (data.iat) {
|
if (data.iat) {
|
||||||
iat = new Date(data.iat).toISOString();
|
iat = new Date(data.iat).toISOString();
|
||||||
}
|
}
|
||||||
|
@ -23,16 +25,18 @@ files.forEach(function (fname) {
|
||||||
emails[email] = {
|
emails[email] = {
|
||||||
domains: []
|
domains: []
|
||||||
, ports: []
|
, ports: []
|
||||||
, nodes: [ { issuedAt: iat, scheme: 'mailto', type: 'email', name: email } ]
|
, nodes: [ { createdAt: iat, scheme: 'mailto', type: 'email', name: email } ]
|
||||||
, jtis: []
|
, jtis: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
emails[email].jtis.push(data.id);
|
emails[email].jtis.push(data.id);
|
||||||
data.domains.forEach(function (d) {
|
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) {
|
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]');
|
console.log('[\n' + Object.keys(emails).map(function (k) { return JSON.stringify(emails[k]); }).join(',\n') + '\n]');
|
||||||
|
|
|
@ -143,15 +143,17 @@ DB.domains.available = function (name) {
|
||||||
return !DB._byDomain[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
|
// TODO verifications to change ownership of a domain
|
||||||
return PromiseA.resolve().then(function () {
|
return PromiseA.resolve().then(function () {
|
||||||
var err;
|
var err;
|
||||||
//var acc = DB._byId[aid];
|
//var acc = DB._byId[aid];
|
||||||
var domain = {
|
var domain = {
|
||||||
name: name
|
name: opts.domain || opts.name
|
||||||
|
, hostname: opts.hostname
|
||||||
|
, os: opts.os
|
||||||
, createdAt: new Date().toISOString()
|
, createdAt: new Date().toISOString()
|
||||||
, wildcard: true
|
, wildcard: opts.wildcard
|
||||||
};
|
};
|
||||||
var pdomain;
|
var pdomain;
|
||||||
var parts = name.split('.').map(function (el, i) {
|
var parts = name.split('.').map(function (el, i) {
|
||||||
|
@ -189,11 +191,13 @@ DB.ports.available = function (number) {
|
||||||
return !DB._byPort[number];
|
return !DB._byPort[number];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
DB.ports._add = function (acc, number) {
|
DB.ports._add = function (acc, opts) {
|
||||||
return PromiseA.resolve().then(function () {
|
return PromiseA.resolve().then(function () {
|
||||||
//var acc = DB._byId[aid];
|
//var acc = DB._byId[aid];
|
||||||
var port = {
|
var port = {
|
||||||
number: number
|
number: opts.port || opts.number
|
||||||
|
, hostname: opts.hostname
|
||||||
|
, os: opts.os
|
||||||
, createdAt: new Date().toISOString()
|
, createdAt: new Date().toISOString()
|
||||||
};
|
};
|
||||||
if (DB._byPort[number]) {
|
if (DB._byPort[number]) {
|
||||||
|
@ -652,6 +656,10 @@ module.exports.pairRequest = function (opts) {
|
||||||
, sub: authReq.subject
|
, sub: authReq.subject
|
||||||
, pin: pin
|
, pin: pin
|
||||||
, hostname: authReq.hostname
|
, hostname: authReq.hostname
|
||||||
|
, os_type: authReq.os_type
|
||||||
|
, os_platform: authReq.os_platform
|
||||||
|
, os_release: authReq.os_release
|
||||||
|
, os_arch: authReq.os_arch
|
||||||
};
|
};
|
||||||
auth = {
|
auth = {
|
||||||
id: authReq.id
|
id: authReq.id
|
||||||
|
@ -747,8 +755,10 @@ module.exports.pairPin = function (opts) {
|
||||||
acc = { email: true, domains: [], ports: [], nodes: [ emailNode ] };
|
acc = { email: true, domains: [], ports: [], nodes: [ emailNode ] };
|
||||||
}
|
}
|
||||||
return PromiseA.all([
|
return PromiseA.all([
|
||||||
DB.domains._add(acc, opts.domain)
|
DB.domains._add(acc, { domain: opts.domain, wildcard: true, hostname: auth.authnData.hostname,
|
||||||
, DB.ports._add(acc, opts.port)
|
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 () {
|
]).then(function () {
|
||||||
var authzData = {
|
var authzData = {
|
||||||
id: auth.id
|
id: auth.id
|
||||||
|
|
Loading…
Reference in New Issue