line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Squid::Purge::Multicast; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1161
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw(Net::Squid::Purge); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
87
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6819
|
use IO::Socket::Multicast; |
|
1
|
|
|
|
|
39750
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Net::Squid::Purge::Multicast->mk_accessors(qw(multicast_group multicast_port)); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.1'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub purge { |
15
|
0
|
|
|
0
|
1
|
|
my ($self, @urls) = @_; |
16
|
0
|
0
|
|
|
|
|
if (! $self->multicast_group) { die 'multicast_group must be set!'; } |
|
0
|
|
|
|
|
|
|
17
|
0
|
0
|
|
|
|
|
if (! $self->multicast_port) { die 'multicast_port must be set!'; } |
|
0
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $socket = IO::Socket::Multicast->new( Proto => 'icp', LocalPort => $self->multicast_port); |
20
|
0
|
0
|
|
|
|
|
if (! $socket->mcast_add($self->multicast_group)) { |
21
|
0
|
|
|
|
|
|
die "Couldn't set group: $!\n"; |
22
|
|
|
|
|
|
|
} |
23
|
0
|
|
|
|
|
|
for my $url (@urls) { |
24
|
0
|
0
|
|
|
|
|
if (! $socket->mcast_send($self->_format_request($url))) { warn 'purge request failed'; } |
|
0
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
} |
26
|
0
|
|
|
|
|
|
return 1; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _format_purge { |
30
|
0
|
|
|
0
|
|
|
my ($self, $url) = @_; |
31
|
0
|
|
|
|
|
|
return <<"EOF"; |
32
|
|
|
|
|
|
|
PURGE $url HTTP/1.0 |
33
|
|
|
|
|
|
|
Accept: */* |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
EOF |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
__END__ |