| 4 |
|
Begin VB.Form Form1 |
| 5 |
|
BorderStyle = 3 'Fixed Dialog |
| 6 |
|
Caption = "i-scream Winhost" |
| 7 |
< |
ClientHeight = 1275 |
| 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 = 1275 |
| 15 |
> |
ScaleHeight = 1185 |
| 16 |
|
ScaleWidth = 4710 |
| 17 |
|
ShowInTaskbar = 0 'False |
| 18 |
|
StartUpPosition = 2 'CenterScreen |
| 19 |
|
Visible = 0 'False |
| 20 |
+ |
Begin VB.CommandButton Command1 |
| 21 |
+ |
Caption = "more" |
| 22 |
+ |
Height = 255 |
| 23 |
+ |
Left = 3960 |
| 24 |
+ |
TabIndex = 8 |
| 25 |
+ |
Top = 840 |
| 26 |
+ |
Width = 615 |
| 27 |
+ |
End |
| 28 |
+ |
Begin VB.TextBox Text1 |
| 29 |
+ |
Height = 2055 |
| 30 |
+ |
Left = 120 |
| 31 |
+ |
Locked = -1 'True |
| 32 |
+ |
MultiLine = -1 'True |
| 33 |
+ |
ScrollBars = 2 'Vertical |
| 34 |
+ |
TabIndex = 7 |
| 35 |
+ |
Top = 1200 |
| 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 = 480 |
| 44 |
< |
Width = 1455 |
| 44 |
> |
Width = 615 |
| 45 |
|
End |
| 46 |
|
Begin SysTray.SystemTray SystemTray |
| 47 |
< |
Left = 2160 |
| 48 |
< |
Top = 1800 |
| 47 |
> |
Left = 2520 |
| 48 |
> |
Top = 4200 |
| 49 |
|
_ExtentX = 847 |
| 50 |
|
_ExtentY = 847 |
| 51 |
|
SysTrayText = "i-scream Winhost" |
| 52 |
|
IconFile = 0 |
| 53 |
|
End |
| 54 |
|
Begin VB.Timer Timer1 |
| 55 |
< |
Left = 2760 |
| 56 |
< |
Top = 1800 |
| 55 |
> |
Left = 3120 |
| 56 |
> |
Top = 4200 |
| 57 |
|
End |
| 58 |
|
Begin VB.CommandButton Reconfigure |
| 59 |
|
Caption = "Reconfigure with FilterManager" |
| 60 |
|
Height = 375 |
| 61 |
< |
Left = 120 |
| 61 |
> |
Left = 840 |
| 62 |
|
TabIndex = 0 |
| 63 |
< |
Top = 480 |
| 63 |
> |
Top = 3480 |
| 64 |
|
Width = 2895 |
| 65 |
|
End |
| 66 |
|
Begin MSWinsockLib.Winsock TCPSock |
| 67 |
< |
Left = 3720 |
| 68 |
< |
Top = 1800 |
| 67 |
> |
Left = 4080 |
| 68 |
> |
Top = 4200 |
| 69 |
|
_ExtentX = 741 |
| 70 |
|
_ExtentY = 741 |
| 71 |
|
_Version = 393216 |
| 72 |
|
End |
| 73 |
|
Begin MSWinsockLib.Winsock UDPSock |
| 74 |
< |
Left = 3240 |
| 75 |
< |
Top = 1800 |
| 74 |
> |
Left = 3600 |
| 75 |
> |
Top = 4200 |
| 76 |
|
_ExtentX = 741 |
| 77 |
|
_ExtentY = 741 |
| 78 |
|
_Version = 393216 |
| 82 |
|
Alignment = 1 'Right Justify |
| 83 |
|
Caption = "Next heartbeat:" |
| 84 |
|
Height = 255 |
| 85 |
< |
Left = 2400 |
| 85 |
> |
Left = 120 |
| 86 |
|
TabIndex = 5 |
| 87 |
< |
Top = 120 |
| 87 |
> |
Top = 480 |
| 88 |
|
Width = 1455 |
| 89 |
|
End |
| 90 |
|
Begin VB.Label Label1 |
| 100 |
|
BorderStyle = 1 'Fixed Single |
| 101 |
|
Caption = "0" |
| 102 |
|
Height = 255 |
| 103 |
< |
Left = 3960 |
| 103 |
> |
Left = 1680 |
| 104 |
|
TabIndex = 3 |
| 105 |
< |
Top = 120 |
| 105 |
> |
Top = 480 |
| 106 |
|
Width = 615 |
| 107 |
|
End |
| 108 |
|
Begin VB.Label Label3 |
| 120 |
|
Height = 255 |
| 121 |
|
Left = 0 |
| 122 |
|
TabIndex = 1 |
| 123 |
< |
Top = 960 |
| 124 |
< |
Width = 4695 |
| 123 |
> |
Top = 840 |
| 124 |
> |
Width = 3855 |
| 125 |
|
End |
| 126 |
|
End |
| 127 |
|
Attribute VB_Name = "Form1" |
| 154 |
|
Dim CUpTime As New CUpTime |
| 155 |
|
Dim wksta As New CNetWksta |
| 156 |
|
|
| 157 |
+ |
Dim windowBig As Boolean |
| 158 |
+ |
|
| 159 |
|
Dim responseNumber As Integer |
| 160 |
|
|
| 161 |
+ |
Private Sub Command1_Click() |
| 162 |
+ |
|
| 163 |
+ |
' Toggle visibility of the debug output. |
| 164 |
+ |
|
| 165 |
+ |
If windowBig Then |
| 166 |
+ |
Form1.Height = 1500 |
| 167 |
+ |
windowBig = False |
| 168 |
+ |
Else |
| 169 |
+ |
Form1.Height = 4350 |
| 170 |
+ |
windowBig = True |
| 171 |
+ |
End If |
| 172 |
+ |
|
| 173 |
+ |
End Sub |
| 174 |
+ |
|
| 175 |
|
Private Sub Form_Load() |
| 176 |
|
|
| 177 |
|
If App.PrevInstance Then |
| 191 |
|
End |
| 192 |
|
End If |
| 193 |
|
|
| 194 |
+ |
windowBig = False |
| 195 |
+ |
|
| 196 |
|
''''TEMP |
| 197 |
|
'filterManagerHostname = "killigrew.ukc.ac.uk" |
| 198 |
|
'filterManagerTCPPort = 4567 |
| 242 |
|
SystemTray.Icon = Val(Form1.Icon) |
| 243 |
|
End Sub |
| 244 |
|
|
| 245 |
+ |
Private Sub Image1_Click() |
| 246 |
+ |
|
| 247 |
+ |
End Sub |
| 248 |
+ |
|
| 249 |
|
Private Sub Reconfigure_Click() |
| 250 |
|
' establish a TCP connection to a filtermanager |
| 251 |
|
connected = False |
| 287 |
|
' Remove linefeeds and returns from the line. |
| 288 |
|
response = Replace(response, Chr(13), "") |
| 289 |
|
response = Replace(response, Chr(10), "") |
| 250 |
– |
'Text4.Text = Text4.Text & vbCrLf & response |
| 290 |
|
|
| 291 |
|
If connected = False Then |
| 292 |
|
' Perform TCP configuration (1.1) |
| 295 |
|
Case 1: |
| 296 |
|
If Not response = "OK" Then GoTo configError |
| 297 |
|
TCPSock.SendData "LASTMODIFIED" & vbCrLf |
| 298 |
+ |
Text1.Text = "Requesting configuration from FilterManager:- " & vbCrLf |
| 299 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
| 300 |
|
Case 2: |
| 301 |
|
If response = "ERROR" Then GoTo configError |
| 302 |
|
lastModified = response |
| 303 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
| 304 |
|
TCPSock.SendData "FILELIST" & vbCrLf |
| 305 |
+ |
' New addition to the protocol. |
| 306 |
|
Case 3: |
| 307 |
|
If response = "ERROR" Then GoTo configError |
| 308 |
|
fileList = response |
| 309 |
< |
TCPSock.SendData "UDPUpdateTime" & vbCrLf |
| 309 |
> |
Text1.Text = Text1.Text & response & vbCrLf |
| 310 |
> |
TCPSock.SendData "FQDN" & vbCrLf |
| 311 |
|
Case 4: |
| 312 |
|
If response = "ERROR" Then GoTo configError |
| 313 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
| 314 |
+ |
machineName = response |
| 315 |
+ |
TCPSock.SendData "UDPUpdateTime" & vbCrLf |
| 316 |
+ |
Case 5: |
| 317 |
+ |
If response = "ERROR" Then GoTo configError |
| 318 |
|
UDPUpdateTime = response |
| 319 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
| 320 |
|
TCPSock.SendData "TCPUpdateTime" & vbCrLf |
| 321 |
< |
Case 5: |
| 321 |
> |
Case 6: |
| 322 |
|
If response = "ERROR" Then GoTo configError |
| 323 |
|
TCPUpdateTime = response |
| 324 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
| 325 |
|
TCPSock.SendData "ENDCONFIG" & vbCrLf |
| 326 |
< |
Case 6: |
| 326 |
> |
Case 7: |
| 327 |
|
If Not response = "OK" Then GoTo configError |
| 328 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
| 329 |
|
TCPSock.SendData "FILTER" & vbCrLf |
| 330 |
< |
Case 7: |
| 330 |
> |
Case 8: |
| 331 |
> |
Text1.Text = Text1.Text & response & vbCrLf |
| 332 |
|
'we got a filter list here. |
| 333 |
|
readTo = 0 |
| 334 |
|
' get hostname |
| 342 |
|
' get TCP Port number |
| 343 |
|
filterTCPPort = response |
| 344 |
|
TCPSock.SendData "END" & vbCrLf |
| 345 |
< |
Case 8: |
| 345 |
> |
Case 9: |
| 346 |
|
If Not response = "OK" Then GoTo configError |
| 347 |
|
connected = True |
| 348 |
|
responseNumber = 0 |
| 349 |
|
TCPSock.Close |
| 350 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
| 351 |
|
'Text4.Text = Text4.Text & vbCrLf & " <closed>" |
| 352 |
|
Status.Caption = "Configuration successful" |
| 353 |
|
Label3.Caption = UDPUpdateTime |
| 360 |
|
Select Case responseNumber |
| 361 |
|
Case 1: |
| 362 |
|
If Not response = "OK" Then GoTo heartbeatError |
| 363 |
+ |
Text1.Text = "Performing heartbeat: -" & vbCrLf |
| 364 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
| 365 |
|
TCPSock.SendData "CONFIG" & vbCrLf |
| 366 |
|
Case 2: |
| 367 |
|
If Not response = "OK" Then GoTo heartbeatError |
| 368 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
| 369 |
|
TCPSock.SendData fileList & vbCrLf |
| 370 |
|
Case 3: |
| 371 |
|
If Not response = "OK" Then GoTo heartbeatError |
| 372 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
| 373 |
|
TCPSock.SendData lastModified & vbCrLf |
| 374 |
|
Case 4: |
| 375 |
|
If Not response = "OK" Then GoTo heartbeatError |
| 376 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
| 377 |
|
TCPSock.SendData "ENDHEARTBEAT" & vbCrLf |
| 378 |
|
Case 5: |
| 379 |
|
If Not response = "OK" Then GoTo heartbeatError |
| 380 |
+ |
Text1.Text = Text1.Text & response & vbCrLf |
| 381 |
|
TCPSock.Close |
| 382 |
|
Status.Caption = "Heartbeat sent successfully." |
| 383 |
|
End Select |
| 406 |
|
|
| 407 |
|
' prepare the contents of the XML packet. |
| 408 |
|
seqNo = seqNo + 1 |
| 409 |
< |
machineName = TCPSock.LocalHostName |
| 409 |
> |
|
| 410 |
> |
' Comment this line in the next protocol |
| 411 |
> |
'machineName = TCPSock.LocalHostName |
| 412 |
> |
|
| 413 |
|
LocalIP = TCPSock.LocalIP |
| 414 |
|
packetDate = Date2Num() |
| 415 |
|
|
| 448 |
|
Dim memory& |
| 449 |
|
GlobalMemoryStatus memsts |
| 450 |
|
memory& = memsts.dwTotalPhys |
| 451 |
< |
memTotal = memory& \ 1024 |
| 451 |
> |
memTotal = memory& \ 1048576 |
| 452 |
|
memory& = memsts.dwAvailPhys |
| 453 |
< |
memFree = memory& \ 1024 |
| 453 |
> |
memFree = memory& \ 1048576 |
| 454 |
|
memory& = memsts.dwTotalVirtual |
| 455 |
< |
swapTotal = memory& \ 1024 |
| 455 |
> |
swapTotal = memory& \ 1048576 |
| 456 |
|
memory& = memsts.dwAvailVirtual |
| 457 |
< |
swapFree = memory& \ 1024 |
| 457 |
> |
swapFree = memory& \ 1048576 |
| 458 |
|
|
| 459 |
|
uptime = CUpTime.MilliSecs \ 1000 |
| 460 |
|
|
| 462 |
|
cpu_time = CUpTime.CPUTime |
| 463 |
|
percent_idle = CUpTime.PercentIdle |
| 464 |
|
|
| 465 |
+ |
userCount = wksta.LoggedOnUsers |
| 466 |
+ |
|
| 467 |
|
' build the contents of the XML packet |
| 468 |
|
xml = "<packet seq_no=""" & seqNo & """ machine_name=""" & machineName & """ date=""" & packetDate & """ type=""data"" ip=""" & LocalIP & """>" & _ |
| 469 |
|
"<os>" & _ |
| 475 |
|
"<processor>" & processorType & "</processor>" & _ |
| 476 |
|
"<uptime>" & uptime & "</uptime>" & _ |
| 477 |
|
"</os>" & _ |
| 478 |
+ |
"<users><count>" & userCount & "</count></users>" & _ |
| 479 |
|
"<cpu><idle>" & percent_idle & "</idle><user>" & cpu_time & "</user></cpu>" & _ |
| 480 |
|
"<memory><total>" & memTotal & "</total><free>" & memFree & "</free></memory>" & _ |
| 481 |
|
"<swap><total>" & swapTotal & "</total><free>" & swapFree & "</free></swap>" & _ |
| 482 |
|
"</packet>" |
| 483 |
< |
'Text4.Text = Text4.Text + xml |
| 483 |
> |
Text1.Text = "Last packet contained: -" & vbCrLf & xml |
| 484 |
|
|
| 485 |
|
' Use the first winsock control to send a UDP packet. |
| 486 |
|
UDPSock.RemoteHost = filterHostname |