У меня есть файл random.js, содержащий его, чтобы получить случайный поддельный ip
exports.ip = function () {
let random = (Math.floor(Math.random() * 255) + 1)+"."+(Math.floor(Math.random() * 255) + 0)+"."+(Math.floor(Math.random() * 255) + 0)+"."+(Math.floor(Math.random() * 255) + 0);
return random
}
и я вызываю переменную в файле send.js для замены строки {randomip}
let replace_tag = function (to) {
config.message.subject = config.message.subject
.replace("{randomip}", random.ip)
.replace("{email}", to)
.replace("{date}", random.date);
config.message.fromname = config.message.fromname
.replace("{randomip}", random.ip)
.replace("{email}", to)
.replace("{date}", random.date);
config.message.fromemail = config.message.fromemail
.replace("{randomip}", random.ip)
.replace("{email}", to)
.replace("{date}", random.date);
}
но он будет выдавать только один сгенерированный ip, я хочу, чтобы он генерировал случайный каждый раз, когда он вызывается, будет выдавать разные значения
Я попытался вставить его в цикл, но все еще не работает
Я вызываю функцию замены в другой функции, затем вводю ее в цикл, как этот
let kirim = function (to) {
replace_tag(to);
let message = {
from: config.message.fromname+'<'+config.message.fromemail+'>',
to: to,
subject: config.message.subject,
text: config.message.text,
html: html
};
transporter.sendMail(message, (error, info) => {
if (error) {
return console.log(error.response)
}
console.log('Message sent: ',info.accepted);
});
};
(async () => {
for (var i in list) {
kirim(list[i]);
await delay(config.send.delay*1000);
}
})();