#76 added trusted connection ranges for modem messages
This commit is contained in:
@@ -6,6 +6,8 @@ config.SCADA_SV_PORT = 16100
|
||||
config.SCADA_SV_LISTEN = 16101
|
||||
-- listen port for SCADA coordinator API access
|
||||
config.SCADA_API_LISTEN = 16200
|
||||
-- max trusted modem message distance (0 to disable check)
|
||||
config.TRUSTED_RANGE = 0
|
||||
|
||||
-- expected number of reactor units, used only to require that number of unit monitors
|
||||
config.NUM_UNITS = 4
|
||||
|
||||
@@ -191,13 +191,14 @@ function coordinator.log_comms_connecting(message)
|
||||
end
|
||||
|
||||
-- coordinator communications
|
||||
---@param version string
|
||||
---@param modem table
|
||||
---@param sv_port integer
|
||||
---@param sv_listen integer
|
||||
---@param api_listen integer
|
||||
---@param version string coordinator version
|
||||
---@param modem table modem device
|
||||
---@param sv_port integer port of configured supervisor
|
||||
---@param sv_listen integer listening port for supervisor replys
|
||||
---@param api_listen integer listening port for pocket API
|
||||
---@param range integer trusted device connection range
|
||||
---@param sv_watchdog watchdog
|
||||
function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, sv_watchdog)
|
||||
function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, range, sv_watchdog)
|
||||
local self = {
|
||||
sv_linked = false,
|
||||
sv_seq_num = 0,
|
||||
@@ -209,6 +210,8 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, sv_wa
|
||||
---@class coord_comms
|
||||
local public = {}
|
||||
|
||||
comms.set_trusted_range(range)
|
||||
|
||||
-- PRIVATE FUNCTIONS --
|
||||
|
||||
-- configure modem channels
|
||||
@@ -512,8 +515,8 @@ function coordinator.comms(version, modem, sv_port, sv_listen, api_listen, sv_wa
|
||||
|
||||
---@class facility_conf
|
||||
local conf = {
|
||||
num_units = config[1],
|
||||
defs = {} -- boilers and turbines
|
||||
num_units = config[1], ---@type integer
|
||||
defs = {} -- boilers and turbines
|
||||
}
|
||||
|
||||
if (#config - 1) == (conf.num_units * 2) then
|
||||
|
||||
@@ -19,7 +19,7 @@ local iocontrol = require("coordinator.iocontrol")
|
||||
local renderer = require("coordinator.renderer")
|
||||
local sounder = require("coordinator.sounder")
|
||||
|
||||
local COORDINATOR_VERSION = "beta-v0.9.1"
|
||||
local COORDINATOR_VERSION = "beta-v0.9.2"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
@@ -41,6 +41,7 @@ local cfv = util.new_validator()
|
||||
cfv.assert_port(config.SCADA_SV_PORT)
|
||||
cfv.assert_port(config.SCADA_SV_LISTEN)
|
||||
cfv.assert_port(config.SCADA_API_LISTEN)
|
||||
cfv.assert_type_int(config.TRUSTED_RANGE)
|
||||
cfv.assert_type_int(config.NUM_UNITS)
|
||||
cfv.assert_type_bool(config.RECOLOR)
|
||||
cfv.assert_type_num(config.SOUNDER_VOLUME)
|
||||
@@ -146,7 +147,8 @@ local function main()
|
||||
log.debug("boot> conn watchdog created")
|
||||
|
||||
-- start comms, open all channels
|
||||
local coord_comms = coordinator.comms(COORDINATOR_VERSION, modem, config.SCADA_SV_PORT, config.SCADA_SV_LISTEN, config.SCADA_API_LISTEN, conn_watchdog)
|
||||
local coord_comms = coordinator.comms(COORDINATOR_VERSION, modem, config.SCADA_SV_PORT, config.SCADA_SV_LISTEN,
|
||||
config.SCADA_API_LISTEN, config.TRUSTED_RANGE, conn_watchdog)
|
||||
log.debug("boot> comms init")
|
||||
log_comms("comms initialized")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user