Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ipcRenderer.on('Request0101', (event, arg) => {
  2.  
  3.     console.log("Request0101 socket");
  4.  
  5.     const tryFirstDNSPromise = new Promise((resolve, reject) => {
  6.  
  7.         const DNS1 = new DNSCheck();
  8.         DNS1.client = net.Socket().connect(DNS1.ports[0], DNS1.address[0]);
  9.         DNS1.client.setEncoding('hex')
  10.  
  11.         DNS1.client.on('connect', function () {
  12.             console.log("connect 1 DNS");
  13.             resolve(DNS1);
  14.         });
  15.  
  16.         DNS1.client.on('error', function (error) {
  17.             console.log("error 1 DNS");
  18.             reject(error);
  19.         });
  20.  
  21.         DNS1.client.on("data", function (data) {
  22.             console.log("1 DATA DNS", data);
  23.             dStream.dataInput(data)
  24.         })
  25.  
  26.         DNS1.client.on('end', function () {
  27.             console.log('1 END DNS')
  28.         })
  29.  
  30.     });
  31.  
  32.     const trySecondDNSPromise = new Promise((resolve, reject) => {
  33.  
  34.         const DNS2 = new DNSCheck();
  35.         DNS2.client = net.Socket().connect(DNS2.ports[1], DNS2.address[1]);
  36.         DNS2.client.setEncoding('hex');
  37.  
  38.         DNS2.client.on('connect', function () {
  39.             console.log("connect 2 DNS");
  40.             resolve(DNS2);
  41.         });
  42.  
  43.         DNS2.client.on('error', function (error) {
  44.             console.log("error 2 DNS");
  45.             reject(error);
  46.         });
  47.  
  48.         DNS2.client.on("data", function (data) {
  49.             console.log("2 DATA DNS", data);
  50.             dStream.dataInput(data)
  51.         })
  52.  
  53.         DNS2.client.on('end', function () {
  54.             console.log('2 END DNS')
  55.         })
  56.  
  57.     });
  58.  
  59.     tryFirstDNSPromise.then((client) => {
  60.         client.sendData('0101', '')
  61.     }).catch((error) => {
  62.         console.log(error)
  63.         trySecondDNSPromise.then((client) => {
  64.             client.sendData('0101', '')
  65.         }).catch((error) => {
  66.             console.log(error)
  67.         })
  68.     })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement