diff --git a/server/model/monitor.js b/server/model/monitor.js index ac8925608..c0a3cce65 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -534,6 +534,17 @@ class Monitor extends BeanModel { bean.ping = dayjs().valueOf() - startTime; } else if (this.type === "radius") { 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 { const resp = await radius( this.hostname, @@ -541,7 +552,8 @@ class Monitor extends BeanModel { this.radiusPassword, this.radiusCalledStationId, this.radiusCallingStationId, - this.radiusSecret + this.radiusSecret, + port ); if (resp.code) { bean.msg = resp.code; diff --git a/server/util-server.js b/server/util-server.js index cf303ba85..b975a43f3 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -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} + */ exports.radius = function ( hostname, username, @@ -298,9 +309,11 @@ exports.radius = function ( calledStationId, callingStationId, secret, + port = 1812, ) { const client = new radiusClient({ host: hostname, + hostPort: port, dictionaries: [ file ], }); diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 99cbeb95f..6d1a7e512 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -97,8 +97,8 @@ - -
+ +
@@ -616,9 +616,11 @@ export default { } // 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") { this.monitor.port = "53"; + } else if (this.monitor.type === "radius") { + this.monitor.port = "1812"; } else { this.monitor.port = undefined; }