Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
smradius
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
smradius
smradius
Commits
5e853fcc
Commit
5e853fcc
authored
May 15, 2019
by
Nigel Kukard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed POD to COA and added backwards compatibility
parent
5f4abf79
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
22 deletions
+34
-22
lib/smradius/daemon.pm
lib/smradius/daemon.pm
+34
-22
No files found.
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
$
podServerAttribute
(
@
{
$user
->
{'
ConfigAttributes
'}
->
{'
SMRadius-Config-PODServer
'}
})
{
foreach
my
$
coaServerAttribute
(
@
{
$coaServer
})
{
# 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
PODServer => IP: '
"
.
$podServer
.
"
' Port: '
"
.
$pod
ServerPort
.
"
'
");
$self
->
log
(
LOG_DEBUG
,"
[SMRADIUS] POST-ACCT: Trying
CoAServer => IP: '
"
.
$coaServer
.
"
' 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
Markdown
is supported
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