Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • smradius/smradius
  • centiva-shail/smradius
  • nkukard/smradius
3 results
Show changes
Commits on Source (178)
stages: stages:
- default - quality
- tests
- install
publish:
stage: default
code-quality:
stage: quality
script: script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update - apt-get update
- apt-get dist-upgrade -y - apt-get dist-upgrade -y
- apt-get install -y perl-modules
- apt-get install -y make
- apt-get install -y libperl-critic-perl - apt-get install -y libperl-critic-perl
- perlcritic --gentle "$CI_PROJECT_DIR" - perlcritic --gentle "$CI_PROJECT_DIR"
make-test:
stage: tests
script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
- apt-get dist-upgrade -y
- apt-get install -y git make
- apt-get install -y libdevel-cover-perl libpod-coverage-perl libtest-most-perl
- apt-get install -y libnet-server-perl libconfig-inifiles-perl libdatetime-perl libcache-fastmmap-perl libtimedate-perl
libcrypt-des-perl libcrypt-rc4-perl libdigest-sha-perl libdigest-md4-perl libmime-lite-perl
- apt-get install -y mariadb-server
# Start services and create dirs we need
- service mysql start
- mkdir /var/run/smradius
# Update our dependencies
- cd "$CI_PROJECT_DIR"
- ./update-git-modules
- perl -MCPAN -e 'install Math::Expression' < /dev/null
# Build Makefile and make
- perl Makefile.PL
- make
# Convert DB into MySQL
- blib/script/convert-tsql MySQL database/core.tsql > database/core.mysql
- blib/script/convert-tsql MySQL database/users-accounting-summary.tsql > database/users-accounting-summary.mysql
- blib/script/convert-tsql MySQL database/wisp.tsql > database/wisp.mysql
# Load SQL into DB
- echo "CREATE DATABASE smradiustest;" | mysql -u root
- mysql -u root smradiustest < database/core.mysql
- mysql -u root smradiustest < database/users-accounting-summary.mysql
- mysql -u root smradiustest < database/wisp.mysql
# Sort out config file
- cp smradiusd.conf smradiusd.conf.test
- perl -pi -e 's/database=smradius/database=smradiustest/' smradiusd.conf.test
# Run tests, exclude all but smradius
- DBTESTS=1 cover -test -ignore_re '.*' -select_re '^blib\/lib\/smradius\/' | tee devel-coverage.txt
- grep "^Total" devel-coverage.txt | awk '{ print "(" $8 "%) covered" }'
make-install:
stage: install
script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
- apt-get dist-upgrade -y
- apt-get install -y git make
- apt-get install -y mariadb-server
- cd "$CI_PROJECT_DIR"
- ./update-git-modules
- perl Makefile.PL
- make install
[submodule "awitpt"]
path = awitpt
url = https://gitlab.devlabs.linuxassist.net/awit-frameworks/awit-perl-toolkit.git
[submodule "webgui/awitef"] [submodule "webgui/awitef"]
path = webgui/awitef path = webgui/awitef
url = https://gitlab.devlabs.linuxassist.net/awit-frameworks/awit-extjs-framework.git url = https://gitlab.devlabs.linuxassist.net/awit-frameworks/awit-extjs-framework.git
[submodule "awitpt"]
path = 3rdparty/awitpt
url = https://gitlab.devlabs.linuxassist.net/awit-frameworks/awit-perl-toolkit.git
branch = v1.0.x
# Makefile
# Copyright (C) 2014-2016, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
use warnings;
use ExtUtils::MakeMaker;
use File::Find;
my @additionalDirs = ();
find(
{
wanted => sub {
if (/^Makefile.PL$/) {
my $dirname = $File::Find::dir;
if ($dirname ne ".") {
$dirname =~ s,\./,,;
push(@additionalDirs,$dirname);
}
};
},
bydepth => 1,
},
".",
);
WriteMakefile(
'NAME' => 'SMRadius-3rdParty',
'DIR' => \@additionalDirs,
);
# vim: ts=4
awitpt @ 6944c201
Subproject commit 6944c2017372a13a334f902fdd8461e171393949
...@@ -27,7 +27,7 @@ Enhanced features: ...@@ -27,7 +27,7 @@ Enhanced features:
* Plugin: Topups * Plugin: Topups
* Plugin: Auto-topups * Plugin: Auto-topups
* Plugin: Usage/Time caps * Plugin: Usage/Time caps
* Plugin: Prepaid accounting based on usage/time * Plugin: Prepaid accounting based on usage/time
* Plugin: Creation of accounting START records when no START record has been received but an interim update has - helps on slow/lossly links * Plugin: Creation of accounting START records when no START record has been received but an interim update has - helps on slow/lossly links
* Plugin: Notifications, % based or approximate time based * Plugin: Notifications, % based or approximate time based
* Plugin: User blacklists * Plugin: User blacklists
......
...@@ -8,10 +8,10 @@ Installing SMRadius. ...@@ -8,10 +8,10 @@ Installing SMRadius.
- Cache::FastMmap (Debian based: libcache-fastmmap-perl, RPM based: perl-Cache-FastMmap) - Cache::FastMmap (Debian based: libcache-fastmmap-perl, RPM based: perl-Cache-FastMmap)
- DateTime (requires: perl-Class-Singleton) - DateTime (requires: perl-Class-Singleton)
- TimeDate - TimeDate
- Crypt::DES - Crypt::DES (Debian based: libcrypt-des-perl)
- Crytpt::RC4 - Crytpt::RC4 (Debian based: libcrypt-rc4-perl)
- Digest::SHA1 - Digest::SHA1 (Debian based: libdigest-sha-perl)
- Digest::MD4 - Digest::MD4 (Debian based: libdigest-md4-perl)
- Math::Expression - Math::Expression
* Requirements for webui * Requirements for webui
......
# SMRadius Utility Functions # Makefile
# Copyright (C) 2007-2015, AllWorldIT # Copyright (C) 2014-2016, AllWorldIT
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
...@@ -16,103 +16,34 @@ ...@@ -16,103 +16,34 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
## @class smradius::util
# Utility functions
package smradius::util;
use strict; use strict;
use warnings; use warnings;
# Exporter stuff
require Exporter;
our (@ISA,@EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(
niceUndef
templateReplace
isBoolean
);
## @fn niceUndef($string)
# If string defined return 'string', or if undefined return -undef-
#
# @param string String to check
#
# @return Return 'string' if defined, or -undef- otherwise
sub niceUndef
{
my $string = shift;
return defined($string) ? "'$string'" : '-undef-';
}
## @fn templateReplace($string,$hashref) use ExtUtils::MakeMaker;
# Template string replacer function use File::Find;
#
# @param string String to replace template items in
# @param hashref Hashref containing the hash of tempalte items & values
#
# @return String with replaced items
sub templateReplace
{
my ($string,$hashref) = @_;
my @valueArray = ();
# Replace blanks WriteMakefile(
while (my ($entireMacro,$section,$item,$default) = ($string =~ /(\%{([a-z]+)\.([a-z0-9\-]+)(?:=([^}]*))?})/i )) { 'NAME' => 'SMRadius',
# Replace macro with ?
$string =~ s/$entireMacro/\?/;
# Get value to substitute 'VENDORPREFIX' => '/opt/smradius',
my $value = defined($hashref->{$section}->{$item}) ? $hashref->{$section}->{$item} : $default; 'INSTALLDIRS' => 'vendor',
# Add value onto our array 'VERSION_FROM' => "lib/smradius/version.pm",
push(@valueArray,$value);
}
return ($string, @valueArray); 'DIR' => ["3rdparty"],
}
'EXE_FILES' => [qw(
## @fn isBoolean($var) bin/smradiusd
# Check if a variable is boolean bin/smadmin
# bin/smradclient
# @param var Variable to check )],
# );
# @return 1, 0 or undef
sub isBoolean
{
my $var = shift;
# Check if we're defined
if (!defined($var)) {
return;
}
# Nuke whitespaces
$var =~ s/\s//g;
# Allow true, on, set, enabled, 1, false, off, unset, disabled, 0
if ($var =~ /^(?:true|on|set|enabled|1)$/i) {
return 1;
}
if ($var =~ /^(?:false|off|unset|disabled|0)$/i) {
return 0;
}
# Invalid or unknown
return;
}
1;
# vim: ts=4 # vim: ts=4
[![build status](https://gitlab.devlabs.linuxassist.net/smradius/smradius/badges/master/build.svg)](https://gitlab.devlabs.linuxassist.net/smradius/smradius/commits/master)
[![coverage report](https://gitlab.devlabs.linuxassist.net/smradius/smradius/badges/master/coverage.svg)](https://gitlab.devlabs.linuxassist.net/smradius/smradius/commits/master)
\ No newline at end of file
...@@ -5,8 +5,7 @@ smradiusd: ...@@ -5,8 +5,7 @@ smradiusd:
* Create a raddbpath config option which is prepended to dict paths * Create a raddbpath config option which is prepended to dict paths
usage related queries: * Configurable 'use defaults for POD/CoA' we may not want to send these
* Use Math module to perform calculations
smadmin: smadmin:
* Ability to run smadmin before the end of current month and updating the records as necessary at a later stage * Ability to run smadmin before the end of current month and updating the records as necessary at a later stage
......
awitpt @ 932340ef
Subproject commit 932340ef7336dc40bdd3d35d2023bde1310e9066
...@@ -17,15 +17,16 @@ ...@@ -17,15 +17,16 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict; use strict;
use warnings; use warnings;
# Set library directory
use lib qw( use Config;
smradius use FindBin;
awitpt/lib use lib ("$FindBin::Bin/../lib", "$FindBin::Bin/../share/perl5", "$FindBin::Bin/../share/perl/$Config{'version'}");
);
# Check Config::IniFiles is instaslled # Check Config::IniFiles is instaslled
......
#!/usr/bin/perl
# Radius client
# Copyright (C) 2007-2016, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
use warnings;
use Config;
use FindBin;
use lib ("$FindBin::Bin/../lib", "$FindBin::Bin/../share/perl5", "$FindBin::Bin/../share/perl/$Config{'version'}");
use smradius::client;
# Grab and exit with result received
my $res = smradius::client->run();
exit($res);
# vim: ts=4
#!/usr/bin/perl
# Radius daemon
# Copyright (C) 2007-2016, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
use warnings;
use Config;
use FindBin;
use lib ("$FindBin::Bin/../lib", "$FindBin::Bin/../share/perl5", "$FindBin::Bin/../share/perl/$Config{'version'}");
use smradius::daemon;
smradius::daemon->run();
1;
# vim: ts=4
#!/bin/bash
# Database translation/creation script
# Copyright (C) 2009-2016, AllWorldIT
# Copyright (C) 2008, LinuxRulz
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
database="$1"
file="$2"
prefix="$3"
# Display usage info
display_usage() {
echo "Usage: $0 <database type> <file> [prefix]"
echo
echo "Valid database types:"
echo " mysql - For MySQL v5.5+"
echo " pgsql - For PostgreSQL"
echo " sqlite - For SQLite v3"
echo
exit
}
# Check we have our params
if [ -z "$database" -o -z "$file" ]
then
display_usage
fi
# Check file exists
if [ ! -f "$file" ]
then
echo "ERROR: Cannot open file '$file'"
exit 1
fi
# Check what we converting for
case "$database" in
"mysql")
sed \
-e "s/@PREFIX@/$prefix/g" \
-e 's/@PRELOAD@/SET FOREIGN_KEY_CHECKS=0;/' \
-e 's/@POSTLOAD@/SET FOREIGN_KEY_CHECKS=1;/' \
-e 's/@CREATE_TABLE_SUFFIX@/ENGINE=InnoDB CHARACTER SET latin1 COLLATE latin1_bin/' \
-e 's/@SERIAL_TYPE@/SERIAL/' \
-e 's/@BIGINT_UNSIGNED@/BIGINT UNSIGNED/' \
-e 's/@INT_UNSIGNED@/INT UNSIGNED/' \
-e 's/@TRACK_KEY_LEN@/512/' \
-e 's/@SERIAL_REF_TYPE@/BIGINT UNSIGNED/' < "$file"
;;
"pgsql")
sed \
-e "s/@PREFIX@/$prefix/g" \
-e 's/@PRELOAD@/SET CONSTRAINTS ALL DEFERRED;/' \
-e 's/@POSTLOAD@//' \
-e 's/@CREATE_TABLE_SUFFIX@//' \
-e 's/@SERIAL_TYPE@/SERIAL PRIMARY KEY/' \
-e 's/@BIGINT_UNSIGNED@/INT8/' \
-e 's/@INT_UNSIGNED@/INT8/' \
-e 's/@TRACK_KEY_LEN@/512/' \
-e 's/@SERIAL_REF_TYPE@/INT8/' < "$file"
;;
"sqlite")
sed \
-e "s/@PREFIX@/$prefix/g" \
-e 's/@PRELOAD@//' \
-e 's/@POSTLOAD@//' \
-e 's/@CREATE_TABLE_SUFFIX@//' \
-e 's/@SERIAL_TYPE@/INTEGER PRIMARY KEY AUTOINCREMENT/' \
-e 's/@BIGINT_UNSIGNED@/INT8/' \
-e 's/@INT_UNSIGNED@/INT8/' \
-e 's/@TRACK_KEY_LEN@/512/' \
-e 's/@SERIAL_REF_TYPE@/INT8/' < "$file"
;;
*)
echo "ERROR: Invalid database type '$database'"
exit 1
;;
esac
...@@ -179,7 +179,7 @@ CREATE TABLE @PREFIX@topups_summary ( ...@@ -179,7 +179,7 @@ CREATE TABLE @PREFIX@topups_summary (
TopupID @SERIAL_REF_TYPE@ NOT NULL, TopupID @SERIAL_REF_TYPE@ NOT NULL,
PeriodKey VARCHAR(255) NOT NULL, PeriodKey VARCHAR(255) NOT NULL,
Balance @INT_UNSIGNED@, Balance @INT_UNSIGNED@,
...@@ -199,13 +199,13 @@ CREATE TABLE @PREFIX@accounting ( ...@@ -199,13 +199,13 @@ CREATE TABLE @PREFIX@accounting (
ServiceType @INT_UNSIGNED@, ServiceType @INT_UNSIGNED@,
FramedProtocol @INT_UNSIGNED@, FramedProtocol @INT_UNSIGNED@,
NASPort VARCHAR(255), NASPort VARCHAR(255),
NASPortType @INT_UNSIGNED@, NASPortType @INT_UNSIGNED@,
CallingStationID VARCHAR(255), CallingStationID VARCHAR(255),
CalledStationID VARCHAR(255), CalledStationID VARCHAR(255),
...@@ -251,6 +251,9 @@ CREATE INDEX @PREFIX@accounting_idx2 ON @PREFIX@accounting (PeriodKey); ...@@ -251,6 +251,9 @@ CREATE INDEX @PREFIX@accounting_idx2 ON @PREFIX@accounting (PeriodKey);
CREATE INDEX @PREFIX@accounting_idx4 ON @PREFIX@accounting (Username,AcctSessionID,NASIPAddress,NASPort); CREATE INDEX @PREFIX@accounting_idx4 ON @PREFIX@accounting (Username,AcctSessionID,NASIPAddress,NASPort);
/* accounting_update_query */ /* accounting_update_query */
CREATE INDEX @PREFIX@accounting_idx5 ON @PREFIX@accounting (Username,AcctSessionID,NASIPAddress,NASPort,PeriodKey); CREATE INDEX @PREFIX@accounting_idx5 ON @PREFIX@accounting (Username,AcctSessionID,NASIPAddress,NASPort,PeriodKey);
/* Index for the EventTimestamp */
CREATE INDEX @PREFIX@accounting_idx7 ON @PREFIX@accounting (EventTimestamp);
CREATE INDEX @PREFIX@accounting_idx8 ON @PREFIX@accounting (Username,EventTimestamp);
...@@ -269,11 +272,14 @@ CREATE TABLE @PREFIX@accounting_summary ( ...@@ -269,11 +272,14 @@ CREATE TABLE @PREFIX@accounting_summary (
TotalOutput @INT_UNSIGNED@ TotalOutput @INT_UNSIGNED@
) @CREATE_TABLE_SUFFIX@; ) @CREATE_TABLE_SUFFIX@;
CREATE INDEX @PREFIX@accounting_summary_idx1 ON @PREFIX@accounting_summary (Username);
CREATE INDEX @PREFIX@accounting_summary_idx2 ON @PREFIX@accounting_summary (PeriodKey);
CREATE INDEX @PREFIX@accounting_summary_idx3 ON @PREFIX@accounting_summary (Username,PeriodKey);
/* Users data */ /* Users data */
CREATE TABLE @PREFIX@users_data ( CREATE TABLE @PREFIX@users_data (
ID @SERIAL_TYPE@, ID @SERIAL_TYPE@,
UserID @INT_UNSIGNED@, UserID @INT_UNSIGNED@,
...@@ -284,4 +290,4 @@ CREATE TABLE @PREFIX@users_data ( ...@@ -284,4 +290,4 @@ CREATE TABLE @PREFIX@users_data (
Value VARCHAR(255), Value VARCHAR(255),
UNIQUE (UserID,Name) UNIQUE (UserID,Name)
) @CREATE_TABLE_SUFFIX@; ) @CREATE_TABLE_SUFFIX@;
...@@ -2,3 +2,4 @@ ALTER TABLE @PREFIX@users ADD COLUMN PeriodKey VARCHAR(255); ...@@ -2,3 +2,4 @@ ALTER TABLE @PREFIX@users ADD COLUMN PeriodKey VARCHAR(255);
ALTER TABLE @PREFIX@users ADD COLUMN TotalTraffic @INT_UNSIGNED@; ALTER TABLE @PREFIX@users ADD COLUMN TotalTraffic @INT_UNSIGNED@;
ALTER TABLE @PREFIX@users ADD COLUMN TotalUptime @INT_UNSIGNED@; ALTER TABLE @PREFIX@users ADD COLUMN TotalUptime @INT_UNSIGNED@;
ALTER TABLE @PREFIX@users ADD COLUMN NASIdentifier VARCHAR(255); ALTER TABLE @PREFIX@users ADD COLUMN NASIdentifier VARCHAR(255);
ALTER TABLE @PREFIX@users ADD COLUMN LastAcctUpdate DATETIME;
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
# relevant information for reproducing the bug. Packet dumps are most # relevant information for reproducing the bug. Packet dumps are most
# useful. # useful.
package Radius::Dictionary; package smradius::Radius::Dictionary;
use strict; use strict;
use warnings; use warnings;
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
# relevant information for reproducing the bug. Packet dumps are most # relevant information for reproducing the bug. Packet dumps are most
# useful. # useful.
package Radius::Packet; package smradius::Radius::Packet;
use strict; use strict;
require Exporter; require Exporter;
...@@ -32,7 +32,7 @@ $VSA = 26; # Type assigned in RFC2138 to the ...@@ -32,7 +32,7 @@ $VSA = 26; # Type assigned in RFC2138 to the
# Vendor-Specific Attributes # Vendor-Specific Attributes
# Be sure our dictionaries are current # Be sure our dictionaries are current
use Radius::Dictionary 1.50; use smradius::Radius::Dictionary 1.50;
use Carp; use Carp;
use Socket; use Socket;
use Digest::MD5; use Digest::MD5;
......
There are notable differences between Packet.pm and the Net::Radius Packet.pm, most notable raw value support.
...@@ -41,6 +41,8 @@ our (@EXPORT); ...@@ -41,6 +41,8 @@ our (@EXPORT);
); );
use AWITPT::Util;
# Check Math::Expression is installed # Check Math::Expression is installed
if (!eval {require Math::Expression; 1;}) { if (!eval {require Math::Expression; 1;}) {
print STDERR "You're missing Math::Expression, try 'apt-get install libmath-expression-perl'\n"; print STDERR "You're missing Math::Expression, try 'apt-get install libmath-expression-perl'\n";
...@@ -51,6 +53,7 @@ use smradius::logging; ...@@ -51,6 +53,7 @@ use smradius::logging;
use smradius::util; use smradius::util;
# Attributes we do not handle # Attributes we do not handle
my @attributeCheckIgnoreList = ( my @attributeCheckIgnoreList = (
'User-Password' 'User-Password'
...@@ -65,7 +68,23 @@ my @attributeReplyIgnoreList = ( ...@@ -65,7 +68,23 @@ my @attributeReplyIgnoreList = (
'SMRadius-Username-Transform', 'SMRadius-Username-Transform',
'SMRadius-Evaluate', 'SMRadius-Evaluate',
'SMRadius-Peer-Address', 'SMRadius-Peer-Address',
'SMRadius-Disable-WebUITopup' 'SMRadius-Disable-WebUITopup',
'SMRadius-AutoTopup-Traffic-Enabled',
'SMRadius-AutoTopup-Traffic-Amount',
'SMRadius-AutoTopup-Traffic-Limit',
'SMRadius-AutoTopup-Traffic-Notify',
'SMRadius-AutoTopup-Traffic-NotifyTemplate',
'SMRadius-AutoTopup-Traffic-Threshold',
'SMRadius-AutoTopup-Uptime-Enabled',
'SMRadius-AutoTopup-Uptime-Amount',
'SMRadius-AutoTopup-Uptime-Limit',
'SMRadius-AutoTopup-Uptime-Notify',
'SMRadius-AutoTopup-Uptime-NotifyTemplate',
'SMRadius-AutoTopup-Uptime-Threshold',
'SMRadius-Config-Filter-Reply-Attribute',
'SMRadius-Config-Filter-Reply-VAttribute',
'SMRadius-FUP-Period',
'SMRadius-FUP-Traffic-Threshold',
); );
my @attributeVReplyIgnoreList = ( my @attributeVReplyIgnoreList = (
); );
...@@ -85,8 +104,8 @@ sub addAttribute ...@@ -85,8 +104,8 @@ sub addAttribute
# Check we have the name, operator AND value # Check we have the name, operator AND value
if (!defined($attribute->{'Name'}) || !defined($attribute->{'Operator'}) || !defined($attribute->{'Value'})) { if (!defined($attribute->{'Name'}) || !defined($attribute->{'Operator'}) || !defined($attribute->{'Value'})) {
$server->log(LOG_DEBUG,"[ATTRIBUTES] Problem adding attribute with name = ".niceUndef($attribute->{'Name'}). $server->log(LOG_DEBUG,"[ATTRIBUTES] Problem adding attribute with name = ".prettyUndef($attribute->{'Name'}).
", operator = ".niceUndef($attribute->{'Operator'}).", value = ".niceUndef($attribute->{'Value'})); ", operator = ".prettyUndef($attribute->{'Operator'}).", value = ".prettyUndef($attribute->{'Value'}));
return; return;
} }
...@@ -170,7 +189,7 @@ sub checkAuthAttribute ...@@ -170,7 +189,7 @@ sub checkAuthAttribute
# Get packet attribute value # Get packet attribute value
my $attrVal = $packetAttributes->{$attribute->{'Name'}}; my $attrVal = $packetAttributes->{$attribute->{'Name'}};
$server->log(LOG_DEBUG,"[ATTRIBUTES] Processing CHECK attribute value ".niceUndef($attrVal)." against: '". $server->log(LOG_DEBUG,"[ATTRIBUTES] Processing CHECK attribute value ".prettyUndef($attrVal)." against: '".
$attribute->{'Name'}."' ".$attribute->{'Operator'}." '".join("','",@attrValues)."'"); $attribute->{'Name'}."' ".$attribute->{'Operator'}." '".join("','",@attrValues)."'");
# Loop with all the test attribute values # Loop with all the test attribute values
...@@ -327,7 +346,7 @@ sub checkAuthAttribute ...@@ -327,7 +346,7 @@ sub checkAuthAttribute
# Always matches as a check item, and adds the current # Always matches as a check item, and adds the current
# attribute with value to the list of configuration items. # attribute with value to the list of configuration items.
# #
# As a reply item, it has an itendtical meaning, but the # As a reply item, it has an idendtical meaning, but the
# attribute is added to the reply items. # attribute is added to the reply items.
} elsif ($operator eq '+=') { } elsif ($operator eq '+=') {
...@@ -410,7 +429,7 @@ sub checkAcctAttribute ...@@ -410,7 +429,7 @@ sub checkAcctAttribute
# Get packet attribute value # Get packet attribute value
my $attrVal = $packetAttributes->{$attribute->{'Name'}}; my $attrVal = $packetAttributes->{$attribute->{'Name'}};
$server->log(LOG_DEBUG,"[ATTRIBUTES] Processing CHECK attribute value ".niceUndef($attrVal)." against: '". $server->log(LOG_DEBUG,"[ATTRIBUTES] Processing CHECK attribute value ".prettyUndef($attrVal)." against: '".
$attribute->{'Name'}."' ".$attribute->{'Operator'}." '".join("','",@attrValues)."'"); $attribute->{'Name'}."' ".$attribute->{'Operator'}." '".join("','",@attrValues)."'");
# Loop with all the test attribute values # Loop with all the test attribute values
...@@ -424,7 +443,7 @@ sub checkAcctAttribute ...@@ -424,7 +443,7 @@ sub checkAcctAttribute
# Always matches as a check item, and adds the current # Always matches as a check item, and adds the current
# attribute with value to the list of configuration items. # attribute with value to the list of configuration items.
# #
# As a reply item, it has an itendtical meaning, but the # As a reply item, it has an idendtical meaning, but the
# attribute is added to the reply items. # attribute is added to the reply items.
if ($operator eq '+=') { if ($operator eq '+=') {
...@@ -531,7 +550,7 @@ sub setReplyAttribute ...@@ -531,7 +550,7 @@ sub setReplyAttribute
# Always matches as a check item, and replaces in the configuration items any attribute of the same name. # Always matches as a check item, and replaces in the configuration items any attribute of the same name.
# If no attribute of that name appears in the request, then this attribute is added. # If no attribute of that name appears in the request, then this attribute is added.
# #
# As a reply item, it has an itendtical meaning, but for the reply items, instead of the request items. # As a reply item, it has an idendtical meaning, but for the reply items, instead of the request items.
} elsif ($attribute->{'Operator'} eq ':=') { } elsif ($attribute->{'Operator'} eq ':=') {
# Overwrite # Overwrite
...@@ -546,7 +565,7 @@ sub setReplyAttribute ...@@ -546,7 +565,7 @@ sub setReplyAttribute
# Always matches as a check item, and adds the current # Always matches as a check item, and adds the current
# attribute with value to the list of configuration items. # attribute with value to the list of configuration items.
# #
# As a reply item, it has an itendtical meaning, but the # As a reply item, it has an idendtical meaning, but the
# attribute is added to the reply items. # attribute is added to the reply items.
} elsif ($attribute->{'Operator'} eq '+=') { } elsif ($attribute->{'Operator'} eq '+=') {
...@@ -595,7 +614,7 @@ sub setReplyVAttribute ...@@ -595,7 +614,7 @@ sub setReplyVAttribute
@attrValues = ( $attribute->{'Value'} ); @attrValues = ( $attribute->{'Value'} );
} }
$server->log(LOG_DEBUG,"[VATTRIBUTES] Processing REPLY attribute: '". $server->log(LOG_DEBUG,"[VATTRIBUTES] Processing REPLY vattribute: '".
$attribute->{'Name'}."' ".$attribute->{'Operator'}." '".join("','",@attrValues)."'"); $attribute->{'Name'}."' ".$attribute->{'Operator'}." '".join("','",@attrValues)."'");
...@@ -625,7 +644,7 @@ sub setReplyVAttribute ...@@ -625,7 +644,7 @@ sub setReplyVAttribute
# Always matches as a check item, and replaces in the configuration items any attribute of the same name. # Always matches as a check item, and replaces in the configuration items any attribute of the same name.
# If no attribute of that name appears in the request, then this attribute is added. # If no attribute of that name appears in the request, then this attribute is added.
# #
# As a reply item, it has an itendtical meaning, but for the reply items, instead of the request items. # As a reply item, it has an idendtical meaning, but for the reply items, instead of the request items.
} elsif ($attribute->{'Operator'} eq ':=') { } elsif ($attribute->{'Operator'} eq ':=') {
# Overwrite # Overwrite
...@@ -640,7 +659,7 @@ sub setReplyVAttribute ...@@ -640,7 +659,7 @@ sub setReplyVAttribute
# Always matches as a check item, and adds the current # Always matches as a check item, and adds the current
# attribute with value to the list of configuration items. # attribute with value to the list of configuration items.
# #
# As a reply item, it has an itendtical meaning, but the # As a reply item, it has an idendtical meaning, but the
# attribute is added to the reply items. # attribute is added to the reply items.
} elsif ($attribute->{'Operator'} eq '+=') { } elsif ($attribute->{'Operator'} eq '+=') {
...@@ -692,7 +711,7 @@ sub processConfigAttribute ...@@ -692,7 +711,7 @@ sub processConfigAttribute
# Always matches as a check item, and adds the current # Always matches as a check item, and adds the current
# attribute with value to the list of configuration items. # attribute with value to the list of configuration items.
# #
# As a reply item, it has an itendtical meaning, but the # As a reply item, it has an idendtical meaning, but the
# attribute is added to the reply items. # attribute is added to the reply items.
if ($attribute->{'Operator'} eq '+=') { if ($attribute->{'Operator'} eq '+=') {
...@@ -705,7 +724,7 @@ sub processConfigAttribute ...@@ -705,7 +724,7 @@ sub processConfigAttribute
# Always matches as a check item, and replaces in the configuration items any attribute of the same name. # Always matches as a check item, and replaces in the configuration items any attribute of the same name.
# If no attribute of that name appears in the request, then this attribute is added. # If no attribute of that name appears in the request, then this attribute is added.
# #
# As a reply item, it has an itendtical meaning, but for the reply items, instead of the request items. # As a reply item, it has an idendtical meaning, but for the reply items, instead of the request items.
} elsif ($attribute->{'Operator'} eq ':=') { } elsif ($attribute->{'Operator'} eq ':=') {
@{$configAttributes->{$attribute->{'Name'}}} = @attrValues; @{$configAttributes->{$attribute->{'Name'}}} = @attrValues;
...@@ -755,7 +774,7 @@ sub addAttributeConditionalVariable ...@@ -755,7 +774,7 @@ sub addAttributeConditionalVariable
{ {
my ($user,$name,$value) = @_; my ($user,$name,$value) = @_;
print(STDERR "CONDITIONAL VARIABLE: $name => $value\n");
$user->{'AttributeConditionalVariables'}->{$name} = [ $value ]; $user->{'AttributeConditionalVariables'}->{$name} = [ $value ];
return; return;
...@@ -775,7 +794,8 @@ sub processConditional ...@@ -775,7 +794,8 @@ sub processConditional
# Split off expression # Split off expression
my ($condition,$onTrue,$onFalse) = ($attrVal =~ /^([^\?]*)(?:\?\s*((?:\S+)?[^:]*)(?:\s*\:\s*(.*))?)?$/); # NK: This probably needs a bit of work
my ($condition,$onTrue,$onFalse) = ($attrVal =~ /^([^\?]*)(?:\?\s*((?:\S+)?[^:]*)(?:\:\s*(.*))?)?$/);
# If there is no condition we cannot really continue? # If there is no condition we cannot really continue?
if (!defined($condition)) { if (!defined($condition)) {
...@@ -829,6 +849,10 @@ sub processConditional ...@@ -829,6 +849,10 @@ sub processConditional
# We only get here if $res is set to 1 above, if its only a conditional with no onTrue & onFalse # We only get here if $res is set to 1 above, if its only a conditional with no onTrue & onFalse
# Then attribStr will be unef # Then attribStr will be unef
if ($res && defined($attribStr)) { if ($res && defined($attribStr)) {
# Sanitize the output
$attribStr =~ s/^\s*//;
$attribStr =~ s/\s*$//;
foreach my $rawAttr (split(/;/,$attribStr)) { foreach my $rawAttr (split(/;/,$attribStr)) {
# Split off attribute string: name = value # Split off attribute string: name = value
my ($attrName,$attrVal) = ($rawAttr =~ /^\s*([^=]+)=\s*(.*)/); my ($attrName,$attrVal) = ($rawAttr =~ /^\s*([^=]+)=\s*(.*)/);
......