Captive-Portal
view release on metacpan or search on metacpan
lib/Captive/Portal/Role/Session.pm view on Meta::CPAN
package Captive::Portal::Role::Session;
use strict;
use warnings;
=head1 NAME
Captive::Portal::Role::Session - session methods for Captive::Portal
=cut
our $VERSION = '4.10';
use Log::Log4perl qw(:easy);
use JSON qw();
use Try::Tiny;
use Digest::MD5 qw(md5_hex);
use Captive::Portal::LockHandle;
use Role::Basic;
requires qw(
cfg
spawn_cmd
normalize_ip
find_mac
);
# Role::Basic exports ALL subroutines, there is currently no other way to
# prevent exporting private methods, sigh
#
my $_init_session = sub {
my ( $self, $ip, $mac ) = @_;
my $new_session = {
STATE => 'init',
IP => $ip,
MAC => $mac,
};
return $new_session;
};
=head1 DESCRIPTION
IP addresses of clients must be unique. They are determined by the HTTP-Parameter I<REMOTE_ADDR>. The corresponding MAC-address is determined from the ARP-table. If there are duplicate IP-addresses for different MAC-addresses something bad is happeni...
Active sessions have corresponding IP/MAC entries in the B<capo_sessions_ipset>.
Session state is recorded on disc under the $SESSIONS_DIR. The session state is JSON encoded.
Example: active session
{
"STATE" : "active",
"START_TIME" : 1317106093,
"STOP_TIME" : "",
"USERNAME" : "foo",
"IP" : "134.60.239.90",
"MAC" : "F0:F4:69:17:89:DE",
"USER_AGENT" : "Mozilla/5.0 ... Safari/534.50",
"COOKIE" : "202ceeee8c0ec85869dbac19c57c3c5e"
}
=head1 ROLES
All roles throw exceptions on error.
=over 4
=item $capo->get_current_session()
Returns the current- or a new initialized session-hash for this HTTP-Client.
=cut
sub get_current_session {
( run in 2.359 seconds using v1.01-cache-2.11-cpan-5511b514fd6 )