Merge pull request #3490 from chakflying/fix/radius-retry

Fix: Incorrect radius error & retry handling
pull/3318/head
Louis Lam 1 year ago committed by GitHub
commit 0a59fef7d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -792,7 +792,6 @@ class Monitor extends BeanModel {
port = this.port;
}
try {
const resp = await radius(
this.hostname,
this.radiusUsername,
@ -801,20 +800,11 @@ class Monitor extends BeanModel {
this.radiusCallingStationId,
this.radiusSecret,
port,
this.interval * 1000 * 0.8,
this.interval * 1000 * 0.4,
);
if (resp.code) {
bean.msg = resp.code;
}
bean.status = UP;
} catch (error) {
bean.status = DOWN;
if (error.response?.code) {
bean.msg = error.response.code;
} else {
bean.msg = error.message;
}
}
bean.ping = dayjs().valueOf() - startTime;
} else if (this.type === "redis") {
let startTime = dayjs().valueOf();

@ -486,6 +486,7 @@ exports.radius = function (
host: hostname,
hostPort: port,
timeout: timeout,
retries: 1,
dictionaries: [ file ],
});
@ -497,6 +498,12 @@ exports.radius = function (
[ attributes.CALLING_STATION_ID, callingStationId ],
[ attributes.CALLED_STATION_ID, calledStationId ],
],
}).catch((error) => {
if (error.response?.code) {
throw Error(error.response.code);
} else {
throw Error(error.message);
}
});
};

@ -0,0 +1,13 @@
# Container running a test radius server
# More instructions in https://github.com/louislam/uptime-kuma/pull/1635
FROM freeradius/freeradius-server:latest
RUN mkdir -p /etc/raddb/mods-config/files/
RUN echo "client net {" > /etc/raddb/clients.conf
RUN echo " ipaddr = 172.17.0.0/16" >> /etc/raddb/clients.conf
RUN echo " secret = testing123" >> /etc/raddb/clients.conf
RUN echo "}" >> /etc/raddb/clients.conf
RUN echo "bob Cleartext-Password := \"testpw\"" > /etc/raddb/mods-config/files/authorize
Loading…
Cancel
Save