Browse code

First draft

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@935 77e5149b-7576-45b1-b177-96237e5ba77b

Nigel Horne authored on 2004/09/28 02:10:35
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,85 @@
0
+#!/usr/bin/perl -w
1
+
2
+#   Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk>
3
+# 
4
+#   This program is free software; you can redistribute it and/or modify
5
+#   it under the terms of the GNU General Public License as published by
6
+#   the Free Software Foundation; either version 2 of the License, or
7
+#   (at your option) any later version.
8
+# 
9
+#   This program is distributed in the hope that it will be useful,
10
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
+#   GNU General Public License for more details.
13
+# 
14
+#   You should have received a copy of the GNU General Public License
15
+#   along with this program; if not, write to the Free Software
16
+#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+
18
+#	clamavmon - monitor a network for virus intrusion
19
+
20
+eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}' if 0; 
21
+
22
+use strict;
23
+use IO::Socket::INET;
24
+use Tk;
25
+use Tk::Dialog;
26
+use threads;
27
+
28
+my $mw = MainWindow->new;
29
+my $history = "";
30
+
31
+my $text = $mw->Scrolled('Text', -width => 50, -scrollbars => 'ow')->pack;
32
+
33
+my $button1 = $mw->Button(-text => 'About', -command => \&about)->pack(-side => 'left');
34
+# my $button2 = $mw->Button(-text => 'Quit', -command => \&quit)->pack(-side => 'left');
35
+my $button2 = $mw->Button(-text => 'Quit', -command => \&exit)->pack(-side => 'left');
36
+
37
+my $t = threads->new(\&listener);
38
+
39
+my $quitting = 0;
40
+
41
+MainLoop;
42
+
43
+sub listener {
44
+	my $MySocket = IO::Socket::INET->new(
45
+		LocalPort => 3310,
46
+		Proto => 'udp',
47
+		Type => SOCK_DGRAM) or die "$0: socket: $!\n";
48
+
49
+	unless($quitting) {
50
+		my $mess;
51
+		$MySocket->recv($mess, 128);
52
+
53
+		my ($rport, $ipaddr) = sockaddr_in($MySocket->peername);
54
+
55
+		$text->insert('end', "From " . inet_ntoa($ipaddr) . " $mess\n");
56
+
57
+		print "From " . inet_ntoa($ipaddr) . " $mess\n";
58
+ 
59
+		# $text->Contents($history);
60
+		$text->pack;
61
+	}
62
+}
63
+
64
+sub quit {
65
+	$quitting = 1;
66
+	$t->join();
67
+	exit;
68
+}
69
+
70
+sub about {
71
+	my $about = $mw->DialogBox(
72
+		-title=>"About clamAVmon",
73
+		-buttons=>["OK"]
74
+	);
75
+
76
+	$about->add('Label',
77
+		-anchor => 'w',
78
+		-justify => 'left',
79
+		-text => "clamAVmon\n" .
80
+			"Copyright (C) 2004 Nigel Horne njh\@bandsman.co.uk\n" .
81
+			"The GPL Licence will appear here")->pack;
82
+
83
+	$about->Show();
84
+}