4 |
|
Begin VB.Form Form1 |
5 |
|
BorderStyle = 3 'Fixed Dialog |
6 |
|
Caption = "i-scream Winhost" |
7 |
< |
ClientHeight = 4905 |
7 |
> |
ClientHeight = 1185 |
8 |
|
ClientLeft = 45 |
9 |
|
ClientTop = 330 |
10 |
|
ClientWidth = 4710 |
12 |
|
LinkTopic = "Form1" |
13 |
|
MaxButton = 0 'False |
14 |
|
MinButton = 0 'False |
15 |
< |
ScaleHeight = 4905 |
15 |
> |
ScaleHeight = 1185 |
16 |
|
ScaleWidth = 4710 |
17 |
|
ShowInTaskbar = 0 'False |
18 |
|
StartUpPosition = 2 'CenterScreen |
36 |
|
Width = 4455 |
37 |
|
End |
38 |
|
Begin VB.CommandButton Hide |
39 |
< |
Caption = "Hide Window" |
40 |
< |
Height = 375 |
41 |
< |
Left = 3120 |
39 |
> |
Caption = "hide" |
40 |
> |
Height = 255 |
41 |
> |
Left = 3960 |
42 |
|
TabIndex = 6 |
43 |
< |
Top = 240 |
44 |
< |
Width = 1455 |
43 |
> |
Top = 480 |
44 |
> |
Width = 615 |
45 |
|
End |
46 |
|
Begin SysTray.SystemTray SystemTray |
47 |
|
Left = 2520 |
139 |
|
Dim seqNo As Long |
140 |
|
Dim machineName As String |
141 |
|
|
142 |
+ |
Dim secondsRunning As Long |
143 |
+ |
|
144 |
|
Dim filterHostname As String |
145 |
|
Dim filterTCPPort As Integer |
146 |
|
Dim filterUDPPort As Integer |
147 |
|
Dim fileList As String |
148 |
|
Dim lastModified As String |
149 |
|
|
150 |
+ |
Dim fourtySevenDays As Integer |
151 |
+ |
|
152 |
|
Dim UDPUpdateTime As Integer |
153 |
|
Dim TCPUpdateTime As Integer |
154 |
|
|
155 |
|
Dim protocolVersion As String |
156 |
|
Dim connected As Boolean |
157 |
+ |
Dim heartBeating As Boolean |
158 |
|
|
159 |
|
Dim CUpTime As New CUpTime |
160 |
|
Dim wksta As New CNetWksta |
184 |
|
End |
185 |
|
End If |
186 |
|
|
187 |
+ |
' Assume the host is run within the first 47 days of the machine starting. |
188 |
+ |
fourtySevenDays = 0 |
189 |
+ |
|
190 |
|
protocolVersion = "1.1" |
191 |
|
|
192 |
|
Status.Caption = "Loading" |
250 |
|
SystemTray.Icon = Val(Form1.Icon) |
251 |
|
End Sub |
252 |
|
|
253 |
+ |
|
254 |
|
Private Sub Reconfigure_Click() |
255 |
|
' establish a TCP connection to a filtermanager |
256 |
< |
connected = False |
257 |
< |
TCPSock.Close |
258 |
< |
TCPSock.Connect filterManagerHostname, filterManagerTCPPort |
256 |
> |
If Not heartBeating Then |
257 |
> |
connected = False |
258 |
> |
TCPSock.Close |
259 |
> |
TCPSock.Connect filterManagerHostname, filterManagerTCPPort |
260 |
> |
Else |
261 |
> |
Status.Caption = "Cannot reconfigure while heartbeating" |
262 |
> |
End If |
263 |
|
End Sub |
264 |
|
|
265 |
|
|
296 |
|
' Remove linefeeds and returns from the line. |
297 |
|
response = Replace(response, Chr(13), "") |
298 |
|
response = Replace(response, Chr(10), "") |
286 |
– |
'Text4.Text = Text4.Text & vbCrLf & response |
299 |
|
|
300 |
|
If connected = False Then |
301 |
|
' Perform TCP configuration (1.1) |
311 |
|
lastModified = response |
312 |
|
Text1.Text = Text1.Text & response & vbCrLf |
313 |
|
TCPSock.SendData "FILELIST" & vbCrLf |
314 |
< |
''' Uncomment this for new protocol release. |
303 |
< |
'Case 2a: |
304 |
< |
'If response = "ERROR" Then GoTo configError |
305 |
< |
'fileList = response |
306 |
< |
'Text1.Text = Text1.Text & response & vbCrLf |
307 |
< |
'TCPSock.SendData "FQDN" & vbCrLf |
314 |
> |
' New addition to the protocol. |
315 |
|
Case 3: |
316 |
|
If response = "ERROR" Then GoTo configError |
317 |
|
fileList = response |
318 |
|
Text1.Text = Text1.Text & response & vbCrLf |
319 |
< |
' REMOVE above line, uncomment next |
313 |
< |
'machineName = response |
314 |
< |
TCPSock.SendData "UDPUpdateTime" & vbCrLf |
319 |
> |
TCPSock.SendData "FQDN" & vbCrLf |
320 |
|
Case 4: |
321 |
|
If response = "ERROR" Then GoTo configError |
322 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
323 |
+ |
machineName = response |
324 |
+ |
TCPSock.SendData "UDPUpdateTime" & vbCrLf |
325 |
+ |
Case 5: |
326 |
+ |
If response = "ERROR" Then GoTo configError |
327 |
|
UDPUpdateTime = response |
328 |
|
Text1.Text = Text1.Text & response & vbCrLf |
329 |
|
TCPSock.SendData "TCPUpdateTime" & vbCrLf |
330 |
< |
Case 5: |
330 |
> |
Case 6: |
331 |
|
If response = "ERROR" Then GoTo configError |
332 |
|
TCPUpdateTime = response |
333 |
|
Text1.Text = Text1.Text & response & vbCrLf |
334 |
|
TCPSock.SendData "ENDCONFIG" & vbCrLf |
335 |
< |
Case 6: |
335 |
> |
Case 7: |
336 |
|
If Not response = "OK" Then GoTo configError |
337 |
|
Text1.Text = Text1.Text & response & vbCrLf |
338 |
|
TCPSock.SendData "FILTER" & vbCrLf |
339 |
< |
Case 7: |
339 |
> |
Case 8: |
340 |
|
Text1.Text = Text1.Text & response & vbCrLf |
341 |
|
'we got a filter list here. |
342 |
|
readTo = 0 |
351 |
|
' get TCP Port number |
352 |
|
filterTCPPort = response |
353 |
|
TCPSock.SendData "END" & vbCrLf |
354 |
< |
Case 8: |
354 |
> |
Case 9: |
355 |
|
If Not response = "OK" Then GoTo configError |
356 |
|
connected = True |
357 |
|
responseNumber = 0 |
365 |
|
End Select |
366 |
|
Else |
367 |
|
' Perform a heartbeat (1.1) |
368 |
+ |
heartBeating = True |
369 |
|
On Error GoTo heartbeatError |
370 |
|
Select Case responseNumber |
371 |
|
Case 1: |
382 |
|
Text1.Text = Text1.Text & response & vbCrLf |
383 |
|
TCPSock.SendData lastModified & vbCrLf |
384 |
|
Case 4: |
385 |
< |
If Not response = "OK" Then GoTo heartbeatError |
385 |
> |
If Not response = "OK" Then |
386 |
> |
heartBeating = False |
387 |
> |
Reconfigure_Click |
388 |
> |
End If |
389 |
|
Text1.Text = Text1.Text & response & vbCrLf |
390 |
|
TCPSock.SendData "ENDHEARTBEAT" & vbCrLf |
391 |
|
Case 5: |
401 |
|
Exit Sub |
402 |
|
|
403 |
|
configError: |
404 |
< |
Status.Caption = "FAILED to get configuration" |
404 |
> |
heartBeating = False |
405 |
> |
Status.Caption = "FAILED to get configuration from the server" |
406 |
|
Exit Sub |
407 |
|
heartbeatError: |
408 |
+ |
heartBeating = False |
409 |
|
Status.Caption = "Heatbeat FAILED" |
410 |
|
Exit Sub |
411 |
|
End Sub |
422 |
|
' prepare the contents of the XML packet. |
423 |
|
seqNo = seqNo + 1 |
424 |
|
|
425 |
< |
' Comment this line in the next protocol |
410 |
< |
machineName = TCPSock.LocalHostName |
425 |
> |
netbiosName = TCPSock.LocalHostName |
426 |
|
|
427 |
|
LocalIP = TCPSock.LocalIP |
428 |
|
packetDate = Date2Num() |
462 |
|
Dim memory& |
463 |
|
GlobalMemoryStatus memsts |
464 |
|
memory& = memsts.dwTotalPhys |
465 |
< |
memTotal = memory& \ 1024 |
465 |
> |
memTotal = memory& \ 1048576 |
466 |
|
memory& = memsts.dwAvailPhys |
467 |
< |
memFree = memory& \ 1024 |
467 |
> |
memFree = memory& \ 1048576 |
468 |
|
memory& = memsts.dwTotalVirtual |
469 |
< |
swapTotal = memory& \ 1024 |
469 |
> |
swapTotal = memory& \ 1048576 |
470 |
|
memory& = memsts.dwAvailVirtual |
471 |
< |
swapFree = memory& \ 1024 |
471 |
> |
swapFree = memory& \ 1048576 |
472 |
|
|
458 |
– |
uptime = CUpTime.MilliSecs \ 1000 |
459 |
– |
|
473 |
|
CUpTime.Capture |
474 |
|
cpu_time = CUpTime.CPUTime |
475 |
|
percent_idle = CUpTime.PercentIdle |
476 |
|
|
477 |
+ |
'' Doesn't work after 47 days :-/ |
478 |
+ |
'uptime = GetTickCount \ 1000 |
479 |
+ |
|
480 |
+ |
'secondsRunning = secondsRunning + UDPUpdateTime |
481 |
+ |
'uptime = secondsRunning |
482 |
+ |
|
483 |
+ |
uptime = CUpTime.MilliSecs / 1000# |
484 |
+ |
|
485 |
+ |
userCount = wksta.LoggedOnUsers |
486 |
+ |
|
487 |
|
' build the contents of the XML packet |
488 |
|
xml = "<packet seq_no=""" & seqNo & """ machine_name=""" & machineName & """ date=""" & packetDate & """ type=""data"" ip=""" & LocalIP & """>" & _ |
489 |
|
"<os>" & _ |
490 |
+ |
"<netbios_name>" & netbiosName & "</netbios_name>" & _ |
491 |
|
"<name>" & osName & "</name>" & _ |
492 |
< |
"<version>" & osVersionMajor & "</version>" & _ |
492 |
> |
"<version>" & osVersionMajor & "." & osVersionMinor & "</version>" & _ |
493 |
|
"<release>" & osBuild & "</release>" & _ |
494 |
< |
"<platform>" & osName & "</platform>" & _ |
471 |
< |
"<minor_version>" & osVersionMinor & "</minor_version>" & _ |
472 |
< |
"<processor>" & processorType & "</processor>" & _ |
494 |
> |
"<platform>" & processorType & "</platform>" & _ |
495 |
|
"<uptime>" & uptime & "</uptime>" & _ |
496 |
|
"</os>" & _ |
497 |
+ |
"<users><count>" & userCount & "</count></users>" & _ |
498 |
|
"<cpu><idle>" & percent_idle & "</idle><user>" & cpu_time & "</user></cpu>" & _ |
499 |
|
"<memory><total>" & memTotal & "</total><free>" & memFree & "</free></memory>" & _ |
500 |
|
"<swap><total>" & swapTotal & "</total><free>" & swapFree & "</free></swap>" & _ |