diff options
author | ivan <ivan> | 2000-11-07 15:00:37 +0000 |
---|---|---|
committer | ivan <ivan> | 2000-11-07 15:00:37 +0000 |
commit | 7f07089722bfcabe3bf42619bb2bdb81fd8d44e1 (patch) | |
tree | 8bbfe5b33182d68cd89e63176a11dcc468091ed0 /FS | |
parent | b31966d5d1f9d8629bd28ff1c2ff37a5c84965c1 (diff) |
session monitor
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Record.pm | 8 | ||||
-rw-r--r-- | FS/FS/nas.pm | 12 | ||||
-rw-r--r-- | FS/FS/session.pm | 27 | ||||
-rw-r--r-- | FS/MANIFEST | 4 |
4 files changed, 43 insertions, 8 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index b0bfb0b..59472c8 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -731,10 +731,10 @@ Check/untaint ip addresses. IPv4 only for now. sub ut_ip { my( $self, $field ) = @_; - $self->getfield($field) =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/; + $self->getfield($field) =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ or return "Illegal (IP address) $field: ". $self->getfield($field); - for ( $1 $2 $3 $4 ) { return "Illegal (IP address) $field" if $_ > 255; }; - $self->$setfield($field, "$1.$2.$3.$3"); + for ( $1, $2, $3, $4 ) { return "Illegal (IP address) $field" if $_ > 255; } + $self->setfield($field, "$1.$2.$3.$3"); ''; } @@ -895,7 +895,7 @@ sub hfields { =head1 VERSION -$Id: Record.pm,v 1.8 2000-10-27 20:15:50 ivan Exp $ +$Id: Record.pm,v 1.9 2000-11-07 15:00:37 ivan Exp $ =head1 BUGS diff --git a/FS/FS/nas.pm b/FS/FS/nas.pm index 5ed95f9..873c9bc 100644 --- a/FS/FS/nas.pm +++ b/FS/FS/nas.pm @@ -117,11 +117,21 @@ sub check { || $self->ut_numbern('last'); } +=sub heartbeat TIMESTAMP + +Updates the timestamp for this nas + +=cut + +sub heartbeat { + warn "warning: heartbeat unimplemented!" +} + =back =head1 VERSION -$Id: nas.pm,v 1.1 2000-10-27 20:18:32 ivan Exp $ +$Id: nas.pm,v 1.2 2000-11-07 15:00:37 ivan Exp $ =head1 BUGS diff --git a/FS/FS/session.pm b/FS/FS/session.pm index 0d766bd..b85a582 100644 --- a/FS/FS/session.pm +++ b/FS/FS/session.pm @@ -4,6 +4,8 @@ use strict; use vars qw( @ISA ); use FS::Record qw( qsearchs ); use FS::svc_acct; +use FS::port; +use FS::nas; @ISA = qw(FS::Record); @@ -31,6 +33,8 @@ FS::session - Object methods for session records $error = $record->check; + $error = $record->nas_heartbeat($timestamp); + =head1 DESCRIPTION An FS::session object represents an user login session. FS::session inherits @@ -57,7 +61,7 @@ from FS::Record. The following fields are currently supported: =item new HASHREF -Creates a new example. To add the example to the database, see L<"insert">. +Creates a new session. To add the session to the database, see L<"insert">. Note that this stores the hash reference, not a distinct copy of the hash it points to. You can ask the object for a copy with the I<hash> method. @@ -95,6 +99,8 @@ sub insert { $error = $self->SUPER::insert; return $error if $error; + $self->nas_heartbeat($self->getfield('login')); + #session-starting callback! ''; @@ -136,6 +142,8 @@ sub replace { $error = $self->SUPER::replace; return $error if $error; + $self->nas_heartbeat($self->getfield('logout')); + #session-ending callback! ''; @@ -143,7 +151,7 @@ sub replace { =item check -Checks all fields to make sure this is a valid example. If there is +Checks all fields to make sure this is a valid session. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods. @@ -167,11 +175,24 @@ sub check { ''; } +=item nas_heartbeat + +Heartbeats the nas associated with this session (see L<FS::nas>). + +=cut + +sub nas_heartbeat { + my $self = shift; + my $port = qsearchs('port',{'portnum'=>$self->portnum}); + my $nas = qsearchs('nas',{'nasnum'=>$port->nasnum}); + $nas->heartbeat(shift); +} + =back =head1 VERSION -$Id: session.pm,v 1.1 2000-10-27 20:18:32 ivan Exp $ +$Id: session.pm,v 1.2 2000-11-07 15:00:37 ivan Exp $ =head1 BUGS diff --git a/FS/MANIFEST b/FS/MANIFEST index e0b5b51..91d2e2f 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -40,12 +40,16 @@ FS/svc_acct_pop.pm FS/svc_acct_sm.pm FS/svc_domain.pm FS/type_pkgs.pm +FS/nas.pm +FS/port.pm +FS/session.pm MANIFEST MANIFEST.SKIP Makefile.PL test.pl README bin/freeside-bill +bin/freeside-print-batch FS/domain_record.pm FS/prepay_credit.pm FS/svc_www.pm |