1
|
|
|
// jshint esversion: 8, -W030 |
2
|
|
|
|
3
|
|
|
const whois = require('../../common/whoisWrapper'), |
|
|
|
|
4
|
|
|
conversions = require('../../common/conversions'), |
|
|
|
|
5
|
|
|
base = 10; |
6
|
|
|
|
7
|
|
|
const { |
8
|
|
|
ipcRenderer |
9
|
|
|
} = require('electron'); |
10
|
|
|
|
11
|
|
|
require('../../common/stringFormat'); |
12
|
|
|
|
13
|
|
|
/* |
14
|
|
|
// Receive whois lookup reply |
15
|
|
|
ipcRenderer.on('bulkwhois:results', function(event, domain, domainResults) { |
16
|
|
|
|
17
|
|
|
//ipcRenderer.send('app:debug', "Whois domain reply for {0}:\n {1}".format(domain, domainResults)); |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
(function() { |
21
|
|
|
var result; |
22
|
|
|
if (typeof domainResults === 'object') { |
23
|
|
|
JSON.stringify(domainResults, null, 2); |
24
|
|
|
result = domainResults.map(function(data) { |
25
|
|
|
data.data = parseRawData(data.data); |
26
|
|
|
return data; |
27
|
|
|
}); |
28
|
|
|
} else { |
29
|
|
|
result = parseRawData(domainResults); |
30
|
|
|
} |
31
|
|
|
return result; |
32
|
|
|
})(); |
33
|
|
|
|
34
|
|
|
}); |
35
|
|
|
*/ |
36
|
|
|
|
37
|
|
|
/* |
38
|
|
|
// Receive bulk whois results |
39
|
|
|
ipcRenderer.on('bulkwhois:resultreceive', function(event, results) { |
40
|
|
|
|
41
|
|
|
}); |
42
|
|
|
*/ |
43
|
|
|
|
44
|
|
|
/* |
45
|
|
|
ipcRenderer.on('bw:status.update', function(...) {...}); |
46
|
|
|
Bulk whois processing, ui status update |
47
|
|
|
parameters |
48
|
|
|
event |
49
|
|
|
stat |
50
|
|
|
value |
51
|
|
|
*/ |
52
|
|
|
ipcRenderer.on('bw:status.update', function(event, stat, value) { |
53
|
|
|
ipcRenderer.send('app:debug', "{0}, value update to {1}".format(stat, value)); // status update |
54
|
|
|
var percent; |
55
|
|
|
switch (stat) { |
56
|
|
|
case 'start': |
57
|
|
|
if ($('#bwProcessingButtonNext').hasClass('is-hidden') === false) { |
58
|
|
|
$('#bwProcessingButtonNext').addClass('is-hidden'); |
59
|
|
|
$('#bwProcessingButtonPause').removeClass('is-hidden'); |
60
|
|
|
$('#bwProcessingButtonStop').removeClass('is-hidden'); |
61
|
|
|
} |
62
|
|
|
break; |
63
|
|
|
case 'domains.processed': // processed domains |
64
|
|
|
percent = parseFloat((value / parseInt($('#bwProcessingSpanTotal').text(), base) * 100).toFixed(1)) || 0; |
65
|
|
|
$('#bwProcessingSpanProcessed').text('{0} ({1}%)'.format(value, percent)); |
66
|
|
|
break; |
67
|
|
|
case 'domains.waiting': // whois requests waiting reply |
68
|
|
|
percent = parseFloat((value / parseInt($('#bwProcessingSpanSent').text(), base) * 100).toFixed(1)) || 0; |
69
|
|
|
$('#bwProcessingSpanWaiting').text('{0} ({1}%)'.format(value, percent)); |
70
|
|
|
break; |
71
|
|
|
case 'domains.sent': // sent whois requests |
72
|
|
|
percent = parseFloat((value / parseInt($('#bwProcessingSpanTotal').text(), base) * 100).toFixed(1)) || 0; |
73
|
|
|
$('#bwProcessingSpanSent').text('{0} ({1}%)'.format(value, percent)); |
74
|
|
|
break; |
75
|
|
|
case 'domains.total': // total domains |
76
|
|
|
$('#bwProcessingSpanTotal').text(value); |
77
|
|
|
break; |
78
|
|
|
case 'time.current': // current time |
79
|
|
|
$('#bwProcessingSpanTimecurrent').text('{0}'.format(value)); |
80
|
|
|
break; |
81
|
|
|
case 'time.remaining': // remaining time |
82
|
|
|
$('#bwProcessingSpanTimeremaining').text('{0}'.format(value)); |
83
|
|
|
break; |
84
|
|
|
case 'reqtimes.maximum': // maximum request reply time |
85
|
|
|
$('#bwProcessingSpanReqtimemax').text('{0}ms'.format(value)); |
86
|
|
|
break; |
87
|
|
|
case 'reqtimes.minimum': // minimum request reply time |
88
|
|
|
$('#bwProcessingSpanReqtimemin').text('{0}ms'.format(value)); |
89
|
|
|
break; |
90
|
|
|
case 'reqtimes.last': // last request reply time |
91
|
|
|
$('#bwProcessingSpanReqtimelast').text('{0}ms'.format(value)); |
92
|
|
|
break; |
93
|
|
|
case 'reqtimes.average': // Average request reply time |
94
|
|
|
$('#bwProcessingSpanReqtimeavg').text('{0}ms'.format(value)); |
95
|
|
|
break; |
96
|
|
|
case 'status.available': // Domains available |
97
|
|
|
percent = parseFloat((value / parseInt($('#bwProcessingSpanTotal').text(), base) * 100).toFixed(1)) || 0; |
98
|
|
|
$('#bwProcessingSpanStatusavailable').text('{0} ({1}%)'.format(value, percent)); |
99
|
|
|
break; |
100
|
|
|
case 'status.unavailable': // Domains unavailable |
101
|
|
|
percent = parseFloat((value / parseInt($('#bwProcessingSpanTotal').text(), base) * 100).toFixed(1)) || 0; |
102
|
|
|
$('#bwProcessingSpanStatusunavailable').text('{0} ({1}%)'.format(value, percent)); |
103
|
|
|
break; |
104
|
|
|
case 'status.error': // Domains error |
105
|
|
|
percent = parseFloat((value / parseInt($('#bwProcessingSpanTotal').text(), base) * 100).toFixed(1)) || 0; |
106
|
|
|
$('#bwProcessingSpanStatuserror').text('{0} ({1}%)'.format(value, percent)); |
107
|
|
|
break; |
108
|
|
|
case 'laststatus.available': // Last available domain |
109
|
|
|
$('#bwProcessingSpanLaststatusavailable').text('{0}'.format(value)); |
110
|
|
|
break; |
111
|
|
|
case 'laststatus.unavailable': // Last unavailable domain |
112
|
|
|
$('#bwProcessingSpanLaststatusunavailable').text('{0}'.format(value)); |
113
|
|
|
break; |
114
|
|
|
case 'laststatus.error': // Last error domain |
115
|
|
|
$('#bwProcessingSpanLaststatuserror').text('{0}'.format(value)); |
116
|
|
|
break; |
117
|
|
|
case 'finished': // Finished |
118
|
|
|
$('#bwProcessingButtonPause').addClass('is-hidden'); |
119
|
|
|
$('#bwProcessingButtonStop').addClass('is-hidden'); |
120
|
|
|
$('#bwProcessingButtonNext').removeClass('is-hidden'); |
121
|
|
|
break; |
122
|
|
|
default: |
123
|
|
|
break; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
return; |
127
|
|
|
}); |
128
|
|
|
|
129
|
|
|
/* |
130
|
|
|
$('#bwProcessingButtonPause').click(function() {...}); |
131
|
|
|
Bulk processing, pause/continue process |
132
|
|
|
*/ |
133
|
|
|
$('#bwProcessingButtonPause').click(function() { |
134
|
|
|
var searchStatus = $('#bwProcessingButtonPauseSpanText').text(); |
135
|
|
|
switch (searchStatus) { |
136
|
|
|
case 'Continue': |
137
|
|
|
setPauseButton(); |
138
|
|
|
ipcRenderer.send('bw:lookup.continue'); |
139
|
|
|
break; |
140
|
|
|
case 'Pause': |
141
|
|
|
$('#bwProcessingButtonPause').removeClass('is-warning').addClass('is-success'); |
142
|
|
|
$('#bwProcessingButtonPauseicon').removeClass('fa-pause').addClass('fa-play'); |
143
|
|
|
$('#bwProcessingButtonPauseSpanText').text('Continue'); |
144
|
|
|
ipcRenderer.send('bw:lookup.pause'); |
145
|
|
|
break; |
146
|
|
|
default: |
147
|
|
|
break; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
return; |
151
|
|
|
}); |
152
|
|
|
|
153
|
|
|
/* |
154
|
|
|
setPauseButton |
155
|
|
|
Set bulk whois pause button |
156
|
|
|
*/ |
157
|
|
|
function setPauseButton() { |
158
|
|
|
$('#bwProcessingButtonPause').removeClass('is-success').addClass('is-warning'); |
159
|
|
|
$('#bwProcessingButtonPauseicon').removeClass('fa-play').addClass('fa-pause'); |
160
|
|
|
$('#bwProcessingButtonPauseSpanText').text('Pause'); |
161
|
|
|
|
162
|
|
|
return; |
|
|
|
|
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/* |
166
|
|
|
$('#bwProcessingButtonStop').click(function() {...}); |
167
|
|
|
Trigger Bulk whois Stop modal |
168
|
|
|
*/ |
169
|
|
|
$('#bwProcessingButtonStop').click(function() { |
170
|
|
|
ipcRenderer.send('app:debug', "Pausing whois & opening stop modal"); |
171
|
|
|
$('#bwProcessingButtonPause').text().includes('Pause') ? $('#bwProcessingButtonPause').click() : false; |
172
|
|
|
$('#bwProcessingModalStop').addClass('is-active'); |
173
|
|
|
|
174
|
|
|
return; |
|
|
|
|
175
|
|
|
}); |
176
|
|
|
|
177
|
|
|
/* |
178
|
|
|
$('#bwProcessingModalStopButtonContinue').click(function() {...}); |
179
|
|
|
Close modal and allow continue |
180
|
|
|
*/ |
181
|
|
|
$('#bwProcessingModalStopButtonContinue').click(function() { |
182
|
|
|
ipcRenderer.send('app:debug', "Closing Stop modal & continue"); |
183
|
|
|
$('#bwProcessingModalStop').removeClass('is-active'); |
184
|
|
|
|
185
|
|
|
return; |
|
|
|
|
186
|
|
|
}); |
187
|
|
|
|
188
|
|
|
/* |
189
|
|
|
$('#bwProcessingModalStopButtonStop').click(function() {...}); |
190
|
|
|
Stop bulk whois entirely and scrape everything |
191
|
|
|
*/ |
192
|
|
|
$('#bwProcessingModalStopButtonStop').click(function() { |
193
|
|
|
ipcRenderer.send('app:debug', "Closing Stop modal & going back to start"); |
194
|
|
|
$('#bwpStopModal').removeClass('is-active'); |
195
|
|
|
$('#bwProcessing').addClass('is-hidden'); |
196
|
|
|
setPauseButton(); |
197
|
|
|
$('#bwEntry').removeClass('is-hidden'); |
198
|
|
|
|
199
|
|
|
return; |
|
|
|
|
200
|
|
|
}); |
201
|
|
|
|
202
|
|
|
/* |
203
|
|
|
$('#bwProcessingModalStopButtonStopsave').click(function() {...}); |
204
|
|
|
Stop bulk whois entirely and save/export |
205
|
|
|
*/ |
206
|
|
|
$('#bwProcessingModalStopButtonStopsave').click(function() { |
207
|
|
|
ipcRenderer.send('app:debug', "Closing Stop modal & exporting"); |
208
|
|
|
ipcRenderer.send('bw:lookup.stop'); |
209
|
|
|
$('#bwProcessingModalStop').removeClass('is-active'); |
210
|
|
|
$('#bwProcessing').addClass('is-hidden'); |
211
|
|
|
setPauseButton(); |
212
|
|
|
$('#bwExport').removeClass('is-hidden'); |
213
|
|
|
|
214
|
|
|
return; |
|
|
|
|
215
|
|
|
}); |
216
|
|
|
|
217
|
|
|
/* |
218
|
|
|
$('#bwProcessingButtonNext').click(function() {...}); |
219
|
|
|
Bulk processing, proceed to export options |
220
|
|
|
*/ |
221
|
|
|
$('#bwProcessingButtonNext').click(function() { |
222
|
|
|
$('#bwProcessing').addClass('is-hidden'); |
223
|
|
|
$('#bwExport').removeClass('is-hidden'); |
224
|
|
|
|
225
|
|
|
return; |
|
|
|
|
226
|
|
|
}); |
227
|
|
|
|