Updated all applications to support socket reporting
This commit is contained in:
parent
d256efc9e1
commit
416ab12c5f
@ -40,12 +40,12 @@ from importlib import import_module
|
|||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
|
|
||||||
# Twisted is pretty important, so I keep it separate
|
# Twisted is pretty important, so I keep it separate
|
||||||
from twisted.internet.protocol import DatagramProtocol
|
from twisted.internet.protocol import Factory, Protocol
|
||||||
from twisted.internet import reactor
|
from twisted.protocols.basic import NetstringReceiver
|
||||||
from twisted.internet import task
|
from twisted.internet import reactor, task
|
||||||
|
|
||||||
# Things we import from the main hblink module
|
# Things we import from the main hblink module
|
||||||
from hblink import HBSYSTEM, systems, int_id, hblink_handler
|
from hblink import HBSYSTEM, systems, hblink_handler, reportFactory, REPORT_OPCODES, config_reports
|
||||||
from dmr_utils.utils import hex_str_3, int_id, get_alias
|
from dmr_utils.utils import hex_str_3, int_id, get_alias
|
||||||
from dmr_utils import decode, bptc, const
|
from dmr_utils import decode, bptc, const
|
||||||
from acl import acl_check, acl_build
|
from acl import acl_check, acl_build
|
||||||
@ -80,8 +80,8 @@ def import_rules(_rules):
|
|||||||
|
|
||||||
class bridgeallSYSTEM(HBSYSTEM):
|
class bridgeallSYSTEM(HBSYSTEM):
|
||||||
|
|
||||||
def __init__(self, _name, _config, _logger):
|
def __init__(self, _name, _config, _logger, _report):
|
||||||
HBSYSTEM.__init__(self, _name, _config, _logger)
|
HBSYSTEM.__init__(self, _name, _config, _logger, _report)
|
||||||
|
|
||||||
# Status information for the system, TS1 & TS2
|
# Status information for the system, TS1 & TS2
|
||||||
# 1 & 2 are "timeslot"
|
# 1 & 2 are "timeslot"
|
||||||
@ -318,12 +318,14 @@ if __name__ == '__main__':
|
|||||||
logger.warning('No %s ACL for system %s - initializing \'PERMIT:ALL\'', acl_type, system)
|
logger.warning('No %s ACL for system %s - initializing \'PERMIT:ALL\'', acl_type, system)
|
||||||
ACL[acl_type].update({system: {1: acl_build('PERMIT:ALL'), 2: acl_build('PERMIT:ALL')}})
|
ACL[acl_type].update({system: {1: acl_build('PERMIT:ALL'), 2: acl_build('PERMIT:ALL')}})
|
||||||
|
|
||||||
|
# INITIALIZE THE REPORTING LOOP
|
||||||
|
report_server = config_reports(CONFIG, logger, reportFactory)
|
||||||
|
|
||||||
# HBlink instance creation
|
# HBlink instance creation
|
||||||
logger.info('HBlink \'hb_bridge_all.py\' (c) 2016 N0MJS & the K0USY Group - SYSTEM STARTING...')
|
logger.info('HBlink \'hb_bridge_all.py\' (c) 2016 N0MJS & the K0USY Group - SYSTEM STARTING...')
|
||||||
for system in CONFIG['SYSTEMS']:
|
for system in CONFIG['SYSTEMS']:
|
||||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||||
systems[system] = bridgeallSYSTEM(system, CONFIG, logger)
|
systems[system] = bridgeallSYSTEM(system, CONFIG, logger, report_server)
|
||||||
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
||||||
logger.debug('%s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
logger.debug('%s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ from twisted.protocols.basic import NetstringReceiver
|
|||||||
from twisted.internet import reactor, task
|
from twisted.internet import reactor, task
|
||||||
|
|
||||||
# Things we import from the main hblink module
|
# Things we import from the main hblink module
|
||||||
from hblink import HBSYSTEM, systems, hblink_handler, reportFactory, REPORT_OPCODES
|
from hblink import HBSYSTEM, systems, hblink_handler, reportFactory, REPORT_OPCODES, config_reports
|
||||||
from dmr_utils.utils import hex_str_3, int_id, get_alias
|
from dmr_utils.utils import hex_str_3, int_id, get_alias
|
||||||
from dmr_utils import decode, bptc, const
|
from dmr_utils import decode, bptc, const
|
||||||
import hb_config
|
import hb_config
|
||||||
@ -66,28 +66,6 @@ __status__ = 'pre-alpha'
|
|||||||
|
|
||||||
# Module gobal varaibles
|
# Module gobal varaibles
|
||||||
|
|
||||||
|
|
||||||
# Timed loop used for reporting HBP status
|
|
||||||
#
|
|
||||||
# REPORT BASED ON THE TYPE SELECTED IN THE MAIN CONFIG FILE
|
|
||||||
def config_reports(_config, _logger, _factory):
|
|
||||||
if _config['REPORTS']['REPORT']:
|
|
||||||
def reporting_loop(_logger, _server):
|
|
||||||
_logger.debug('Periodic reporting loop started')
|
|
||||||
_server.send_config()
|
|
||||||
_server.send_bridge()
|
|
||||||
|
|
||||||
_logger.info('HBlink TCP reporting server configured')
|
|
||||||
|
|
||||||
report_server = _factory(_config, _logger)
|
|
||||||
report_server.clients = []
|
|
||||||
reactor.listenTCP(_config['REPORTS']['REPORT_PORT'], report_server)
|
|
||||||
|
|
||||||
reporting = task.LoopingCall(reporting_loop, _logger, report_server)
|
|
||||||
reporting.start(_config['REPORTS']['REPORT_INTERVAL'])
|
|
||||||
|
|
||||||
return report_server
|
|
||||||
|
|
||||||
# Import Bridging rules
|
# Import Bridging rules
|
||||||
# Note: A stanza *must* exist for any MASTER or CLIENT configured in the main
|
# Note: A stanza *must* exist for any MASTER or CLIENT configured in the main
|
||||||
# configuration file and listed as "active". It can be empty,
|
# configuration file and listed as "active". It can be empty,
|
||||||
|
16
hb_parrot.py
16
hb_parrot.py
@ -30,12 +30,12 @@ from time import time, sleep
|
|||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
|
||||||
# Twisted is pretty important, so I keep it separate
|
# Twisted is pretty important, so I keep it separate
|
||||||
from twisted.internet.protocol import DatagramProtocol
|
from twisted.internet.protocol import Factory, Protocol
|
||||||
from twisted.internet import reactor
|
from twisted.protocols.basic import NetstringReceiver
|
||||||
from twisted.internet import task
|
from twisted.internet import reactor, task
|
||||||
|
|
||||||
# Things we import from the main hblink module
|
# Things we import from the main hblink module
|
||||||
from hblink import HBSYSTEM, systems, int_id, hblink_handler
|
from hblink import HBSYSTEM, systems, hblink_handler, reportFactory, REPORT_OPCODES, config_reports
|
||||||
from dmr_utils.utils import hex_str_3, int_id, get_alias
|
from dmr_utils.utils import hex_str_3, int_id, get_alias
|
||||||
from dmr_utils import decode, bptc, const
|
from dmr_utils import decode, bptc, const
|
||||||
import hb_config
|
import hb_config
|
||||||
@ -55,8 +55,8 @@ __status__ = 'pre-alpha'
|
|||||||
|
|
||||||
class parrot(HBSYSTEM):
|
class parrot(HBSYSTEM):
|
||||||
|
|
||||||
def __init__(self, _name, _config, _logger):
|
def __init__(self, _name, _config, _logger, _report):
|
||||||
HBSYSTEM.__init__(self, _name, _config, _logger)
|
HBSYSTEM.__init__(self, _name, _config, _logger, _report)
|
||||||
|
|
||||||
# Status information for the system, TS1 & TS2
|
# Status information for the system, TS1 & TS2
|
||||||
# 1 & 2 are "timeslot"
|
# 1 & 2 are "timeslot"
|
||||||
@ -218,12 +218,14 @@ if __name__ == '__main__':
|
|||||||
if talkgroup_ids:
|
if talkgroup_ids:
|
||||||
logger.info('ID ALIAS MAPPER: talkgroup_ids dictionary is available')
|
logger.info('ID ALIAS MAPPER: talkgroup_ids dictionary is available')
|
||||||
|
|
||||||
|
# INITIALIZE THE REPORTING LOOP
|
||||||
|
report_server = config_reports(CONFIG, logger, reportFactory)
|
||||||
|
|
||||||
# HBlink instance creation
|
# HBlink instance creation
|
||||||
logger.info('HBlink \'hb_parrot.py\' (c) 2016 N0MJS & the K0USY Group - SYSTEM STARTING...')
|
logger.info('HBlink \'hb_parrot.py\' (c) 2016 N0MJS & the K0USY Group - SYSTEM STARTING...')
|
||||||
for system in CONFIG['SYSTEMS']:
|
for system in CONFIG['SYSTEMS']:
|
||||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||||
systems[system] = parrot(system, CONFIG, logger)
|
systems[system] = parrot(system, CONFIG, logger, report_server)
|
||||||
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
||||||
logger.debug('%s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
logger.debug('%s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
||||||
|
|
||||||
|
17
hb_router.py
17
hb_router.py
@ -38,12 +38,12 @@ from time import time
|
|||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
|
||||||
# Twisted is pretty important, so I keep it separate
|
# Twisted is pretty important, so I keep it separate
|
||||||
from twisted.internet.protocol import DatagramProtocol
|
from twisted.internet.protocol import Factory, Protocol
|
||||||
from twisted.internet import reactor
|
from twisted.protocols.basic import NetstringReceiver
|
||||||
from twisted.internet import task
|
from twisted.internet import reactor, task
|
||||||
|
|
||||||
# Things we import from the main hblink module
|
# Things we import from the main hblink module
|
||||||
from hblink import HBSYSTEM, systems, int_id, hblink_handler
|
from hblink import HBSYSTEM, systems, hblink_handler, reportFactory, REPORT_OPCODES, config_reports
|
||||||
from dmr_utils.utils import hex_str_3, int_id, get_alias
|
from dmr_utils.utils import hex_str_3, int_id, get_alias
|
||||||
from dmr_utils import decode, bptc, const
|
from dmr_utils import decode, bptc, const
|
||||||
import hb_config
|
import hb_config
|
||||||
@ -174,8 +174,8 @@ def rule_timer_loop():
|
|||||||
|
|
||||||
class routerSYSTEM(HBSYSTEM):
|
class routerSYSTEM(HBSYSTEM):
|
||||||
|
|
||||||
def __init__(self, _name, _config, _logger):
|
def __init__(self, _name, _config, _logger, _report):
|
||||||
HBSYSTEM.__init__(self, _name, _config, _logger)
|
HBSYSTEM.__init__(self, _name, _config, _logger, _report)
|
||||||
|
|
||||||
# Status information for the system, TS1 & TS2
|
# Status information for the system, TS1 & TS2
|
||||||
# 1 & 2 are "timeslot"
|
# 1 & 2 are "timeslot"
|
||||||
@ -480,11 +480,14 @@ if __name__ == '__main__':
|
|||||||
# Build the Access Control List
|
# Build the Access Control List
|
||||||
ACL = build_acl('sub_acl')
|
ACL = build_acl('sub_acl')
|
||||||
|
|
||||||
|
# INITIALIZE THE REPORTING LOOP
|
||||||
|
report_server = config_reports(CONFIG, logger, reportFactory)
|
||||||
|
|
||||||
# HBlink instance creation
|
# HBlink instance creation
|
||||||
logger.info('HBlink \'hb_router.py\' (c) 2016 N0MJS & the K0USY Group - SYSTEM STARTING...')
|
logger.info('HBlink \'hb_router.py\' (c) 2016 N0MJS & the K0USY Group - SYSTEM STARTING...')
|
||||||
for system in CONFIG['SYSTEMS']:
|
for system in CONFIG['SYSTEMS']:
|
||||||
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
if CONFIG['SYSTEMS'][system]['ENABLED']:
|
||||||
systems[system] = routerSYSTEM(system, CONFIG, logger)
|
systems[system] = routerSYSTEM(system, CONFIG, logger, report_server)
|
||||||
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
reactor.listenUDP(CONFIG['SYSTEMS'][system]['PORT'], systems[system], interface=CONFIG['SYSTEMS'][system]['IP'])
|
||||||
logger.debug('%s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
logger.debug('%s instance created: %s, %s', CONFIG['SYSTEMS'][system]['MODE'], system, systems[system])
|
||||||
|
|
||||||
|
@ -22,8 +22,9 @@ MAX_MISSED: 3
|
|||||||
# REPORT_CLIENTS - comma separated list of IPs you will allow clients
|
# REPORT_CLIENTS - comma separated list of IPs you will allow clients
|
||||||
# to connect on. Entering a * will allow all.
|
# to connect on. Entering a * will allow all.
|
||||||
#
|
#
|
||||||
|
# ****FOR NOW MUST BE TRUE - USE THE LOOPBACK IF YOU DON'T USE THIS!!!****
|
||||||
[REPORTS]
|
[REPORTS]
|
||||||
REPORT: False
|
REPORT: True
|
||||||
REPORT_INTERVAL: 60
|
REPORT_INTERVAL: 60
|
||||||
REPORT_PORT: 4321
|
REPORT_PORT: 4321
|
||||||
REPORT_CLIENTS: 127.0.0.1
|
REPORT_CLIENTS: 127.0.0.1
|
||||||
|
@ -68,7 +68,7 @@ systems = {}
|
|||||||
#
|
#
|
||||||
# REPORT BASED ON THE TYPE SELECTED IN THE MAIN CONFIG FILE
|
# REPORT BASED ON THE TYPE SELECTED IN THE MAIN CONFIG FILE
|
||||||
def config_reports(_config, _logger, _factory):
|
def config_reports(_config, _logger, _factory):
|
||||||
if _config['REPORTS']['REPORT']:
|
if True: #_config['REPORTS']['REPORT']:
|
||||||
def reporting_loop(_logger, _server):
|
def reporting_loop(_logger, _server):
|
||||||
_logger.debug('Periodic reporting loop started')
|
_logger.debug('Periodic reporting loop started')
|
||||||
_server.send_config()
|
_server.send_config()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user