line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IRC::Indexer::Report::Server; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
52794
|
use 5.10.1; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
276
|
|
4
|
4
|
|
|
4
|
|
25
|
use strict; |
|
4
|
|
|
|
|
59
|
|
|
4
|
|
|
|
|
132
|
|
5
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
261
|
|
6
|
4
|
|
|
4
|
|
34
|
use Carp; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
565
|
|
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
13704
|
use Storable qw/dclone/; |
|
4
|
|
|
|
|
35232
|
|
|
4
|
|
|
|
|
7372
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
## A single server. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
8
|
|
|
8
|
0
|
207
|
my $self = {}; |
15
|
8
|
|
|
|
|
19
|
my $class = shift; |
16
|
8
|
|
|
|
|
28
|
bless $self, $class; |
17
|
8
|
|
|
|
|
28
|
my %args = @_; |
18
|
8
|
|
|
|
|
42
|
$args{lc $_} = delete $args{$_} for keys %args; |
19
|
|
|
|
|
|
|
|
20
|
8
|
100
|
66
|
|
|
88
|
if ($args{fromhash} && ref $args{fromhash} eq 'HASH') { |
21
|
|
|
|
|
|
|
## given a previously-created hash |
22
|
|
|
|
|
|
|
## does no validation currently |
23
|
2
|
|
|
|
|
331
|
$self->{NetInfo} = dclone($args{fromhash}); |
24
|
|
|
|
|
|
|
} else { |
25
|
6
|
|
|
|
|
32
|
$self->{NetInfo} = {}; |
26
|
|
|
|
|
|
|
} |
27
|
8
|
|
|
|
|
36
|
return $self |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub clone { |
31
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
32
|
0
|
|
|
|
|
0
|
my %args = @_; |
33
|
0
|
|
|
|
|
0
|
$args{lc $_} = $args{$_} for keys %args; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
0
|
my $cloned = dclone($self->{NetInfo}); |
36
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
0
|
delete $cloned->{HashChans} if $args{nochannels}; |
38
|
0
|
0
|
|
|
|
0
|
delete $cloned->{ListChans} if $args{nochannels}; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
return $cloned |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
1
|
0
|
4
|
sub info { netinfo(@_) } |
44
|
|
|
|
|
|
|
sub netinfo { |
45
|
96
|
|
|
96
|
1
|
131
|
my $self = shift; |
46
|
96
|
|
|
|
|
157
|
my %args = @_; |
47
|
96
|
|
|
|
|
246
|
$args{lc $_} = $args{$_} for keys %args; |
48
|
|
|
|
|
|
|
|
49
|
96
|
50
|
|
|
|
232
|
return $self->clone(%args) if $args{nochannels}; |
50
|
|
|
|
|
|
|
|
51
|
96
|
|
|
|
|
776
|
return $self->{NetInfo} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub connectedto { |
55
|
5
|
|
|
5
|
1
|
708
|
my ($self, $server) = @_; |
56
|
5
|
100
|
|
|
|
24
|
return $self->netinfo->{ConnectedTo} = $server if defined $server; |
57
|
3
|
|
|
|
|
9
|
return $self->netinfo->{ConnectedTo} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub connectedat { |
61
|
3
|
|
|
3
|
1
|
7
|
my ($self, $ts) = @_; |
62
|
3
|
100
|
|
|
|
11
|
return $self->netinfo->{ConnectedAt} = $ts if defined $ts; |
63
|
2
|
|
|
|
|
5
|
return $self->netinfo->{ConnectedAt} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub startedat { |
67
|
3
|
|
|
3
|
1
|
8
|
my ($self, $ts) = @_; |
68
|
3
|
100
|
|
|
|
15
|
return $self->netinfo->{StartedAt} = $ts if defined $ts; |
69
|
1
|
|
|
|
|
3
|
return $self->netinfo->{StartedAt} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub finishedat { |
73
|
7
|
|
|
7
|
1
|
15
|
my ($self, $ts) = @_; |
74
|
7
|
100
|
|
|
|
28
|
return $self->netinfo->{FinishedAt} = $ts if defined $ts; |
75
|
3
|
|
|
|
|
7
|
return $self->netinfo->{FinishedAt} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub status { |
79
|
|
|
|
|
|
|
## empty string = nuthin' doin' |
80
|
|
|
|
|
|
|
## INIT = socket connected |
81
|
|
|
|
|
|
|
## CONNECTED = irc_001 |
82
|
|
|
|
|
|
|
## DONE = finished |
83
|
|
|
|
|
|
|
## FAIL = error encountered |
84
|
31
|
|
|
31
|
1
|
48
|
my ($self, $status) = @_; |
85
|
31
|
100
|
|
|
|
84
|
return $self->netinfo->{Status} = $status |
86
|
|
|
|
|
|
|
if defined $status; |
87
|
25
|
|
50
|
|
|
49
|
return $self->netinfo->{Status}//'' |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub failed { |
91
|
6
|
|
|
6
|
1
|
13
|
my ($self, $reason) = @_; |
92
|
|
|
|
|
|
|
## set a failure reason and FAIL status |
93
|
6
|
100
|
|
|
|
15
|
if ($reason) { |
94
|
2
|
|
|
|
|
6
|
$self->status('FAIL'); |
95
|
2
|
|
|
|
|
7
|
$self->netinfo->{Failure} = $reason; |
96
|
|
|
|
|
|
|
} |
97
|
6
|
|
|
|
|
13
|
return $self->netinfo->{Failure} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
0
|
0
|
0
|
sub netname { network(@_) } |
101
|
|
|
|
|
|
|
sub network { |
102
|
2
|
|
|
2
|
1
|
5
|
my ($self, $netname) = @_; |
103
|
2
|
100
|
|
|
|
10
|
return $self->netinfo->{NetName} = $netname |
104
|
|
|
|
|
|
|
if defined $netname; |
105
|
1
|
|
|
|
|
4
|
return $self->netinfo->{NetName} |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
0
|
0
|
0
|
sub servername { server(@_) } |
109
|
|
|
|
|
|
|
sub server { |
110
|
4
|
|
|
4
|
1
|
476
|
my ($self, $server) = @_; |
111
|
4
|
100
|
|
|
|
14
|
return $self->netinfo->{ServerName} = $server if defined $server; |
112
|
3
|
|
|
|
|
7
|
return $self->netinfo->{ServerName} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub blank_motd { |
116
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
117
|
0
|
|
|
|
|
0
|
$self->netinfo->{MOTD} = []; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub motd { |
121
|
4
|
|
|
4
|
1
|
9
|
my ($self, $line) = @_; |
122
|
4
|
100
|
|
|
|
11
|
push(@{ $self->netinfo->{MOTD} }, $line) if defined $line; |
|
2
|
|
|
|
|
5
|
|
123
|
4
|
|
|
|
|
10
|
return $self->netinfo->{MOTD} |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
0
|
0
|
0
|
sub opercount { opers(@_) } |
127
|
|
|
|
|
|
|
sub opers { |
128
|
3
|
|
|
3
|
1
|
6
|
my ($self, $opers) = @_; |
129
|
3
|
100
|
|
|
|
12
|
return $self->netinfo->{OperCount} = $opers |
130
|
|
|
|
|
|
|
if defined $opers; |
131
|
2
|
|
|
|
|
5
|
return $self->netinfo->{OperCount} |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
0
|
0
|
0
|
sub globalusers { users(@_) } |
135
|
|
|
|
|
|
|
sub users { |
136
|
3
|
|
|
3
|
1
|
5
|
my ($self, $global) = @_; |
137
|
3
|
100
|
|
|
|
12
|
return $self->netinfo->{GlobalUsers} = $global |
138
|
|
|
|
|
|
|
if defined $global; |
139
|
2
|
|
|
|
|
5
|
return $self->netinfo->{GlobalUsers} |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
0
|
0
|
0
|
sub listlinks { links(@_) } |
143
|
|
|
|
|
|
|
sub links { |
144
|
1
|
|
|
1
|
1
|
2
|
my ($self, $linklist) = @_; |
145
|
1
|
50
|
33
|
|
|
5
|
return $self->netinfo->{ListLinks} = $linklist |
146
|
|
|
|
|
|
|
if $linklist and ref $linklist eq 'ARRAY'; |
147
|
1
|
|
50
|
|
|
3
|
return $self->netinfo->{ListLinks}//[] |
148
|
|
|
|
|
|
|
## FIXME better links handling |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
0
|
0
|
0
|
sub chancount { totalchans(@_) } |
152
|
|
|
|
|
|
|
sub totalchans { |
153
|
|
|
|
|
|
|
## usually automagically updated |
154
|
1
|
|
|
1
|
1
|
2
|
my ($self, $count) = @_; |
155
|
1
|
50
|
|
|
|
3
|
return $self->netinfo->{ChanCount} = $count |
156
|
|
|
|
|
|
|
if defined $count; |
157
|
1
|
|
|
|
|
3
|
return $self->netinfo->{ChanCount} |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
1
|
|
|
1
|
0
|
5
|
sub listchans { channels(@_) } |
161
|
|
|
|
|
|
|
sub channels { |
162
|
1
|
|
|
1
|
1
|
11
|
my ($self, $chanlist) = @_; |
163
|
1
|
50
|
33
|
|
|
5
|
return $self->netinfo->{ListChans} = $chanlist |
164
|
|
|
|
|
|
|
if $chanlist and ref $chanlist eq 'ARRAY'; |
165
|
1
|
|
|
|
|
4
|
$self->_sort_listchans; |
166
|
1
|
|
|
|
|
3
|
return $self->netinfo->{ListChans} |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
1
|
|
|
1
|
0
|
4
|
sub hashchans { chanhash(@_) } |
170
|
|
|
|
|
|
|
sub chanhash { |
171
|
2
|
|
|
2
|
1
|
4
|
my ($self, $hash) = @_; |
172
|
2
|
50
|
33
|
|
|
17
|
return $self->netinfo->{HashChans} = $hash |
173
|
|
|
|
|
|
|
if $hash and ref $hash eq 'HASH'; |
174
|
2
|
|
|
|
|
4
|
return $self->netinfo->{HashChans} |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub ircd { |
178
|
3
|
|
|
3
|
1
|
6
|
my ($self, $version) = @_; |
179
|
3
|
100
|
|
|
|
11
|
return $self->netinfo->{IRCD} = $version |
180
|
|
|
|
|
|
|
if defined $version; |
181
|
2
|
|
|
|
|
6
|
return $self->netinfo->{IRCD} |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub add_channel { |
185
|
3
|
|
|
3
|
1
|
7
|
my ($self, $channel, $users, $topic) = @_; |
186
|
3
|
50
|
|
|
|
48
|
return unless $channel; |
187
|
3
|
|
50
|
|
|
7
|
$users //= 0; |
188
|
3
|
|
50
|
|
|
8
|
$topic //= ''; |
189
|
3
|
|
|
|
|
13
|
$self->netinfo->{HashChans}->{$channel} = { |
190
|
|
|
|
|
|
|
Topic => $topic, |
191
|
|
|
|
|
|
|
Users => $users, |
192
|
|
|
|
|
|
|
}; |
193
|
3
|
|
|
|
|
6
|
++$self->netinfo->{ChanCount}; |
194
|
3
|
|
|
|
|
12
|
return $channel |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub _sort_listchans { |
198
|
1
|
|
|
1
|
|
3
|
my ($self) = @_; |
199
|
1
|
|
50
|
|
|
5
|
my $chash = $self->netinfo->{HashChans}//{}; |
200
|
1
|
50
|
|
|
|
11
|
return unless keys %$chash; |
201
|
3
|
|
|
|
|
11
|
my @sorted = sort { |
202
|
1
|
|
|
|
|
8
|
$chash->{$b}->{Users} <=> $chash->{$a}->{Users} |
203
|
|
|
|
|
|
|
} keys %$chash; |
204
|
1
|
|
|
|
|
4
|
$self->netinfo->{ListChans} = []; |
205
|
1
|
|
|
|
|
3
|
for my $chan (@sorted) { |
206
|
3
|
|
|
|
|
7
|
my $users = $chash->{$chan}->{Users}; |
207
|
3
|
|
|
|
|
5
|
my $topic = $chash->{$chan}->{Topic}; |
208
|
3
|
|
|
|
|
4
|
push(@{ $self->netinfo->{ListChans} }, [ $chan, $users, $topic ] ); |
|
3
|
|
|
|
|
7
|
|
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
1; |
213
|
|
|
|
|
|
|
__END__ |