X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=fs_selfservice%2FFS-SelfService%2FSelfService%2FFreeRadiusVoip.pm;h=25f673f4ad99ee4d3d7815005687b2a95cd40078;hb=52a824f9b11ca266be10c76894eaf6607344c8d0;hp=47a2bfa782aab9f2490ca81c205da6b78db1cd90;hpb=1b7db3fe3d9049141a13721d658747fe2a006859;p=freeside.git diff --git a/fs_selfservice/FS-SelfService/SelfService/FreeRadiusVoip.pm b/fs_selfservice/FS-SelfService/SelfService/FreeRadiusVoip.pm index 47a2bfa78..25f673f4a 100644 --- a/fs_selfservice/FS-SelfService/SelfService/FreeRadiusVoip.pm +++ b/fs_selfservice/FS-SelfService/SelfService/FreeRadiusVoip.pm @@ -1,29 +1,24 @@ #Add this to the modules section of radiusd.conf # perl { # #path to this module -# module=/usr/local/share/perl/5.8.8/FS/SelfService/FreeRadiusVoip.pm -# func_authenticate = authenticate +# # deb 6 example +# #module=/usr/local/share/perl/5.10.1/FS/SelfService/FreeRadiusVoip.pm +# # deb 7 example +# module=/usr/local/share/perl/5.14.2/FS/SelfService/FreeRadiusVoip.pm +# +# func_authorize = authorize; +# # } # #In the Authorize section #Make sure that you have 'files' uncommented. Then add a line containing 'perl' # after it. # -#In the Authentication section add -# Auth-Type Perl { -# perl -# } -# # #N/A# Add a line containing 'perl' to the Accounting section. # -# In the users file comment the 'DEFAULT Auth-Type = System' lines -# and then add -# DEFAULT Auth-Type = Perl -# Fall-Through = 1 -# -# and on debian systems, add this to /etc/init.d/freeradius, with the +# and on debian 6 systems, add this to /etc/init.d/freeradius, with the # correct path (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=416266) -# LD_PRELOAD=/usr/lib/libperl.so.5.8.8 +# LD_PRELOAD=/usr/lib/libperl.so.5.10 # export LD_PRELOAD BEGIN { $FS::SelfService::skip_uid_check = 1; } @@ -44,17 +39,25 @@ use constant RLM_MODULE_NOOP=> 7; #module succeeded without doing anything use constant RLM_MODULE_UPDATED=> 8; #OK (pairs modified) use constant RLM_MODULE_NUMCODES=> 9; #How many return codes there are -sub authenticate { +sub authorize { - #my $src = $RAD_REQUEST{'User-Name'}; + #&log_request_attributes(); -# my $response = call_time( 'src' => $RAD_REQUEST{'Calling-Station-Id'}, -# 'dst' => $RAD_REQUEST{'Called-Station-Id'}, ); -# -# if $response{$ + my $response = call_time( 'src' => $RAD_REQUEST{'Calling-Station-Id'}, + 'dst' => $RAD_REQUEST{'Called-Station-Id'}, ); - $RAD_REPLY{'Session-Timeout'} = 420; - return RLM_MODULE_UPDATED; + if ( $response->{'error'} ) { + $RAD_REPLY{'Reply-Message'} = $response->{'error'}; + return RLM_MODULE_REJECT; + } elsif ( $response->{'seconds'} ) { + $RAD_REPLY{'Session-Timeout'} = $response->{'seconds'}; + $RAD_REPLY{'Termination-Action'} = 0; + return RLM_MODULE_OK; + } else { + # if the called number is free, put 1 in the Termination-Action attribute + $RAD_REPLY{'Termination-Action'} = 1; + return RLM_MODULE_OK; + } }