/DIAS

Dynamic IP Address Server

Primary LanguageJavaScript

DDNS/DIAS - Dynamic Domain Name Server/Dynamic IP Address Server V1.0.0

Send notification by email when IP address changes.

  1. Clone DIAS file and rename to edit and use in formal environment.

  2. Options: use additional service require own real public ip address.

var options = {
   host: 'ip.cip.cc',
   port: '80',
   path: ''  
};
  1. Seting execution logic:executing function every 2 seconds or 60 seconds.
setInterval(get_SYS_Time, 2 * 1000);
setInterval(get_Real_IP_Address, 60 * 1000);
  1. Setting sender account and other informations.
  let transporter = nodemailer.createTransport({
    host: "smtp.xxx.com",
    port: 465,
    secure: true, // true for 465, false for other ports
    auth: {
      user: "xxxxx@xxxxx.com", // generated ethereal user
      pass: "xxxxx", // generated ethereal password
    },
  });
  1. Seting recipient's imformation.
  let info = await transporter.sendMail({
    from: '"IP Change~ 👻" <xxxxx@xxxxx.com>', // sender address
    to: "xxxxx@xxxxx.com", // list of receivers
    subject: "Hello ✔", // Subject line
    text: "http://" + i, // plain text body
    html: '<a href="http://' + i + '">服务器IP地址:' + 'http://' + i + '</a>', // html body
  });
  1. Introduce mail module.

terminal

npm i nodemailer
  1. Running or yuo can use 'forever' to run.

terminal

node filename