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
9e73cf2d
Commit
9e73cf2d
authored
May 04, 2023
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
640271dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
29 deletions
+7
-29
app.js
app.js
+7
-29
No files found.
app.js
View file @
9e73cf2d
...
...
@@ -4,15 +4,13 @@ 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
const
serverAuth
=
dgram
.
createSocket
(
'
udp4
'
);
const
serverAccounting
=
dgram
.
createSocket
(
'
udp4
'
);
const
server
=
dgram
.
createSocket
(
'
udp4
'
);
server
Auth
.
on
(
'
message
'
,
(
msg
,
rinfo
)
=>
{
server
.
on
(
'
message
'
,
(
msg
,
rinfo
)
=>
{
const
packet
=
radius
.
decode
({
packet
:
msg
,
secret
});
if
(
packet
.
code
!==
'
Access-Request
'
)
{
...
...
@@ -31,32 +29,12 @@ serverAuth.on('message', (msg, rinfo) => {
doAuth
(
packet
,
user
,
rinfo
)
});
server
Auth
.
on
(
'
listening
'
,
()
=>
{
const
address
=
server
Auth
.
address
();
console
.
log
(
'
RADIUS server
Auth
listening on port
'
,
address
.
port
);
server
.
on
(
'
listening
'
,
()
=>
{
const
address
=
server
.
address
();
console
.
log
(
'
RADIUS server listening on port
'
,
address
.
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
);
server
.
bind
(
port
);
async
function
doAuth
(
packet
,
user
,
rinfo
)
{
let
existsUser
=
authenticateUser
(
user
.
username
)
...
...
@@ -101,5 +79,5 @@ function sendResponsePacket(packet, rinfo, code) {
});
server
Auth
.
send
(
response
,
0
,
response
.
length
,
rinfo
.
port
,
rinfo
.
address
);
server
.
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