- Le immagini uploadate non vengono visualizzate subito... cache... aggiungere la versione dell'immagine: vers_img

- Aggiunto il Server TESTRISO e TEST_PCB.
This commit is contained in:
Surya Paolo
2024-09-17 17:38:47 +02:00
parent dcc2a0ec08
commit 9985793fcc
39 changed files with 1259 additions and 162 deletions

View File

@@ -56,11 +56,15 @@ class Mailinabox {
// Trova e stampa il record DKIM
const dkimRecord = records.find(record => record.includes('mail._domainkey'));
if (dkimRecord) {
const pMatch = dkimRecord.match(/p=([A-Za-z0-9+/]+)/);
if (pMatch && pMatch[1]) {
// console.log('Valore di p nel record DKIM:');
// console.log(pMatch[1]);
return pMatch[1];
const pattern = /p=([A-Za-z0-9+/=]+)(?:"\s*"([A-Za-z0-9+/=]+))?/;
// Esegui la ricerca
const match = dkimRecord.match(pattern);
if (match) {
// Concatena le due parti trovate di 'p', la seconda parte è facoltativa
return match[1] + (match[2] || '');
} else {
console.log('Record DKIM non trovato.');
}

View File

@@ -57,7 +57,14 @@ class CloudFlare {
async findAndUpdateOnSite(domain, zone, apiToken) {
try {
const Site = require('../models/site');
const recsite = await Site.findOne({ host: domain });
domain = domain.replace(/^https?:\/\//, '');
let normalizedDomain = domain.startsWith("http://") || domain.startsWith("https://") ? domain : "https://" + domain;
// Trova il sito usando il dominio normalizzato
const recsite = await Site.findOne({ host: normalizedDomain });
if (recsite) {
// Aggiorna i parametri token e zoneId
@@ -87,7 +94,7 @@ class CloudFlare {
let miab = new MailinaboxClass(null);
miab.init();
const dkim = await miab.getDKIMRecord(recsite.host);
const dkim = await miab.getDKIMRecord(recsite.host.replace(/^https?:\/\//, ''));
if (dkim) {
await Site.findOneAndUpdate({ _id: recsite._id }, {
@@ -216,7 +223,12 @@ class CloudFlare {
// get the parameters (Token and zoneId on Database)
const Site = require('../models/site');
await Site.findOne({ host: domainrec.name }).lean()
let domain = domainrec.name.replace(/^https?:\/\//, '');
let normalizedDomain = domain.startsWith("http://") || domain.startsWith("https://") ? domain : "https://" + domain;
// Trova il sito usando il dominio normalizzato
await Site.findOne({ host: normalizedDomain }).lean()
.then(async (site) => {
if (site) {
@@ -224,7 +236,7 @@ class CloudFlare {
const myarrrecdns = await this.fetchDNSRecords(site.cf_token, site.cf_zoneId);
// MX:
let recTypeMX = await myarrrecdns.find((rec) => rec.type === 'MX' && (rec.name === (domainrec.name)));
let recTypeMX = await myarrrecdns.find((rec) => rec.type === 'MX' && (rec.name === (domain)));
if (recTypeMX) {
if (recTypeMX.content !== site.servermail) {
@@ -235,7 +247,7 @@ class CloudFlare {
// create a new record
const newRecord = {
type: 'MX',
name: domainrec.name,
name: domain,
content: site.servermail,
ttl: 1,
proxied: false,
@@ -247,7 +259,7 @@ class CloudFlare {
// TXT record spf1 : TXT nomedominio v=spf1 a mx:box.lamiaposta.org ip4:65.21.63.147 ~all
let recTypeTXTspf1 = await myarrrecdns.find((rec) => rec.type === 'TXT' && (rec.name === (domainrec.name) && (rec.content.indexOf('v=spf1') > -1)));
let recTypeTXTspf1 = await myarrrecdns.find((rec) => rec.type === 'TXT' && (rec.name === (domain) && (rec.content.indexOf('v=spf1') > -1)));
if (site.servermailip) {
let contentTXTspf1 = `v=spf1 a mx:${site.servermail} ip4:${site.servermailip} ~all`;
@@ -261,7 +273,7 @@ class CloudFlare {
// create a new record
const newRecord = {
type: 'TXT',
name: domainrec.name,
name: domain,
content: contentTXTspf1,
ttl: 3600,
};
@@ -272,7 +284,7 @@ class CloudFlare {
// mail._domainkey.nomedominio v=DKIM1; h=sha256; k=rsa; s=email; p=<dkim>
let nameDkimtoFind = `mail._domainkey.${domainrec.name}`;
let nameDkimtoFind = `mail._domainkey.${domain}`;
let recTypeTXTDKIM = await myarrrecdns.find((rec) => rec.type === 'TXT' && (rec.name === nameDkimtoFind));
@@ -299,12 +311,12 @@ class CloudFlare {
// DMARC:
let nameDmarctoFind = `_dmarc.${domainrec.name}`;
let nameDmarctoFind = `_dmarc.${domain}`;
let recTypeTXTdmarc = await myarrrecdns.find((rec) => rec.type === 'TXT' && (rec.name === (nameDmarctoFind) && (rec.content.indexOf('v=DMARC1') > -1)));
if (site.servermailip) {
let contentTXTdmarc = `v=DMARC1; p=quarantine; ruf=mailto:dmarc@${domainrec.name};`;
let contentTXTdmarc = `v=DMARC1; p=quarantine; ruf=mailto:dmarc@${domain};`;
if (recTypeTXTdmarc) {
if (recTypeTXTdmarc.content !== contentTXTdmarc) {
@@ -326,7 +338,7 @@ class CloudFlare {
// AutoConfig:
let myType = 'CNAME';
let strfind = `autoconfig.${domainrec.name}`;
let strfind = `autoconfig.${domain}`;
let contentExpected = site.servermail;
let rectofind = await myarrrecdns.find((rec) => rec.type === 'CNAME' && (rec.name === strfind));
@@ -349,7 +361,7 @@ class CloudFlare {
// AutoDiscover:
myType = 'CNAME';
strfind = `autodiscover.${domainrec.name}`;
strfind = `autodiscover.${domain}`;
contentExpected = site.servermail;
rectofind = await myarrrecdns.find((rec) => rec.type === 'CNAME' && (rec.name === strfind));
@@ -384,7 +396,12 @@ class CloudFlare {
// get the parameters (Token and zoneId on Database)
const Site = require('../models/site');
await Site.findOne({ host: domain }).lean()
domain = domain.replace(/^https?:\/\//, '');
let normalizedDomain = domain.startsWith("http://") || domain.startsWith("https://") ? domain : "https://" + domain;
// Trova il sito usando il dominio normalizzato
await Site.findOne({ host: normalizedDomain }).lean()
.then(async (site) => {
if (site) {
@@ -398,7 +415,7 @@ class CloudFlare {
let paramexpected = '';
try {
paramexpected = site[paramobj.paramsite];
paramexpected = site[paramobj.paramsite].replace(/^https?:\/\//, '');;
} catch (e) {
}