Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
smradius
smradius
Commits
5c444813
Commit
5c444813
authored
Sep 24, 2016
by
Nigel Kukard
Browse files
IMPROVEMENT: Use AWITPT's isBoolean instead of trying to regex booleans ourselves
parent
3931a1eb
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/smradius/config.pm
View file @
5c444813
...
...
@@ -31,6 +31,7 @@ our @EXPORT_OK = qw(
)
;
use
AWITPT::
Util
;
use
smradius::
logging
;
...
...
@@ -71,10 +72,8 @@ sub Init
# Should we use the packet timestamp?
if
(
defined
(
$config
->
{'
radius
'}{'
use_packet_timestamp
'}))
{
if
(
$config
->
{'
radius
'}{'
use_packet_timestamp
'}
=~
/^\s*(yes|true|1)\s*$/i
)
{
$server
->
{'
smradius
'}{'
use_packet_timestamp
'}
=
1
;
}
elsif
(
$config
->
{'
radius
'}{'
use_packet_timestamp
'}
=~
/^\s*(no|false|0)\s*$/i
)
{
$server
->
{'
smradius
'}{'
use_packet_timestamp
'}
=
0
;
if
(
defined
(
my
$val
=
isBoolean
(
$config
->
{'
radius
'}{'
use_packet_timestamp
'})))
{
$server
->
{'
smradius
'}{'
use_packet_timestamp
'}
=
$val
;
}
else
{
$server
->
log
(
LOG_NOTICE
,"
smradius/config.pm: Value for 'use_packet_timestamp' is invalid
");
}
...
...
@@ -84,10 +83,8 @@ sub Init
# Should we use abuse prevention?
if
(
defined
(
$config
->
{'
radius
'}{'
use_abuse_prevention
'}))
{
if
(
$config
->
{'
radius
'}{'
use_abuse_prevention
'}
=~
/^\s*(yes|true|1)\s*$/i
)
{
$server
->
{'
smradius
'}{'
use_abuse_prevention
'}
=
1
;
}
elsif
(
$config
->
{'
radius
'}{'
use_abuse_prevention
'}
=~
/^\s*(no|false|0)\s*$/i
)
{
$server
->
{'
smradius
'}{'
use_abuse_prevention
'}
=
0
;
if
(
defined
(
my
$val
=
isBoolean
(
$config
->
{'
radius
'}{'
use_abuse_prevention
'})))
{
$server
->
{'
smradius
'}{'
use_abuse_prevention
'}
=
$val
;
}
else
{
$server
->
log
(
LOG_NOTICE
,"
smradius/config.pm: Value for 'use_abuse_prevention' is invalid
");
}
...
...
lib/smradius/modules/accounting/mod_accounting_sql.pm
View file @
5c444813
...
...
@@ -299,10 +299,15 @@ sub init
}
}
if
(
defined
(
$scfg
->
{'
mod_accounting_sql
'}
->
{'
accounting_usage_cache_time
'}))
{
if
(
$scfg
->
{'
mod_accounting_sql
'}{'
accounting_usage_cache_time
'}
=~
/^\s*(yes|true|1)\s*$/i
)
{
# Default?
}
elsif
(
$scfg
->
{'
mod_accounting_sql
'}{'
accounting_usage_cache_time
'}
=~
/^\s*(no|false|0)\s*$/i
)
{
$config
->
{'
accounting_usage_cache_time
'}
=
undef
;
# Check if we're a boolean
if
(
defined
(
my
$val
=
isBoolean
(
$scfg
->
{'
mod_accounting_sql
'}{'
accounting_usage_cache_time
'})))
{
# If val is true, we default to the default anyway
# We're disabled
if
(
!
$val
)
{
$config
->
{'
accounting_usage_cache_time
'}
=
undef
;
}
# We *could* have a value...
}
elsif
(
$scfg
->
{'
mod_accounting_sql
'}{'
accounting_usage_cache_time
'}
=~
/^[0-9]+$/
)
{
$config
->
{'
accounting_usage_cache_time
'}
=
$scfg
->
{'
mod_accounting_sql
'}{'
accounting_usage_cache_time
'};
}
else
{
...
...
lib/smradius/modules/features/mod_feature_capping.pm
View file @
5c444813
...
...
@@ -73,17 +73,19 @@ sub init
my
$scfg
=
$server
->
{'
inifile
'};
# Defaults
$config
->
{'
enable_mikrotik
'}
=
0
;
# Setup SQL queries
if
(
defined
(
$scfg
->
{'
mod_feature_capping
'}))
{
# Check if option exists
if
(
defined
(
$scfg
->
{'
mod_feature_capping
'}{'
enable_mikrotik
'}))
{
# 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
;
if
(
defined
(
my
$val
=
isBoolean
(
$scfg
->
{'
mod_feature_capping
'}{'
enable_mikrotik
'})))
{
if
(
$val
)
{
$server
->
log
(
LOG_NOTICE
,"
[MOD_FEATURE_CAPPING] Mikrotik-specific vendor return attributes ENABLED
");
$config
->
{'
enable_mikrotik
'}
=
$val
;
}
}
else
{
$server
->
log
(
LOG_NOTICE
,"
[MOD_FEATURE_CAPPING] Value for 'enable_mikrotik' is invalid
");
}
...
...
@@ -237,7 +239,7 @@ sub post_auth_hook
}
else
{
# Check if we returning Mikrotik vattributes
# FIXME: NK - this is not mikrotik specific
if
(
defined
(
$config
->
{'
enable_mikrotik
'})
)
{
if
(
$config
->
{'
enable_mikrotik
'})
{
# FIXME: NK - We should cap the maximum total session time to that which is already set, if something is set
# Setup reply attributes for Mikrotik HotSpots
my
%attribute
=
(
...
...
@@ -261,7 +263,7 @@ sub post_auth_hook
# Setup limits
}
else
{
# Check if we returning Mikrotik vattributes
if
(
defined
(
$config
->
{'
enable_mikrotik
'})
)
{
if
(
$config
->
{'
enable_mikrotik
'})
{
# Get remaining traffic
my
$remainingTraffic
=
$trafficLimitWithTopups
-
$accountingUsage
->
{'
TotalDataUsage
'};
my
$remainingTrafficLimit
=
(
$remainingTraffic
%
4096
)
*
1024
*
1024
;
...
...
lib/smradius/modules/userdb/mod_userdb_sql.pm
View file @
5c444813
...
...
@@ -225,10 +225,14 @@ sub init
}
if
(
defined
(
$scfg
->
{'
mod_userdb_sql
'}
->
{'
userdb_data_cache_time
'}))
{
if
(
$scfg
->
{'
mod_userdb_sql
'}{'
userdb_data_cache_time
'}
=~
/^\s*(yes|true|1)\s*$/i
)
{
# Default?
}
elsif
(
$scfg
->
{'
mod_userdb_sql
'}{'
userdb_data_cache_time
'}
=~
/^\s*(no|false|0)\s*$/i
)
{
$config
->
{'
userdb_data_cache_time
'}
=
undef
;
if
(
defined
(
my
$val
=
isBoolean
(
$scfg
->
{'
mod_userdb_sql
'}{'
userdb_data_cache_time
'})))
{
# If val is true, we default to the default anyway
# We're disabled
if
(
!
$val
)
{
$config
->
{'
userdb_data_cache_time
'}
=
undef
;
}
# We *could* have a value...
}
elsif
(
$scfg
->
{'
mod_userdb_sql
'}{'
userdb_data_cache_time
'}
=~
/^[0-9]+$/
)
{
$config
->
{'
userdb_data_cache_time
'}
=
$scfg
->
{'
mod_userdb_sql
'}{'
userdb_data_cache_time
'};
}
else
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment