From f2bd594a89fc408b9370814d994d5b137002cda0 Mon Sep 17 00:00:00 2001 From: Walter Boring Date: Sun, 18 Jan 2026 23:54:43 -0500 Subject: [PATCH] Added owner_callsign This adds a new option in the aprsd.conf [DEFAULT] section that denotes who is the callsign that officially owns this APRSD instance. This will be used for sending the instance info to the registry. It's useful when the callsign used by the instance is something useful on the APRS network, which isn't necessarily the same as the person that owns it. --- aprsd/conf/common.py | 5 +++++ aprsd/plugins/version.py | 6 ++++-- tests/plugins/test_version.py | 22 +++++++++++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/aprsd/conf/common.py b/aprsd/conf/common.py index 5167527..ff0cf70 100644 --- a/aprsd/conf/common.py +++ b/aprsd/conf/common.py @@ -22,6 +22,11 @@ aprsd_opts = [ default='NOCALL', help='Callsign to use for messages sent by APRSD', ), + cfg.StrOpt( + 'owner_callsign', + default=None, + help='The ham radio license callsign that owns this APRSD instance.', + ), cfg.BoolOpt( 'enable_save', default=True, diff --git a/aprsd/plugins/version.py b/aprsd/plugins/version.py index 2e68e2e..24f4b72 100644 --- a/aprsd/plugins/version.py +++ b/aprsd/plugins/version.py @@ -1,7 +1,7 @@ import logging import aprsd -from aprsd import plugin +from aprsd import conf, plugin from aprsd.stats import collector LOG = logging.getLogger('APRSD') @@ -24,7 +24,9 @@ class VersionPlugin(plugin.APRSDRegexCommandPluginBase): # message = packet.get("message_text", None) # ack = packet.get("msgNo", "0") s = collector.Collector().collect() - return 'APRSD ver:{} uptime:{}'.format( + owner = conf.CONF.owner_callsign or '-' + return 'APRSD ver:{} uptime:{} owner:{}'.format( aprsd.__version__, s['APRSDStats']['uptime'], + owner, ) diff --git a/tests/plugins/test_version.py b/tests/plugins/test_version.py index 90f9102..3961094 100644 --- a/tests/plugins/test_version.py +++ b/tests/plugins/test_version.py @@ -40,8 +40,9 @@ class TestVersionPlugin(test_plugin.TestPlugin): } } - expected = f'APRSD ver:{aprsd.__version__} uptime:00:00:00' CONF.callsign = fake.FAKE_TO_CALLSIGN + CONF.owner_callsign = None + expected = f'APRSD ver:{aprsd.__version__} uptime:00:00:00 owner:-' version = version_plugin.VersionPlugin() version.enabled = True @@ -62,3 +63,22 @@ class TestVersionPlugin(test_plugin.TestPlugin): # Verify the mock was called exactly once mock_collector_instance.collect.assert_called_once() + + @mock.patch('aprsd.stats.collector.Collector') + def test_version_shows_owner_callsign_when_set(self, mock_collector_class): + mock_collector_instance = mock_collector_class.return_value + mock_collector_instance.collect.return_value = { + 'APRSDStats': {'uptime': '01:23:45'}, + } + + CONF.callsign = fake.FAKE_TO_CALLSIGN + CONF.owner_callsign = 'K0WN3R' + version = version_plugin.VersionPlugin() + version.enabled = True + + packet = fake.fake_packet(message='version', msg_number=1) + actual = version.filter(packet) + self.assertEqual( + actual, + f'APRSD ver:{aprsd.__version__} uptime:01:23:45 owner:K0WN3R', + )