Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
radius
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
radius
Commits
abd6879a
Commit
abd6879a
authored
May 05, 2023
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
9e73cf2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
8 deletions
+30
-8
app.js
app.js
+30
-8
No files found.
app.js
View file @
abd6879a
...
...
@@ -4,13 +4,15 @@ let redis = require('./redis')
redis
.
init
()
const
secret
=
'
secret
'
;
// Replace with your shared secret
const
port
=
1812
;
// Default RADIUS authentication port
const
portAcc
=
1813
;
// Default RADIUS authentication port
let
reject
=
'
Access-Reject
'
let
accept
=
'
Access-Accept
'
let
maxConnection
=
2
let
maxConnection
=
1
const
server
=
dgram
.
createSocket
(
'
udp4
'
);
const
serverAuth
=
dgram
.
createSocket
(
'
udp4
'
);
const
serverAccounting
=
dgram
.
createSocket
(
'
udp4
'
);
server
.
on
(
'
message
'
,
(
msg
,
rinfo
)
=>
{
server
Auth
.
on
(
'
message
'
,
(
msg
,
rinfo
)
=>
{
const
packet
=
radius
.
decode
({
packet
:
msg
,
secret
});
if
(
packet
.
code
!==
'
Access-Request
'
)
{
...
...
@@ -29,12 +31,32 @@ server.on('message', (msg, rinfo) => {
doAuth
(
packet
,
user
,
rinfo
)
});
server
.
on
(
'
listening
'
,
()
=>
{
const
address
=
server
.
address
();
console
.
log
(
'
RADIUS server listening on port
'
,
address
.
port
);
server
Auth
.
on
(
'
listening
'
,
()
=>
{
const
address
=
server
Auth
.
address
();
console
.
log
(
'
RADIUS server
Auth
listening on port
'
,
address
.
port
);
});
server
.
bind
(
port
);
serverAccounting
.
on
(
'
message
'
,
(
msg
,
rinfo
)
=>
{
const
packet
=
radius
.
decode
({
packet
:
msg
,
secret
});
console
.
log
(
packet
)
if
(
packet
.
code
!==
'
Access-Request
'
)
{
console
.
error
(
'
Invalid packet type:
'
+
packet
.
code
);
return
;
}
});
serverAccounting
.
on
(
'
listening
'
,
()
=>
{
const
address
=
serverAccounting
.
address
();
console
.
log
(
'
RADIUS server Accounting listening on port
'
,
address
.
port
);
});
serverAccounting
.
bind
(
portAcc
);
serverAuth
.
bind
(
port
);
async
function
doAuth
(
packet
,
user
,
rinfo
)
{
let
existsUser
=
authenticateUser
(
user
.
username
)
...
...
@@ -79,5 +101,5 @@ function sendResponsePacket(packet, rinfo, code) {
});
server
.
send
(
response
,
0
,
response
.
length
,
rinfo
.
port
,
rinfo
.
address
);
server
Auth
.
send
(
response
,
0
,
response
.
length
,
rinfo
.
port
,
rinfo
.
address
);
}
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