| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package GraphViz::Zone; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
783
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
63
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.01'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
2488
|
use GraphViz; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
|
11
|
|
|
|
|
|
|
my ($this, @args) = @_; |
|
12
|
|
|
|
|
|
|
my $class = shift; |
|
13
|
|
|
|
|
|
|
my $self = bless { @_ }, $class; |
|
14
|
|
|
|
|
|
|
return $self->_init(@_); |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _init { |
|
19
|
|
|
|
|
|
|
my $g = GraphViz->new(directed => 0, width => 7, height => 7); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my ($self, %params) = @_;; |
|
22
|
|
|
|
|
|
|
my ($host, $ip, $text, %host_info); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Caller can set: |
|
25
|
|
|
|
|
|
|
# \- zonefile: (mandatory) |
|
26
|
|
|
|
|
|
|
# \- output: (default to 'zone.png') |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
return undef unless exists($params{zonefile}); |
|
29
|
|
|
|
|
|
|
$self->{output} ||= 'zone.png'; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Open the zone file for reading. |
|
32
|
|
|
|
|
|
|
open(ZONEFILE, $self->{zonefile}); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
while() { |
|
35
|
|
|
|
|
|
|
# If we have an A record. |
|
36
|
|
|
|
|
|
|
if (m/^(\w*)\s+IN\s+A\s+(.*)$/) { |
|
37
|
|
|
|
|
|
|
if (length($2) > 0) { |
|
38
|
|
|
|
|
|
|
# Create a hash entry for the host, add the IP. |
|
39
|
|
|
|
|
|
|
$host_info{$1}{ip} = $2; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# If we have a TXT record. |
|
44
|
|
|
|
|
|
|
if (m/^(\w*)\s+IN\s+TXT\s+"(.*)"$/) { |
|
45
|
|
|
|
|
|
|
# Add the TXT entry to the host's hash key. |
|
46
|
|
|
|
|
|
|
my $text = $2; |
|
47
|
|
|
|
|
|
|
if (length($text) > 0 and exists($host_info{$1})) { |
|
48
|
|
|
|
|
|
|
$host_info{$1}{text} = $text; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$g->add_node($self->{zonefile}); |
|
54
|
|
|
|
|
|
|
for(keys %host_info) { |
|
55
|
|
|
|
|
|
|
my $string = "$_\n"; |
|
56
|
|
|
|
|
|
|
$string .= "IP: $host_info{$_}{ip}\n" if (defined ($host_info{$_}{ip})); |
|
57
|
|
|
|
|
|
|
$string .= "Text: $host_info{$_}{text}" if (defined ($host_info{$_}{text})); |
|
58
|
|
|
|
|
|
|
$g->add_node($_, label => $string, minlen => 5, weight => 0.5); |
|
59
|
|
|
|
|
|
|
$g->add_edge($self->{zonefile} => $_); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$g->as_png($self->{output}); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
|
68
|
|
|
|
|
|
|
__END__ |