diff options
author | ivan <ivan> | 2008-10-24 01:19:46 +0000 |
---|---|---|
committer | ivan <ivan> | 2008-10-24 01:19:46 +0000 |
commit | 2641816698538bbe52d56365266a66e292ce08f1 (patch) | |
tree | 256e1b852699ab63318b07df2af9a8311ed799b3 /FS | |
parent | ee2d1447f9130fb9ed20d54f0169ab7a8f87167e (diff) |
add phone_sqlradius export
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Conf.pm | 7 | ||||
-rw-r--r-- | FS/FS/part_export/phone_sqlradius.pm | 92 | ||||
-rw-r--r-- | FS/FS/part_export/sqlradius.pm | 26 | ||||
-rw-r--r-- | FS/FS/svc_phone.pm | 30 |
4 files changed, 142 insertions, 13 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 7eea4f7ea..882140fdb 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -2491,6 +2491,13 @@ worry that config_items is freeside-specific and icky. 'type' => 'text', }, + { + 'key' => 'svc_phone-radius-default_password', + 'section' => '', + 'description' => 'Default password when exporting svc_phone records to RADIUS', + 'type' => 'text', + }, + ); 1; diff --git a/FS/FS/part_export/phone_sqlradius.pm b/FS/FS/part_export/phone_sqlradius.pm new file mode 100644 index 000000000..b93fe8c1a --- /dev/null +++ b/FS/FS/part_export/phone_sqlradius.pm @@ -0,0 +1,92 @@ +package FS::part_export::phone_sqlradius; + +use vars qw(@ISA $DEBUG %info ); +use Tie::IxHash; +use FS::Record; #qw( dbh qsearch qsearchs str2time_sql ); +#use FS::part_export; +use FS::part_export::sqlradius; +#use FS::svc_phone; +#use FS::export_svc; +#use Carp qw( cluck ); + +@ISA = qw(FS::part_export::sqlradius); + +$DEBUG = 0; + +tie %options, 'Tie::IxHash', + 'datasrc' => { label=>'DBI data source ' }, + 'username' => { label=>'Database username' }, + 'password' => { label=>'Database password' }, + 'ignore_accounting' => { + type => 'checkbox', + label => 'Ignore accounting records from this database' + }, + 'hide_ip' => { + type => 'checkbox', + label => 'Hide IP address information on session reports', + }, + 'hide_data' => { + type => 'checkbox', + label => 'Hide download/upload information on session reports', + }, + + #should be default for this one, right? + #'show_called_station' => { + # type => 'checkbox', + # label => 'Show the Called-Station-ID on session reports', + #}, + + #N/A + #'overlimit_groups' => { label => 'Radius groups to assign to svc_acct which has exceeded its bandwidth or time limit', } , + #'groups_susp_reason' => { label => + # 'Radius group mapping to reason (via template user) (svcnum|username|username@domain reasonnum|reason)', + # type => 'textarea', + # }, + +; + +%info = ( + 'svc' => 'svc_phone', + 'desc' => 'Real-time export to SQL-backed RADIUS (FreeRADIUS, ICRADIUS) for phone provisioning and rating', + 'options' => \%options, + 'notes' => <<END, +Real-time export of <b>radcheck</b> table +<!--, <b>radreply</b> and <b>usergroup</b>-- tables> +to any SQL database for <a href="http://www.freeradius.org/">FreeRADIUS</a> +or <a href="http://radius.innercite.com/">ICRADIUS</a>. +<br><br> + +This export is for phone/VoIP provisioning and rating. For a regular RADIUS +export, see sqlradius. +<br><br> + +<!--An existing RADIUS database will be updated in realtime, but you can use +<a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.9:Documentation:Developer/bin/freeside-phone_sqlradius-reset">freeside-phone_sqlradius-reset</a> +to delete the entire RADIUS database and repopulate the tables from the +Freeside database. +<br><br> +--> + +See the +<a href="http://search.cpan.org/dist/DBI/DBI.pm#connect">DBI documentation</a> +and the +<a href="http://search.cpan.org/search?mode=module&query=DBD%3A%3A">documentation for your DBD</a> +for the exact syntax of a DBI data source. + +END +); + +sub rebless { shift; } + +sub export_username { + my($self, $svc_phone) = (shift, shift); + $svc_phone->countrycode. $svc_phone->phonenum; +} + +sub _export_suspend {} +sub _export_unsuspend {} + +#probably harmless that we ->can('usage_sessions').... ? + +1; + diff --git a/FS/FS/part_export/sqlradius.pm b/FS/FS/part_export/sqlradius.pm index a89d4d764..fca6e09fe 100644 --- a/FS/FS/part_export/sqlradius.pm +++ b/FS/FS/part_export/sqlradius.pm @@ -49,7 +49,7 @@ END $notes2 = <<'END'; An existing RADIUS database will be updated in realtime, but you can use -<a href="../docs/man/bin/freeside-sqlradius-reset">freeside-sqlradius-reset</a> +<a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.9:Documentation:Developer/bin/freeside-sqlradius-reset">freeside-sqlradius-reset</a> to delete the entire RADIUS database and repopulate the tables from the Freeside database. See the <a href="http://search.cpan.org/dist/DBI/DBI.pm#connect">DBI documentation</a> @@ -95,24 +95,24 @@ sub export_username { } sub _export_insert { - my($self, $svc_acct) = (shift, shift); + my($self, $svc_x) = (shift, shift); foreach my $table (qw(reply check)) { my $method = "radius_$table"; - my %attrib = $svc_acct->$method(); + my %attrib = $svc_x->$method(); next unless keys %attrib; - my $err_or_queue = $self->sqlradius_queue( $svc_acct->svcnum, 'insert', - $table, $self->export_username($svc_acct), %attrib ); + my $err_or_queue = $self->sqlradius_queue( $svc_x->svcnum, 'insert', + $table, $self->export_username($svc_x), %attrib ); return $err_or_queue unless ref($err_or_queue); } - my @groups = $svc_acct->radius_groups; + my @groups = $svc_x->radius_groups; if ( @groups ) { - cluck localtime(). ": queuing usergroup_insert for ". $svc_acct->svcnum. - " (". $self->export_username($svc_acct). " with ". join(", ", @groups) + cluck localtime(). ": queuing usergroup_insert for ". $svc_x->svcnum. + " (". $self->export_username($svc_x). " with ". join(", ", @groups) if $DEBUG; my $err_or_queue = $self->sqlradius_queue( - $svc_acct->svcnum, 'usergroup_insert', - $self->export_username($svc_acct), @groups ); + $svc_x->svcnum, 'usergroup_insert', + $self->export_username($svc_x), @groups ); return $err_or_queue unless ref($err_or_queue); } ''; @@ -283,9 +283,9 @@ sub _export_unsuspend { } sub _export_delete { - my( $self, $svc_acct ) = (shift, shift); - my $err_or_queue = $self->sqlradius_queue( $svc_acct->svcnum, 'delete', - $self->export_username($svc_acct) ); + my( $self, $svc_x ) = (shift, shift); + my $err_or_queue = $self->sqlradius_queue( $svc_x->svcnum, 'delete', + $self->export_username($svc_x) ); ref($err_or_queue) ? '' : $err_or_queue; } diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm index b91ba6551..965f3a577 100644 --- a/FS/FS/svc_phone.pm +++ b/FS/FS/svc_phone.pm @@ -2,6 +2,7 @@ package FS::svc_phone; use strict; use vars qw( @ISA @pw_set ); +use FS::Conf; #use FS::Record qw( qsearch qsearchs ); use FS::svc_Common; @@ -217,6 +218,35 @@ sub check_pin { $check_pin eq $self->pin; } +=item radius_reply + +=cut + +sub radius_reply { + my $self = shift; + #XXX Session-Timeout! holy shit, need rlm_perl to ask for this in realtime + {}; +} + +=item radius_check + +=cut + +sub radius_check { + my $self = shift; + my %check = (); + + my $conf = new FS::Conf; + + $check{'User-Password'} = $conf->config('svc_phone-radius-default_password'); + + %check; +} + +sub radius_groups { + (); +} + =back =head1 BUGS |