1
0
mirror of https://github.com/craigerl/aprsd.git synced 2026-01-21 04:55:38 -05:00

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.
This commit is contained in:
Walter Boring 2026-01-18 23:54:43 -05:00
parent cc8d834e5c
commit f2bd594a89
3 changed files with 30 additions and 3 deletions

View File

@ -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,

View File

@ -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,
)

View File

@ -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',
)