line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Session::State::MobileAttributeID; |
2
|
4
|
|
|
4
|
|
204758
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
157
|
|
3
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
230
|
|
4
|
4
|
|
|
4
|
|
3850
|
use HTTP::Session::State::Base; |
|
4
|
|
|
|
|
5644
|
|
|
4
|
|
|
|
|
28
|
|
5
|
4
|
|
|
|
|
40
|
use HTTP::MobileAttribute plugins => [ |
6
|
|
|
|
|
|
|
'UserID', |
7
|
|
|
|
|
|
|
'CIDR', |
8
|
4
|
|
|
4
|
|
4558
|
]; |
|
4
|
|
|
|
|
432035
|
|
9
|
4
|
|
|
4
|
|
2847963
|
use 5.00800; |
|
4
|
|
|
|
|
20
|
|
|
4
|
|
|
|
|
13530
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.41'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw/mobile_attribute check_ip/); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
5
|
|
|
5
|
1
|
141312
|
my $class = shift; |
16
|
5
|
50
|
|
|
|
32
|
my %args = ref($_[0]) ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
17
|
|
|
|
|
|
|
# check required parameters |
18
|
5
|
|
|
|
|
13
|
for (qw/mobile_attribute/) { |
19
|
5
|
50
|
|
|
|
38
|
Carp::croak "missing parameter $_" unless $args{$_}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
# set default values |
22
|
5
|
100
|
|
|
|
19
|
$args{check_ip} = exists($args{check_ip}) ? $args{check_ip} : 1; |
23
|
5
|
50
|
|
|
|
18
|
$args{permissive} = exists($args{permissive}) ? $args{permissive} : 1; |
24
|
5
|
|
|
|
|
74
|
bless {%args}, $class; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get_session_id { |
28
|
5
|
|
|
5
|
1
|
22403
|
my ($self, $req) = @_; |
29
|
|
|
|
|
|
|
|
30
|
5
|
|
|
|
|
17
|
my $ma = $self->mobile_attribute; |
31
|
5
|
100
|
|
|
|
104
|
if ($ma->can('user_id')) { |
32
|
4
|
100
|
|
|
|
17
|
if (my $user_id = $ma->user_id) { |
33
|
3
|
100
|
|
|
|
216
|
if ($self->check_ip) { |
34
|
1
|
|
0
|
|
|
16
|
my $ip = $ENV{REMOTE_ADDR} || (Scalar::Util::blessed($req) ? $req->address : $req->{REMOTE_ADDR}) || die "cannot get address"; |
35
|
1
|
50
|
|
|
|
8
|
if (!$ma->isa_cidr($ip)) { |
36
|
1
|
|
|
|
|
1404
|
die "SECURITY: invalid ip($ip, $ma, $user_id)"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
2
|
|
|
|
|
21
|
return $user_id; |
40
|
|
|
|
|
|
|
} else { |
41
|
1
|
|
|
|
|
51
|
die "cannot detect mobile id from $ma"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} else { |
44
|
1
|
|
|
|
|
12
|
die "this carrier doesn't supports user_id: $ma"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
2
|
|
|
2
|
1
|
1998
|
sub response_filter { } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
__END__ |