line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Declare our package |
2
|
|
|
|
|
|
|
package POE::Component::Server::SimpleHTTP::Connection; |
3
|
|
|
|
|
|
|
$POE::Component::Server::SimpleHTTP::Connection::VERSION = '2.26'; |
4
|
|
|
|
|
|
|
#ABSTRACT: Stores connection information for SimpleHTTP |
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
19
|
use strict; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
132
|
|
7
|
6
|
|
|
6
|
|
18
|
use warnings; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
157
|
|
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
18
|
use Socket qw( inet_ntoa unpack_sockaddr_in ); |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
209
|
|
10
|
6
|
|
|
6
|
|
21
|
use POE; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
31
|
|
11
|
|
|
|
|
|
|
|
12
|
6
|
|
|
6
|
|
4276
|
use Moose; |
|
6
|
|
|
|
|
1861011
|
|
|
6
|
|
|
|
|
39
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has dead => ( |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
isa => 'Bool', |
17
|
|
|
|
|
|
|
default => 0, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has ssl => ( |
21
|
|
|
|
|
|
|
is => 'rw', |
22
|
|
|
|
|
|
|
isa => 'Bool', |
23
|
|
|
|
|
|
|
default => 0, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has sslcipher => ( |
27
|
|
|
|
|
|
|
is => 'rw', |
28
|
|
|
|
|
|
|
default => undef, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has remote_ip => ( |
32
|
|
|
|
|
|
|
is => 'ro', |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has remote_port => ( |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has remote_addr => ( |
40
|
|
|
|
|
|
|
is => 'ro', |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has local_ip => ( |
44
|
|
|
|
|
|
|
is => 'ro', |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has local_port => ( |
48
|
|
|
|
|
|
|
is => 'ro', |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has local_addr => ( |
52
|
|
|
|
|
|
|
is => 'ro', |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
has ID => ( |
56
|
|
|
|
|
|
|
is => 'rw', |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has OnClose => ( |
60
|
|
|
|
|
|
|
is => 'ro', |
61
|
|
|
|
|
|
|
default => sub { { } }, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub BUILDARGS { |
65
|
9
|
|
|
9
|
1
|
18
|
my $class = shift; |
66
|
|
|
|
|
|
|
|
67
|
9
|
|
|
|
|
29
|
my $self = { }; |
68
|
|
|
|
|
|
|
|
69
|
9
|
|
|
|
|
12
|
my $socket = shift; |
70
|
|
|
|
|
|
|
|
71
|
9
|
|
|
|
|
15
|
eval { |
72
|
9
|
|
|
|
|
81
|
( $self->{'remote_port'}, $self->{'remote_addr'} ) = |
73
|
|
|
|
|
|
|
unpack_sockaddr_in( getpeername($socket) ); |
74
|
9
|
|
|
|
|
63
|
$self->{'remote_ip'} = inet_ntoa( $self->{'remote_addr'} ); |
75
|
|
|
|
|
|
|
|
76
|
9
|
|
|
|
|
55
|
( $self->{'local_port'}, $self->{'local_addr'} ) = |
77
|
|
|
|
|
|
|
unpack_sockaddr_in( getsockname($socket) ); |
78
|
9
|
|
|
|
|
39
|
$self->{'local_ip'} = inet_ntoa( $self->{'local_addr'} ); |
79
|
|
|
|
|
|
|
}; |
80
|
|
|
|
|
|
|
|
81
|
9
|
50
|
|
|
|
25
|
if ($@) { |
82
|
0
|
|
|
|
|
0
|
return undef; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
9
|
|
|
|
|
299
|
return $self; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub _on_close { |
89
|
2
|
|
|
2
|
|
19
|
my ( $self, $sessionID, $state, @args ) = @_; |
90
|
2
|
50
|
|
|
|
6
|
if ($state) { |
91
|
2
|
|
|
|
|
65
|
$self->OnClose->{$sessionID} = [ $state, @args ]; |
92
|
2
|
|
|
|
|
10
|
$poe_kernel->refcount_increment( $sessionID, __PACKAGE__ ); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
else { |
95
|
0
|
|
|
|
|
0
|
my $data = delete $self->OnClose->{$sessionID}; |
96
|
0
|
0
|
|
|
|
0
|
$poe_kernel->refcount_decrement( $sessionID, __PACKAGE__ ) if $data; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub DEMOLISH { |
101
|
9
|
|
|
9
|
0
|
13
|
my ($self) = @_; |
102
|
9
|
50
|
|
|
|
18
|
while ( my ( $sessionID, $data ) = each %{ $self->OnClose || {} } ) { |
|
11
|
|
|
|
|
444
|
|
103
|
2
|
|
|
|
|
14
|
$poe_kernel->call( $sessionID, @$data ); |
104
|
2
|
|
|
|
|
104
|
$poe_kernel->refcount_decrement( $sessionID, __PACKAGE__ ); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
6
|
|
|
6
|
|
30596
|
no Moose; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
26
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# End of module |
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
__END__ |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=pod |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=encoding UTF-8 |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 NAME |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
POE::Component::Server::SimpleHTTP::Connection - Stores connection information for SimpleHTTP |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 VERSION |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
version 2.26 |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 SYNOPSIS |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
use POE::Component::Server::SimpleHTTP::Connection; |
132
|
|
|
|
|
|
|
my $connection = POE::Component::Server::SimpleHTTP::Connection->new( $socket ); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# Print some stuff |
135
|
|
|
|
|
|
|
print $connection->remote_port; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 DESCRIPTION |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This module simply holds some information from a SimpleHTTP connection. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 METHODS |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
my $connection = POE::Component::Server::SimpleHTTP::Connection->new( $socket ); |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
$connection->remote_ip(); # Returns remote ip in dotted quad format ( 1.1.1.1 ) |
146
|
|
|
|
|
|
|
$connection->remote_port(); # Returns remote port |
147
|
|
|
|
|
|
|
$connection->remote_addr(); # Returns true remote address, consult the L<Socket> POD |
148
|
|
|
|
|
|
|
$connection->local_addr(); # Returns true local address, same as above |
149
|
|
|
|
|
|
|
$connection->local_ip(); # Returns local ip in dotted quad format ( 1.1.1.1 ) |
150
|
|
|
|
|
|
|
$connection->local_port(); # Returns local port |
151
|
|
|
|
|
|
|
$connection->dead(); # Returns a boolean value whether the socket is closed or not |
152
|
|
|
|
|
|
|
$connection->ssl(); # Returns a boolean value whether the socket is SSLified or not |
153
|
|
|
|
|
|
|
$connection->sslcipher(); # Returns the SSL Cipher type or undef if not SSL |
154
|
|
|
|
|
|
|
$connection->ID(); # unique ID of this connection |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 EXPORT |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Nothing. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=for Pod::Coverage DEMOLISH |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 SEE ALSO |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
L<POE::Component::Server::SimpleHTTP>, |
165
|
|
|
|
|
|
|
L<POE::Component::Server::SimpleHTTP::Response> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 AUTHOR |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Apocalypse <APOCAL@cpan.org> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Apocalypse, Chris Williams, Eriam Schaffter, Marlon Bailey and Philip Gwyn. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
176
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |