samedi 15 septembre 2018

call a function from another file and get a random result for each call

I have a random.js file containing this to get random fake ip

exports.ip = (Math.floor(Math.random() * 255) + 1)+"."+(Math.floor(Math.random() * 255) + 0)+"."+(Math.floor(Math.random() * 255) + 0)+"."+(Math.floor(Math.random() * 255) + 0);

and I call the variable in the send.js file to replace string {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);

}

but it will only produce one generated ip, I want to make it generate random every time it is called will produce different values

I have tried inserting it in the loop but still not working




Aucun commentaire:

Enregistrer un commentaire