Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
smradius
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
smradius
smradius
Commits
2f7c725d
"git@gitlab.linux.community:centiva-shail/smradius.git" did not exist on "dbbb05cc65c8e0fec283c2481f21ebe765a8e2cc"
Commit
2f7c725d
authored
13 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
Added Mikrotik-specific vendor attribute returns on FEATURE_CAPPING module
parent
15e200c1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
smradius/modules/features/mod_feature_capping.pm
+65
-0
65 additions, 0 deletions
smradius/modules/features/mod_feature_capping.pm
smradiusd.conf
+7
-0
7 additions, 0 deletions
smradiusd.conf
with
72 additions
and
0 deletions
smradius/modules/features/mod_feature_capping.pm
+
65
−
0
View file @
2f7c725d
...
...
@@ -21,10 +21,14 @@ use strict;
use
warnings
;
# Modules we need
use
smradius::
attributes
;
use
smradius::
constants
;
use
smradius::
logging
;
use
smradius::
util
;
use
POSIX
qw(floor)
;
# Exporter stuff
require
Exporter
;
our
(
@ISA
,
@EXPORT
,
@EXPORT_OK
);
...
...
@@ -55,11 +59,30 @@ my $UPTIME_LIMIT_KEY = 'SMRadius-Capping-Uptime-Limit';
my
$TRAFFIC_TOPUPS_KEY
=
'
SMRadius-Capping-Traffic-Topup
';
my
$TIME_TOPUPS_KEY
=
'
SMRadius-Capping-Uptime-Topup
';
my
$config
;
## @internal
# Initialize module
sub
init
{
my
$server
=
shift
;
my
$scfg
=
$server
->
{'
inifile
'};
# Setup SQL queries
if
(
defined
(
$scfg
->
{'
mod_feature_capping
'}))
{
# Pull in config
if
(
$scfg
->
{'
mod_feature_capping
'}{'
enable_mikrotik
'}
=~
/^\s*(yes|true|1)\s*$/i
)
{
$server
->
log
(
LOG_NOTICE
,"
[MOD_FEATURE_CAPPING] Mikrotik-specific vendor return attributes ENABLED
");
$config
->
{'
enable_mikrotik
'}
=
$scfg
->
{'
mod_feature_capping
'}{'
enable_mikrotik
'};
# Default?
}
elsif
(
$scfg
->
{'
mod_feature_capping
'}{'
enable_mikrotik
'}
=~
/^\s*(no|false|0)\s*$/i
)
{
$config
->
{'
enable_mikrotik
'}
=
undef
;
}
else
{
$server
->
log
(
LOG_NOTICE
,"
[MOD_FEATURE_CAPPING] Value for 'enable_mikrotik' is invalid
");
}
}
}
...
...
@@ -278,6 +301,18 @@ sub post_auth_hook
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_CAPPING] Usage of
"
.
$accountingUsage
->
{'
TotalSessionTime
'}
.
"
Min exceeds allowed limit of
"
.
$alteredUptimeLimit
.
"
Min. Capped.
");
return
MOD_RES_NACK
;
# Setup limits
}
else
{
# Check if we returning Mikrotik vattributes
if
(
defined
(
$config
->
{'
enable_mikrotik
'}))
{
# Setup reply attributes for Mikrotik HotSpots
my
%attribute
=
(
'
Name
'
=>
'
Session-Timeout
',
'
Operator
'
=>
'
=
',
'
Value
'
=>
$alteredUptimeLimit
-
$accountingUsage
->
{'
TotalSessionTime
'}
);
setReplyAttribute
(
$server
,
$user
->
{'
ReplyAttributes
'},
\
%attribute
);
}
}
}
...
...
@@ -289,6 +324,36 @@ sub post_auth_hook
$server
->
log
(
LOG_DEBUG
,"
[MOD_FEATURE_CAPPING] Usage of
"
.
$accountingUsage
->
{'
TotalDataUsage
'}
.
"
Mb exceeds allowed limit of
"
.
$alteredTrafficLimit
.
"
Mb. Capped.
");
return
MOD_RES_NACK
;
# Setup limits
}
else
{
# Check if we returning Mikrotik vattributes
if
(
defined
(
$config
->
{'
enable_mikrotik
'}))
{
# Get remaining traffic
my
$remainingTraffic
=
$alteredTrafficLimit
-
$accountingUsage
->
{'
TotalDataUsage
'};
my
$remainingTrafficLimit
=
(
$remainingTraffic
%
4096
)
*
1024
;
# * 1024;
my
$remainingTrafficGigawords
=
floor
(
$remainingTraffic
/
4096
);
# Setup reply attributes for Mikrotik HotSpots
for
my
$attrName
('
Recv
','
Xmit
','
Total
')
{
my
%attribute
=
(
'
Vendor
'
=>
14988
,
'
Name
'
=>
"
Mikrotik-
$attrName
-Limit
",
'
Operator
'
=>
'
=
',
# Gigawords leftovers
'
Value
'
=>
$remainingTrafficLimit
);
setReplyVAttribute
(
$server
,
$user
->
{'
ReplyVAttributes
'},
\
%attribute
);
%attribute
=
(
'
Vendor
'
=>
14988
,
'
Name
'
=>
"
Mikrotik-
$attrName
-Limit-Gigawords
",
'
Operator
'
=>
'
=
',
# Gigawords
'
Value
'
=>
$remainingTrafficGigawords
);
setReplyVAttribute
(
$server
,
$user
->
{'
ReplyVAttributes
'},
\
%attribute
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
smradiusd.conf
+
7
−
0
View file @
2f7c725d
...
...
@@ -512,3 +512,10 @@ update_user_stats_query=<<EOT
WHERE
Username
= %{
request
.
User
-
Name
}
EOT
# MOD_FEATURE_CAPPING
[
mod_feature_capping
]
# Enable Mikrotik-specific return vattributes
#enable_mikrotik=1
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment