-
Notifications
You must be signed in to change notification settings - Fork 0
/
who_is.js
136 lines (97 loc) · 4.19 KB
/
who_is.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
const mysql = require('mysql');
const whoiser = require('whoiser');
require('dotenv').config();
let connection = mysql.createConnection({
host: process.env.host,
user: process.env.user,
password: process.env.password,
database: process.env.database,
port: process.env.port
});
const run = function () {
connection = mysql.createConnection({
host: process.env.host,
user: process.env.user,
password: process.env.password,
database: process.env.database,
port: process.env.port
});
connection.connect(function(err) {
if (err) {
console.error('Veri tabanına bağlanırken hata, ' + err.stack);
}
let sql = "SELECT * FROM domain_table where status = 1 and dns = 2 limit 10";
connection.query(sql, function (err, result) {
console.log(result.length);
result.map(statusUpdate);
function statusUpdate(row) {
let sql2 = "UPDATE domain_table SET status = 2 WHERE id = " + row.id + ";";
connection.query(sql2, function (err, result) {
// console.log(result);
})
}
let ban_tld4 = [
'.mil',
'.gov',
'.edu',
];
let ban_tld3 = [
'.va',
'.gr',
'.za',
];
result.map(whoisupdate);
function whoisupdate(row) {
if (ban_tld4.includes(row.domain.slice(row.domain.length - 4))){
return;
}
if (ban_tld3.includes(row.domain.slice(row.domain.length - 3))){
return;
}
if (row.domain.includes(ban_tld4)){
return;
}
try{
(async () => {
//const domainName = 'cloudflare.com'
const domainName = row.domain;
// retrieve WHOIS info from Registrar WHOIS servers
const domainWhois = await whoiser(domainName, { follow: 1 })
const firstDomainWhois = whoiser.firstResult(domainWhois)
const firstTextLine = (firstDomainWhois.text[0] || '').toLowerCase()
let domainAvailability = 'unknown'
if (firstTextLine.includes('reserved')) {
domainAvailability = 'reserved'
} else if (firstDomainWhois['Domain Name'] && firstDomainWhois['Domain Name'].toLowerCase() === domainName) {
domainAvailability = 'registered'
} else if (firstTextLine.includes(`no match for "${domainName}"`)) {
domainAvailability = 'available'
}
console.log(`Domain "${domainName}" is "${domainAvailability}"`)
if (domainAvailability === 'registered') {
// console.log('Domain was registered on', firstDomainWhois['Created Date'], 'at', firstDomainWhois.Registrar)
// console.log('Registration will expire on', firstDomainWhois['Expiry Date'])
// console.log('Domain uses name servers:', firstDomainWhois['Name Server'])
} else if (domainAvailability === 'available') {
console.log('This domain is available for registration right now')
let sql4 = "UPDATE domain_table SET status = 9 WHERE id = " + row.id + ";";
connection.query(sql4, function (err, result) {
console.log(result)
})
}
})();
}catch (error) {
console.error(error);
// expected output: ReferenceError: nonExistentFunction is not defined
// Note - error messages will vary depending on browser
}
}
})
})
};
setInterval(async function () {
connection.end(function(err) {
console.log("The connection is terminated now");
run();
});
},10000);