#76 added trusted connection ranges for modem messages
This commit is contained in:
@@ -6,13 +6,15 @@ local config = {}
|
||||
config.SERVER_PORT = 16000
|
||||
-- port to listen to incoming packets FROM server
|
||||
config.LISTEN_PORT = 15001
|
||||
-- max trusted modem message distance (0 to disable check)
|
||||
config.TRUSTED_RANGE = 0
|
||||
-- log path
|
||||
config.LOG_PATH = "/log.txt"
|
||||
-- log mode
|
||||
-- 0 = APPEND (adds to existing file on start)
|
||||
-- 1 = NEW (replaces existing file on start)
|
||||
config.LOG_MODE = 0
|
||||
-- RTU peripheral devices (name: side/network device name)
|
||||
-- RTU peripheral devices (named: side/network device name)
|
||||
config.RTU_DEVICES = {
|
||||
{
|
||||
name = "boilerValve_0",
|
||||
@@ -33,17 +35,22 @@ config.RTU_REDSTONE = {
|
||||
-- {
|
||||
-- port = rsio.IO.WASTE_PO,
|
||||
-- side = "top",
|
||||
-- bundled_color = colors.blue
|
||||
-- bundled_color = colors.red
|
||||
-- },
|
||||
-- {
|
||||
-- port = rsio.IO.WASTE_PU,
|
||||
-- side = "top",
|
||||
-- bundled_color = colors.cyan
|
||||
-- bundled_color = colors.orange
|
||||
-- },
|
||||
-- {
|
||||
-- port = rsio.IO.WASTE_POPL,
|
||||
-- side = "top",
|
||||
-- bundled_color = colors.yellow
|
||||
-- },
|
||||
-- {
|
||||
-- port = rsio.IO.WASTE_AM,
|
||||
-- side = "top",
|
||||
-- bundled_color = colors.purple
|
||||
-- bundled_color = colors.lime
|
||||
-- }
|
||||
-- }
|
||||
-- }
|
||||
|
||||
29
rtu/rtu.lua
29
rtu/rtu.lua
@@ -160,12 +160,13 @@ function rtu.init_unit()
|
||||
end
|
||||
|
||||
-- RTU Communications
|
||||
---@param version string
|
||||
---@param modem table
|
||||
---@param local_port integer
|
||||
---@param server_port integer
|
||||
---@param conn_watchdog watchdog
|
||||
function rtu.comms(version, modem, local_port, server_port, conn_watchdog)
|
||||
---@param version string RTU version
|
||||
---@param modem table modem device
|
||||
---@param local_port integer local listening port
|
||||
---@param server_port integer remote server port
|
||||
---@param range integer trusted device connection range
|
||||
---@param conn_watchdog watchdog watchdog reference
|
||||
function rtu.comms(version, modem, local_port, server_port, range, conn_watchdog)
|
||||
local self = {
|
||||
version = version,
|
||||
seq_num = 0,
|
||||
@@ -177,6 +178,15 @@ function rtu.comms(version, modem, local_port, server_port, conn_watchdog)
|
||||
conn_watchdog = conn_watchdog
|
||||
}
|
||||
|
||||
---@class rtu_comms
|
||||
local public = {}
|
||||
|
||||
local insert = table.insert
|
||||
|
||||
comms.set_trusted_range(range)
|
||||
|
||||
-- PRIVATE FUNCTIONS --
|
||||
|
||||
-- configure modem channels
|
||||
local function _conf_channels()
|
||||
self.modem.closeAll()
|
||||
@@ -185,13 +195,6 @@ function rtu.comms(version, modem, local_port, server_port, conn_watchdog)
|
||||
|
||||
_conf_channels()
|
||||
|
||||
---@class rtu_comms
|
||||
local public = {}
|
||||
|
||||
local insert = table.insert
|
||||
|
||||
-- PRIVATE FUNCTIONS --
|
||||
|
||||
-- send a scada management packet
|
||||
---@param msg_type SCADA_MGMT_TYPES
|
||||
---@param msg table
|
||||
|
||||
@@ -25,7 +25,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
|
||||
local sps_rtu = require("rtu.dev.sps_rtu")
|
||||
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
||||
|
||||
local RTU_VERSION = "beta-v0.9.13"
|
||||
local RTU_VERSION = "beta-v0.10.0"
|
||||
|
||||
local rtu_t = types.rtu_t
|
||||
|
||||
@@ -42,6 +42,7 @@ local cfv = util.new_validator()
|
||||
|
||||
cfv.assert_port(config.SERVER_PORT)
|
||||
cfv.assert_port(config.LISTEN_PORT)
|
||||
cfv.assert_type_int(config.TRUSTED_RANGE)
|
||||
cfv.assert_type_str(config.LOG_PATH)
|
||||
cfv.assert_type_int(config.LOG_MODE)
|
||||
cfv.assert_type_table(config.RTU_DEVICES)
|
||||
@@ -390,7 +391,8 @@ local function main()
|
||||
log.debug("boot> conn watchdog started")
|
||||
|
||||
-- setup comms
|
||||
smem_sys.rtu_comms = rtu.comms(RTU_VERSION, smem_dev.modem, config.LISTEN_PORT, config.SERVER_PORT, smem_sys.conn_watchdog)
|
||||
smem_sys.rtu_comms = rtu.comms(RTU_VERSION, smem_dev.modem, config.LISTEN_PORT, config.SERVER_PORT,
|
||||
config.TRUSTED_RANGE, smem_sys.conn_watchdog)
|
||||
log.debug("boot> comms init")
|
||||
|
||||
-- init threads
|
||||
|
||||
Reference in New Issue
Block a user