line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2013-2019 by [Mark Overmeer]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.02. |
5
|
|
|
|
|
|
|
# This code is part of distribution Any-Daemon-HTTP. Meta-POD processed |
6
|
|
|
|
|
|
|
# with OODoc into POD and HTML manual-pages. See README.md |
7
|
|
|
|
|
|
|
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Any::Daemon::HTTP::Session; |
10
|
1
|
|
|
1
|
|
8
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
60
|
|
11
|
|
|
|
|
|
|
$VERSION = '0.28'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
15
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
6
|
use Log::Report 'any-daemon-http'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
951
|
use Socket qw(inet_aton AF_INET AF_INET6 PF_INET PF_INET6); |
|
1
|
|
|
|
|
3775
|
|
|
1
|
|
|
|
|
446
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
1
|
|
sub new(%) {my $class = shift; (bless {}, $class)->init({@_})} |
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub init($) |
24
|
0
|
|
|
0
|
0
|
|
{ my ($self, $args) = @_; |
25
|
0
|
0
|
|
|
|
|
my $client = $self->{ADHC_store} = $args->{client} or panic; |
26
|
0
|
|
0
|
|
|
|
my $store = $self->{ADHC_store} = $args->{store} || {}; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
0
|
|
|
|
my $peer = $store->{peer} ||= {}; |
29
|
0
|
|
0
|
|
|
|
my $ip = $peer->{ip} ||= $client->peerhost; |
30
|
0
|
0
|
|
|
|
|
if($client->sockdomain==PF_INET) |
|
|
0
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
{ $peer->{host} = gethostbyaddr inet_aton($ip), AF_INET } |
32
|
|
|
|
|
|
|
elsif($client->sockdomain==PF_INET6) |
33
|
0
|
|
|
|
|
|
{ $peer->{host} = gethostbyaddr $ip, AF_INET6 } |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
$self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#----------------- |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
0
|
1
|
|
sub client() {shift->{ADHC_client}} |
41
|
0
|
0
|
|
0
|
1
|
|
sub get(@) {my $s = shift->{ADHC_store}; wantarray ? @{$s}{@_} : $s->{$_[0]}} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
42
|
0
|
|
|
0
|
1
|
|
sub set($$) {$_[0]->{ADHC_store}{$_[1]} = $_[2]} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# should not be used |
45
|
0
|
|
|
0
|
|
|
sub _store() {shift->{ADHC_store}} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |