line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IRC::Indexer::Report::Network; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
14772
|
use 5.10.1; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
92
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
5
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
6
|
2
|
|
|
2
|
|
9
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
179
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
12
|
use Scalar::Util qw/blessed/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
222
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
11
|
use Storable qw/dclone/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1592
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
2
|
|
|
2
|
0
|
542
|
my $self = {}; |
15
|
2
|
|
|
|
|
5
|
my $class = shift; |
16
|
2
|
|
|
|
|
5
|
bless $self, $class; |
17
|
|
|
|
|
|
|
|
18
|
2
|
100
|
|
|
|
9
|
my %args = @_ if @_; |
19
|
2
|
|
|
|
|
9
|
$args{lc $_} = delete $args{$_} for keys %args; |
20
|
|
|
|
|
|
|
|
21
|
2
|
100
|
|
|
|
16
|
$self->{ServerMOTDs} = 1 if $args{servermotds}; |
22
|
|
|
|
|
|
|
|
23
|
2
|
50
|
|
|
|
38
|
if ($args{fromhash}) { |
24
|
0
|
|
|
|
|
0
|
$self->{Network} = delete $args{fromhash}; |
25
|
|
|
|
|
|
|
} else { |
26
|
2
|
|
|
|
|
23
|
$self->{Network} = { |
27
|
|
|
|
|
|
|
Servers => { |
28
|
|
|
|
|
|
|
## ServerName => { |
29
|
|
|
|
|
|
|
## TrawledAt => |
30
|
|
|
|
|
|
|
## IRCD => |
31
|
|
|
|
|
|
|
## # optional: |
32
|
|
|
|
|
|
|
## MOTD => [], |
33
|
|
|
|
|
|
|
## } |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
OperCount => undef, |
37
|
|
|
|
|
|
|
GlobalUsers => undef, |
38
|
|
|
|
|
|
|
ListChans => [], |
39
|
|
|
|
|
|
|
HashChans => {}, |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
ListLinks => [], |
42
|
|
|
|
|
|
|
LastServer => undef, |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
ConnectedAt => undef, |
45
|
|
|
|
|
|
|
FinishedAt => undef, |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
2
|
50
|
|
|
|
9
|
$self->{NOCHANS} = 1 if $args{nochannels}; |
50
|
2
|
|
|
|
|
8
|
return $self |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
## Simple read-only accessors: |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
1
|
0
|
5
|
sub info { netinfo(@_) } |
56
|
|
|
|
|
|
|
sub netinfo { |
57
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
58
|
1
|
|
|
|
|
2
|
my %args = @_; |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
6
|
return $self->{Network} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub servers { |
64
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
65
|
1
|
|
|
|
|
6
|
return $self->{Network}->{Servers} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub motd_for { |
69
|
1
|
|
|
1
|
1
|
2
|
my ($self, $server) = @_; |
70
|
1
|
50
|
|
|
|
6
|
return unless $server; |
71
|
1
|
50
|
|
|
|
5
|
return unless exists $self->{Network}->{Servers}->{$server}; |
72
|
1
|
|
50
|
|
|
8
|
return $self->{Network}->{Servers}->{$server}->{MOTD} // [] |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub opers { |
76
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
77
|
1
|
|
|
|
|
6
|
return $self->{Network}->{OperCount} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub users { |
81
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
82
|
1
|
|
|
|
|
6
|
return $self->{Network}->{GlobalUsers} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
0
|
0
|
0
|
sub hashchans { chanhash(@_) } |
86
|
|
|
|
|
|
|
sub chanhash { |
87
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
88
|
1
|
|
|
|
|
5
|
return $self->{Network}->{HashChans} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub connectedat { |
92
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
93
|
1
|
|
|
|
|
5
|
return $self->{Network}->{ConnectedAt} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub finishedat { |
97
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
98
|
1
|
|
|
|
|
5
|
return $self->{Network}->{FinishedAt} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub lastserver { |
102
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
103
|
1
|
|
|
|
|
7
|
return $self->{Network}->{LastServer} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub add_server { |
107
|
1
|
|
|
1
|
1
|
490
|
my ($self, $info) = @_; |
108
|
|
|
|
|
|
|
## given a Report::Server object (or subclass), merge to this Network |
109
|
1
|
50
|
33
|
|
|
20
|
croak "add_server needs an IRC::Indexer::Report::Server obj" |
110
|
|
|
|
|
|
|
unless blessed $info and $info->isa('IRC::Indexer::Report::Server'); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
## keyed on reported server name |
113
|
|
|
|
|
|
|
## will "break"-ish on dumb nets announcing dumb names: |
114
|
1
|
|
|
|
|
3
|
my $network = $self->{Network}; |
115
|
1
|
|
|
|
|
2
|
my $servers = $network->{Servers}; |
116
|
|
|
|
|
|
|
|
117
|
1
|
|
|
|
|
4
|
my $name = $info->server; |
118
|
1
|
|
|
|
|
5
|
$servers->{$name}->{TrawledAt} = $info->finishedat; |
119
|
1
|
|
|
|
|
5
|
$servers->{$name}->{IRCD} = $info->ircd; |
120
|
1
|
50
|
|
|
|
6
|
$servers->{$name}->{MOTD} = $info->motd |
121
|
|
|
|
|
|
|
if $self->{ServerMOTDs}; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
## these can all be overriden network-wide: |
124
|
1
|
|
|
|
|
5
|
$network->{GlobalUsers} = $info->users; |
125
|
1
|
|
|
|
|
4
|
$network->{OperCount} = $info->opers; |
126
|
1
|
|
|
|
|
5
|
$network->{ChanCount} = $info->totalchans; |
127
|
1
|
50
|
|
|
|
7
|
$network->{HashChans} = $info->chanhash |
128
|
|
|
|
|
|
|
unless $self->{NOCHANS}; |
129
|
1
|
|
|
|
|
5
|
$network->{ConnectedAt} = $info->connectedat; |
130
|
1
|
|
|
|
|
5
|
$network->{FinishedAt} = $info->finishedat; |
131
|
1
|
|
50
|
|
|
6
|
$network->{ListLinks} = $info->links // [] ; |
132
|
1
|
|
|
|
|
5
|
$network->{LastServer} = $name; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
__END__ |