fix: strip NUL-padded CALLSIGN instead of showing raw bytes

Some peers NUL-pad instead of space-pad; reuse the existing
normalize_fixed_width_ascii helper instead of a plain .strip().
pull/66/head
Rodrigo Pérez 2 months ago
parent a052779ca8
commit e13e0046f5

@ -31,6 +31,7 @@ import time
from typing import Any, Callable
from ..domain import HBPF_SLT_VTERM, bytes_3, int_id
from ..domain.hbp_protocol import normalize_fixed_width_ascii
from .server_voice import server_voice_rf_src_bytes
logger = logging.getLogger(__name__)
@ -97,8 +98,7 @@ class IdentUseCases:
for _peerid in peers:
peer_cfg = peers.get(_peerid, {})
if isinstance(peer_cfg, dict) and peer_cfg.get("CALLSIGN"):
cs = peer_cfg["CALLSIGN"]
_callsign = cs.decode("utf-8", errors="replace") if isinstance(cs, bytes) else cs
_callsign = normalize_fixed_width_ascii(peer_cfg["CALLSIGN"])
break
if not _callsign:
logger.debug("(IDENT) %s System has no peers or no recorded callsign, skipping", system)

@ -51,6 +51,7 @@ from typing import Any
from ...domain import bytes_3, bytes_4, int_id
from ...domain.config_coerce import coerce_bool, parse_options_single
from ...domain.dynamic_tg import DynamicTgEntry
from ...domain.hbp_protocol import normalize_fixed_width_ascii
from ..proxy.deployment import is_proxy_inject_only
logger = logging.getLogger(__name__)
@ -805,10 +806,7 @@ class SubscriptionTableMixin:
parts.append(f"peers_connected={len(connected)}")
if connected:
def _cs(c):
v = c.get("CALLSIGN") or b""
if isinstance(v, bytes):
return v.decode("utf8", errors="replace").strip() or "?"
return str(v).strip() or "?"
return normalize_fixed_width_ascii(c.get("CALLSIGN")) or "?"
parts.append(
"peers=[%s]"
% ", ".join("%s/%s" % (p.get("RADIO_ID", "?"), _cs(p)) for p in connected[:10])

Loading…
Cancel
Save

Powered by TurnKey Linux.