line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Session::State::MobileAgentID; |
2
|
2
|
|
|
2
|
|
103808
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
72
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
52
|
|
4
|
2
|
|
|
2
|
|
37
|
use 5.00800; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
106
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.46'; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
1680
|
use HTTP::Session::State::Base; |
|
2
|
|
|
|
|
4173
|
|
|
2
|
|
|
|
|
15
|
|
8
|
2
|
|
|
2
|
|
2090
|
use HTTP::MobileAgent 0.28; |
|
2
|
|
|
|
|
47918
|
|
|
2
|
|
|
|
|
73
|
|
9
|
2
|
|
|
2
|
|
1740
|
use Net::CIDR::MobileJP; |
|
2
|
|
|
|
|
57308
|
|
|
2
|
|
|
|
|
948
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/mobile_agent/); |
12
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw/check_ip cidr/); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
6
|
|
|
6
|
1
|
82162
|
my $class = shift; |
16
|
6
|
50
|
|
|
|
35
|
my %args = ref($_[0]) ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
17
|
|
|
|
|
|
|
# set default values |
18
|
6
|
100
|
|
|
|
23
|
$args{mobile_agent} = exists($args{mobile_agent}) ? $args{mobile_agent} : undef; |
19
|
6
|
100
|
|
|
|
18
|
$args{check_ip} = exists($args{check_ip}) ? $args{check_ip} : 1; |
20
|
6
|
50
|
|
|
|
19
|
$args{permissive} = exists($args{permissive}) ? $args{permissive} : 1; |
21
|
6
|
100
|
|
|
|
26
|
$args{cidr} = exists($args{cidr}) ? $args{cidr} : Net::CIDR::MobileJP->new(); |
22
|
6
|
|
|
|
|
87735
|
bless {%args}, $class; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub get_session_id { |
26
|
6
|
|
|
6
|
0
|
18365
|
my ($self, $req) = @_; |
27
|
6
|
100
|
|
|
|
19
|
unless (defined $self->mobile_agent) { |
28
|
1
|
|
|
|
|
21
|
$self->mobile_agent(HTTP::MobileAgent->new($req->headers)); |
29
|
|
|
|
|
|
|
} |
30
|
6
|
|
|
|
|
239
|
my $ma = $self->mobile_agent; |
31
|
6
|
50
|
66
|
|
|
44
|
Carp::croak "this module only supports docomo/softbank/ezweb" unless $ma->is_docomo || $ma->is_softbank || $ma->is_ezweb; |
|
|
|
66
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
5
|
|
|
|
|
37
|
my $id = $ma->user_id(); |
34
|
5
|
100
|
|
|
|
100
|
if ($id) { |
35
|
4
|
100
|
|
|
|
14
|
if ($self->check_ip) { |
36
|
1
|
|
0
|
|
|
11
|
my $ip = $ENV{REMOTE_ADDR} || (Scalar::Util::blessed($req) ? $req->address : $req->{REMOTE_ADDR}) || die "cannot get client ip address"; |
37
|
1
|
50
|
|
|
|
5
|
if ($self->cidr->get_carrier($ip) ne $ma->carrier) { |
38
|
1
|
|
|
|
|
1329
|
die "SECURITY: invalid ip($ip, $ma, $id)"; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
3
|
|
|
|
|
28
|
return $id; |
42
|
|
|
|
|
|
|
} else { |
43
|
1
|
|
50
|
|
|
21
|
my $ip = $ENV{REMOTE_ADDR} || (Scalar::Util::blessed($req) ? $req->address : $req->{REMOTE_ADDR}) || 'UNKNOWN'; |
44
|
1
|
|
|
|
|
7
|
my $ua = $ma->user_agent(); |
45
|
1
|
|
|
|
|
22
|
die "cannot detect mobile id from: ($ua, $ip)"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
|
2
|
0
|
1699
|
sub response_filter { } |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
__END__ |