This commit adds support for the port to be specified when using the radius monitor type. A check has been implemented to ensure that a null value is not passed to the radius check function as could occur with monitors that were created before this change was introduced. The default port of 1812 is displayed when the user selects the radius monitor in much the same way as the DNS port is handled. The port was not included in the hostname in the form hostname:port in order to avoid issues with IPv6 addresses and monitors that had been created before this change was implemented. Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>
This commit is contained in:
parent
b24c75eec5
commit
f459ea845c
|
@ -534,6 +534,17 @@ class Monitor extends BeanModel {
|
||||||
bean.ping = dayjs().valueOf() - startTime;
|
bean.ping = dayjs().valueOf() - startTime;
|
||||||
} else if (this.type === "radius") {
|
} else if (this.type === "radius") {
|
||||||
let startTime = dayjs().valueOf();
|
let startTime = dayjs().valueOf();
|
||||||
|
|
||||||
|
// Handle monitors that were created before the
|
||||||
|
// update and as such don't have a value for
|
||||||
|
// this.port.
|
||||||
|
let port;
|
||||||
|
if (this.port == null) {
|
||||||
|
port = 1812;
|
||||||
|
} else {
|
||||||
|
port = this.port;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resp = await radius(
|
const resp = await radius(
|
||||||
this.hostname,
|
this.hostname,
|
||||||
|
@ -541,7 +552,8 @@ class Monitor extends BeanModel {
|
||||||
this.radiusPassword,
|
this.radiusPassword,
|
||||||
this.radiusCalledStationId,
|
this.radiusCalledStationId,
|
||||||
this.radiusCallingStationId,
|
this.radiusCallingStationId,
|
||||||
this.radiusSecret
|
this.radiusSecret,
|
||||||
|
port
|
||||||
);
|
);
|
||||||
if (resp.code) {
|
if (resp.code) {
|
||||||
bean.msg = resp.code;
|
bean.msg = resp.code;
|
||||||
|
|
|
@ -291,6 +291,17 @@ exports.postgresQuery = function (connectionString, query) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query radius server
|
||||||
|
* @param {string} hostname Hostname of radius server
|
||||||
|
* @param {string} username Username to use
|
||||||
|
* @param {string} password Password to use
|
||||||
|
* @param {string} calledStationId ID of called station
|
||||||
|
* @param {string} callingStationId ID of calling station
|
||||||
|
* @param {string} secret Secret to use
|
||||||
|
* @param {number} [port=1812] Port to contact radius server on
|
||||||
|
* @returns {Promise<any>}
|
||||||
|
*/
|
||||||
exports.radius = function (
|
exports.radius = function (
|
||||||
hostname,
|
hostname,
|
||||||
username,
|
username,
|
||||||
|
@ -298,9 +309,11 @@ exports.radius = function (
|
||||||
calledStationId,
|
calledStationId,
|
||||||
callingStationId,
|
callingStationId,
|
||||||
secret,
|
secret,
|
||||||
|
port = 1812,
|
||||||
) {
|
) {
|
||||||
const client = new radiusClient({
|
const client = new radiusClient({
|
||||||
host: hostname,
|
host: hostname,
|
||||||
|
hostPort: port,
|
||||||
dictionaries: [ file ],
|
dictionaries: [ file ],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -97,8 +97,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Port -->
|
<!-- Port -->
|
||||||
<!-- For TCP Port / Steam / MQTT Type -->
|
<!-- For TCP Port / Steam / MQTT / Radius Type -->
|
||||||
<div v-if="monitor.type === 'port' || monitor.type === 'steam' || monitor.type === 'mqtt'" class="my-3">
|
<div v-if="monitor.type === 'port' || monitor.type === 'steam' || monitor.type === 'mqtt' || monitor.type === 'radius'" class="my-3">
|
||||||
<label for="port" class="form-label">{{ $t("Port") }}</label>
|
<label for="port" class="form-label">{{ $t("Port") }}</label>
|
||||||
<input id="port" v-model="monitor.port" type="number" class="form-control" required min="0" max="65535" step="1">
|
<input id="port" v-model="monitor.port" type="number" class="form-control" required min="0" max="65535" step="1">
|
||||||
</div>
|
</div>
|
||||||
|
@ -616,9 +616,11 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set default port for DNS if not already defined
|
// Set default port for DNS if not already defined
|
||||||
if (! this.monitor.port || this.monitor.port === "53") {
|
if (! this.monitor.port || this.monitor.port === "53" || this.monitor.port === "1812") {
|
||||||
if (this.monitor.type === "dns") {
|
if (this.monitor.type === "dns") {
|
||||||
this.monitor.port = "53";
|
this.monitor.port = "53";
|
||||||
|
} else if (this.monitor.type === "radius") {
|
||||||
|
this.monitor.port = "1812";
|
||||||
} else {
|
} else {
|
||||||
this.monitor.port = undefined;
|
this.monitor.port = undefined;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue