Commit 161d5eff authored by Ray Bellis's avatar Ray Bellis

don't pass the secret to handlers

parent 7a89e7b5
......@@ -43,20 +43,20 @@ function defaultResponse(type, req)
return res;
}
async function invokeHandlers(req, res, secret, type, handlers)
async function invokeHandlers(req, res, type, handlers)
{
for (let handler of handlers) {
if (handler[type]) {
if (await handler[type](req, res, secret)) {
if (await handler[type](req, res)) {
break;
}
}
}
}
async function getResponse(type, req, secret, handlers)
async function getResponse(type, req, handlers)
{
const res = defaultResponse(type, req, secret);
const res = defaultResponse(type, req)
if (!res) {
// incorrect packet type - dump it on the floor
console.log(`unexpected packet code ${req.code} received`);
......@@ -64,9 +64,8 @@ async function getResponse(type, req, secret, handlers)
}
// pass to handlers, unless it's a Status-Server packet
const code = req.code.valueOf();
if (code !== 12) {
await invokeHandlers(req, res, secret, type, handlers);
if (req.code !== Code.STATUS_SERVER) {
await invokeHandlers(req, res, type, handlers);
}
return res;
......@@ -102,7 +101,7 @@ function startServer(type, port, state)
console.log(req);
}
let res = await getResponse(type, req, secret, state.handlers);
let res = await getResponse(type, req, state.handlers);
if (res) {
if (state.debug) {
console.log(`-- ${type} response --`);
......@@ -126,7 +125,6 @@ function startServer(type, port, state)
* @async
* @param {RadiusPacket} req - a received RADIUS Request packet
* @param {RadiusPacket} res - a RADIUS Reply packet to be filled out
* @param {string} secret - the secret to use to validate packets and decrypt passwords
* @return {boolean} - true to send the response without fall-through
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment