Skip to content
GitLab
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
5e853fcc
Commit
5e853fcc
authored
May 15, 2019
by
Nigel Kukard
Browse files
Renamed POD to COA and added backwards compatibility
parent
5f4abf79
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/smradius/daemon.pm
View file @
5e853fcc
...
...
@@ -931,64 +931,76 @@ sub process_request {
# Grab packet
my
$response
=
auth_resp
(
$resp
->
pack
,
getAttributeValue
(
$user
->
{'
ConfigAttributes
'},"
SMRadius-Config-Secret
"));
# Check for POD Servers and send disconnect
my
$coaServer
;
# Check for old POD server attribute
if
(
defined
(
$user
->
{'
ConfigAttributes
'}
->
{'
SMRadius-Config-PODServer
'}))
{
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] SMRadius-Config-PODServer is defined
");
$coaServer
=
$user
->
{'
ConfigAttributes
'}
->
{'
SMRadius-Config-PODServer
'};
}
# Check for new CoA server attribute
if
(
defined
(
$user
->
{'
ConfigAttributes
'}
->
{'
SMRadius-Config-CoAServer
'}))
{
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] SMRadius-Config-CoAServer is defined
");
$coaServer
=
$user
->
{'
ConfigAttributes
'}
->
{'
SMRadius-Config-CoAServer
'};
}
# Check for CoA servers
if
(
defined
(
$coaServer
))
{
# Check address format
foreach
my
$
pod
ServerAttribute
(
@
{
$
user
->
{'
ConfigAttributes
'}
->
{'
SMRadius-Config-POD
Server
'}
})
{
foreach
my
$
coa
ServerAttribute
(
@
{
$
coa
Server
})
{
# Check for valid IP
if
(
$
pod
ServerAttribute
=~
/^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/
)
{
my
$
pod
Server
=
$
1
;
if
(
$
coa
ServerAttribute
=~
/^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/
)
{
my
$
coa
Server
=
$
1
;
# If we have a port, use it, otherwise use default 1700
my
$
pod
ServerPort
;
if
(
$
pod
ServerAttribute
=~
/:([0-9]+)$/
)
{
$
pod
ServerPort
=
$
1
;
my
$
coa
ServerPort
;
if
(
$
coa
ServerAttribute
=~
/:([0-9]+)$/
)
{
$
coa
ServerPort
=
$
1
;
}
else
{
$
pod
ServerPort
=
1700
;
$
coa
ServerPort
=
1700
;
}
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] POST-ACCT: Trying
POD
Server => IP: '
"
.
$
pod
Server
.
"
' Port: '
"
.
$
pod
ServerPort
.
"
'
");
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] POST-ACCT: Trying
CoA
Server => IP: '
"
.
$
coa
Server
.
"
' Port: '
"
.
$
coa
ServerPort
.
"
'
");
# Create socket to send packet out on
my
$
pod
ServerTimeout
=
"
10
";
# 10 second timeout
my
$
pod
Sock
=
IO::Socket::
INET
->
new
(
PeerAddr
=>
$
pod
Server
,
PeerPort
=>
$
pod
ServerPort
,
my
$
coa
ServerTimeout
=
"
10
";
# 10 second timeout
my
$
coa
Sock
=
IO::Socket::
INET
->
new
(
PeerAddr
=>
$
coa
Server
,
PeerPort
=>
$
coa
ServerPort
,
Type
=>
SOCK_DGRAM
,
Proto
=>
'
udp
',
TimeOut
=>
$
pod
ServerTimeout
,
TimeOut
=>
$
coa
ServerTimeout
,
);
if
(
!
$
pod
Sock
)
{
if
(
!
$
coa
Sock
)
{
$self
->
log
(
LOG_ERR
,"
[SMRADIUS] POST-ACCT: Failed to create socket to send POD on
");
next
;
}
# Check if we sent the packet...
if
(
!
$
pod
Sock
->
send
(
$response
))
{
if
(
!
$
coa
Sock
->
send
(
$response
))
{
$self
->
log
(
LOG_ERR
,"
[SMRADIUS] POST-ACCT: Failed to send data on socket
");
next
;
}
# Once sent, we need to get a response back
my
$sh
=
IO::
Select
->
new
(
$
pod
Sock
);
my
$sh
=
IO::
Select
->
new
(
$
coa
Sock
);
if
(
!
$sh
)
{
$self
->
log
(
LOG_ERR
,"
[SMRADIUS] POST-ACCT: Failed to select data on socket
");
next
;
}
if
(
!
$sh
->
can_read
(
$
pod
ServerTimeout
))
{
if
(
!
$sh
->
can_read
(
$
coa
ServerTimeout
))
{
$self
->
log
(
LOG_ERR
,"
[SMRADIUS] POST-ACCT: Failed to receive data on socket
");
next
;
}
my
$data
;
$
pod
Sock
->
recv
(
$data
,
65536
);
$
coa
Sock
->
recv
(
$data
,
65536
);
if
(
!
$data
)
{
$self
->
log
(
LOG_ERR
,"
[SMRADIUS] POST-ACCT: Receive data failed
");
$logReason
=
"
POD
Failure
";
$logReason
=
"
CoA
Failure
";
}
else
{
$logReason
=
"
User POD
";
}
...
...
@@ -996,11 +1008,11 @@ sub process_request {
#my @stuff = unpack('C C n a16 a*', $data);
#$self->log(LOG_DEBUG,"STUFF: ".Dumper(\@stuff));
}
else
{
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] Invalid
POD
Server value: '
"
.
$
pod
ServerAttribute
.
"
'
");
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] Invalid
CoA
Server value: '
"
.
$
coa
ServerAttribute
.
"
'
");
}
}
}
else
{
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] SMRadius-Config-
POD
Server is not defined
");
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] SMRadius-Config-
CoA
Server is not defined
");
}
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment