Added cron for ru domain

This commit is contained in:
zeldaroot 2020-08-01 02:19:26 +03:00
parent 05a1b2511d
commit d3d1195dfb

View file

@ -864,11 +864,17 @@ if (
* Create random subdomain.
*/
if (config.random && hour === 4) {
if ((config.random || config.ru.random) && hour === 4) {
active.num++;
active.process.random = true;
config.subdomain = dayToLetter();
config.subdomain = config.random ? dayToLetter() : config.subdomain;
config.ru.subdomain = config.ru.random
? dayToLetter()
.split('')
.reverse()
.join('')
: config.ru.subdomain;
CP_save.save(config, 'config', function(err) {
if (err) console.log('[CP_save.save]', err);
@ -891,7 +897,14 @@ if (config.random && hour === 4) {
* Check domain in BlackList.
*/
if ((config.botdomain || config.subdomain) && config.blacklist && !(hour % 6)) {
if (
(config.botdomain ||
config.subdomain ||
config.ru.botdomain ||
config.ru.subdomain) &&
config.blacklist &&
!(hour % 6)
) {
active.num++;
active.process.checkdomain = true;
@ -912,103 +925,216 @@ if ((config.botdomain || config.subdomain) && config.blacklist && !(hour % 6)) {
active.num--;
active.process.checkdomain = false;
}
var dms = JSON.parse(body);
var danger = false;
var subs = config.subdomain.split('.').filter(Boolean);
var bots = config.botdomain.split('.').filter(Boolean);
var domains = {
sub: {
domain: config.domain,
main: subs[1] ? subs[1] + '.' : subs[0] ? subs[0] + '.' : '',
second: subs[1] ? subs[0] + '.' : ''
},
bot: {
domain: config.bomain || config.domain,
main: bots[1] ? bots[1] + '.' : bots[0] ? bots[0] + '.' : '',
second: bots[1] ? bots[0] + '.' : ''
}
};
for (var i = 0; i < dms.length; i++) {
['sub', 'bot'].forEach(function(name) {
if (name === 'bot' && config.blacklist === 3) {
return;
}
if (name === 'sub' && config.blacklist === 2) {
return;
}
if (
(dms[i] === '*.' + domains.bot.domain ||
dms[i] === domains.bot.domain) &&
config.alt.bomain &&
config.bomain &&
config.alt.bomain !== config.bomain
) {
domains.bot.domain = config.alt.bomain;
if (config.alt.botdomain) {
domains.bot.main = config.alt.botdomain;
config.alt.botdomain =
config.alt.botdomain.replace(/\./g, '').replace(/[0-9]/g, '') +
(parseInt(config.alt.botdomain.replace(/[^0-9]/g, '') || '0') +
1) +
'.';
}
danger = true;
} else if (
domains[name].main &&
(dms[i] === domains[name].main + domains[name].domain ||
dms[i] === '*.' + domains[name].main + domains[name].domain)
) {
domains[name].main =
domains[name].main.replace(/\./g, '').replace(/[0-9]/g, '') +
(parseInt(domains[name].main.replace(/[^0-9]/g, '') || '0') + 1) +
'.';
if (name === 'bot' && config.alt.botdomain) {
domains.bot.main = config.alt.botdomain;
config.alt.botdomain =
config.alt.botdomain.replace(/\./g, '').replace(/[0-9]/g, '') +
(parseInt(config.alt.botdomain.replace(/[^0-9]/g, '') || '0') +
1) +
'.';
}
danger = true;
} else if (
domains[name].second &&
(dms[i] ===
domains[name].second +
domains[name].main +
domains[name].domain ||
dms[i] ===
'*.' +
domains[name].second +
domains[name].main +
domains[name].domain)
) {
domains[name].second =
domains[name].second.replace(/\./g, '').replace(/[0-9]/g, '') +
(parseInt(domains[name].second.replace(/[^0-9]/g, '') || '0') +
1) +
'.';
danger = true;
}
});
var dms = [];
try {
dms = JSON.parse(body);
} catch (e) {
console.error(e);
}
if (danger) {
config.botdomain = domains.bot.second + domains.bot.main;
config.subdomain = domains.sub.second + domains.sub.main;
config.bomain = domains.bot.domain;
async.eachOfLimit(
['*', 'ru'],
1,
function(lang, index, callback) {
if (lang === '*' && !config.botdomain && !config.subdomain) {
return callback();
}
if (lang === 'ru' && !config.ru.botdomain && !config.ru.subdomain) {
return callback();
}
var danger = false;
var subs =
lang === 'ru'
? config.ru.subdomain
? config.ru.subdomain.split('.').filter(Boolean)
: []
: config.subdomain
? config.subdomain.split('.').filter(Boolean)
: [];
var bots =
lang === 'ru'
? config.ru.botdomain
? config.ru.botdomain.split('.').filter(Boolean)
: []
: config.botdomain
? config.botdomain.split('.').filter(Boolean)
: [];
var domains = {
sub: {
domain: lang === 'ru' ? config.ru.domain : config.domain,
main: subs[1] ? subs[1] + '.' : subs[0] ? subs[0] + '.' : '',
second: subs[1] ? subs[0] + '.' : ''
},
bot: {
domain:
lang === 'ru'
? config.ru.bomain || config.ru.domain
: config.bomain || config.domain,
main: bots[1] ? bots[1] + '.' : bots[0] ? bots[0] + '.' : '',
second: bots[1] ? bots[0] + '.' : ''
}
};
for (var i = 0; i < dms.length; i++) {
['sub', 'bot'].forEach(function(name) {
if (name === 'bot' && config.blacklist === 3) {
return;
}
if (name === 'sub' && config.blacklist === 2) {
return;
}
if (
(dms[i] === '*.' + domains.bot.domain ||
dms[i] === domains.bot.domain) &&
(lang === 'ru'
? config.ru.alt.bomain &&
config.ru.bomain &&
config.ru.alt.bomain !== config.ru.bomain
: config.alt.bomain &&
config.bomain &&
config.alt.bomain !== config.bomain)
) {
domains.bot.domain =
lang === 'ru' ? config.ru.alt.bomain : config.alt.bomain;
if (
lang === 'ru' ? config.ru.alt.botdomain : config.alt.botdomain
) {
domains.bot.main =
lang === 'ru'
? config.ru.alt.botdomain
: config.alt.botdomain;
if (lang === 'ru') {
config.ru.alt.botdomain =
config.ru.alt.botdomain
.replace(/\./g, '')
.replace(/[0-9]/g, '') +
(parseInt(
config.ru.alt.botdomain.replace(/[^0-9]/g, '') || '0'
) +
1) +
'.';
} else {
config.alt.botdomain =
config.alt.botdomain
.replace(/\./g, '')
.replace(/[0-9]/g, '') +
(parseInt(
config.alt.botdomain.replace(/[^0-9]/g, '') || '0'
) +
1) +
'.';
}
}
danger = true;
} else if (
domains[name].main &&
(dms[i] === domains[name].main + domains[name].domain ||
dms[i] === '*.' + domains[name].main + domains[name].domain)
) {
domains[name].main =
domains[name].main.replace(/\./g, '').replace(/[0-9]/g, '') +
(parseInt(domains[name].main.replace(/[^0-9]/g, '') || '0') +
1) +
'.';
if (
name === 'bot' &&
(lang === 'ru'
? config.ru.alt.botdomain
: config.alt.botdomain)
) {
domains.bot.main =
lang === 'ru'
? config.ru.alt.botdomain
: config.alt.botdomain;
if (lang === 'ru') {
config.ru.alt.botdomain =
config.ru.alt.botdomain
.replace(/\./g, '')
.replace(/[0-9]/g, '') +
(parseInt(
config.ru.alt.botdomain.replace(/[^0-9]/g, '') || '0'
) +
1) +
'.';
} else {
config.alt.botdomain =
config.alt.botdomain
.replace(/\./g, '')
.replace(/[0-9]/g, '') +
(parseInt(
config.alt.botdomain.replace(/[^0-9]/g, '') || '0'
) +
1) +
'.';
}
}
danger = true;
} else if (
domains[name].second &&
(dms[i] ===
domains[name].second +
domains[name].main +
domains[name].domain ||
dms[i] ===
'*.' +
domains[name].second +
domains[name].main +
domains[name].domain)
) {
domains[name].second =
domains[name].second
.replace(/\./g, '')
.replace(/[0-9]/g, '') +
(parseInt(
domains[name].second.replace(/[^0-9]/g, '') || '0'
) +
1) +
'.';
danger = true;
}
});
}
if (danger) {
if (lang === 'ru') {
config.ru.botdomain = domains.bot.second + domains.bot.main;
config.ru.subdomain = domains.sub.second + domains.sub.main;
config.ru.bomain = domains.bot.domain;
console.log('NEW SUBDOMAIN:', config.subdomain + domains.sub.domain);
console.log('NEW BOTDOMAIN:', config.botdomain + domains.bot.domain);
console.log(
'NEW RU SUBDOMAIN:',
config.ru.subdomain + domains.sub.domain
);
console.log(
'NEW RU BOTDOMAIN:',
config.ru.botdomain + domains.bot.domain
);
} else {
config.botdomain = domains.bot.second + domains.bot.main;
config.subdomain = domains.sub.second + domains.sub.main;
config.bomain = domains.bot.domain;
CP_save.save(config, 'config', function(err) {
if (err) console.log('[CP_save.save]', err);
console.log(
'NEW SUBDOMAIN:',
config.subdomain + domains.sub.domain
);
console.log(
'NEW BOTDOMAIN:',
config.botdomain + domains.bot.domain
);
}
CP_save.save(config, 'config', function(err) {
if (err) console.log('[CP_save.save]', err);
callback();
});
} else {
callback();
}
},
function(err) {
if (err) console.error(err);
active.num--;
active.process.checkdomain = false;
});
} else {
active.num--;
active.process.checkdomain = false;
}
}
);
}
);
} else {
@ -1016,7 +1142,10 @@ if ((config.botdomain || config.subdomain) && config.blacklist && !(hour % 6)) {
'NOT START:',
'CHECKDOMAIN',
'config',
!!config.botdomain || !!config.subdomain,
!!config.botdomain ||
!!config.subdomain ||
!!config.ru.botdomain ||
!!config.ru.subdomain,
'hour',
'6,12,18,24 !=',
hour