Bind OP25 control API and terminal to loopback by default
Both :8001 (FastAPI control API) and :8081 (OP25's HTTP terminal) listened on 0.0.0.0 with no authentication, on a container that is privileged with /dev mounted and network_mode: host. Nodes get deployed to third-party sites, so that exposed start/stop/retune to anyone on the host's LAN. All three containers share the host network namespace, so edge-node still reaches both over 127.0.0.1 unchanged. OP25_DEBUG_EXPOSE=true restores the old 0.0.0.0 binding and logs a loud warning; it is off by default. Confirmed against boatbod/op25 gr310 that the terminal's http:<host>:<port> string is honoured as a real bind address (http_server.py splits it and hands the host to create_server), so no flag was invented. Also reorder models.py so IcecastConfig precedes ConfigGenerator, which annotates a field with it. That only worked because python:slim-trixie is currently Python 3.14, where PEP 649 defers annotation evaluation; on 3.13 or earlier the same file is a hard NameError at import. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
d6dfe5a293
commit
a61a7b2c31
@@ -1,6 +1,7 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import List, Optional, Union
|
||||
from enum import Enum
|
||||
from config import bind_host
|
||||
|
||||
# Preset device settings for common RTL-SDR hardware.
|
||||
# gains: OP25 gain string passed to the device block.
|
||||
@@ -34,6 +35,20 @@ class TalkgroupTag(BaseModel):
|
||||
talkgroup: str
|
||||
tagDec: int
|
||||
|
||||
# Defined before ConfigGenerator, which annotates a field with it. Under
|
||||
# Python 3.14 (PEP 649) annotations are evaluated lazily, so the original
|
||||
# order happened to work in the container; on 3.13 or earlier it is a hard
|
||||
# NameError at import. Keep the definition above its first use so this file
|
||||
# does not depend on the base image's Python version.
|
||||
class IcecastConfig(BaseModel):
|
||||
icecast_host: str
|
||||
icecast_port: int
|
||||
icecast_mountpoint: str
|
||||
icecast_password: str
|
||||
icecast_description: Optional[str] = "OP25"
|
||||
icecast_genre: Optional[str] = "Public Safety"
|
||||
|
||||
|
||||
class ConfigGenerator(BaseModel):
|
||||
type: DecodeMode
|
||||
systemName: str
|
||||
@@ -115,7 +130,9 @@ class MetadataConfig(BaseModel):
|
||||
|
||||
class TerminalConfig(BaseModel):
|
||||
module: Optional[str] = "terminal.py"
|
||||
terminal_type: Optional[str] = "http:0.0.0.0:8081"
|
||||
# Bind address comes from OP25_DEBUG_EXPOSE (config.py) — 127.0.0.1 unless
|
||||
# that flag is set. See config.py for why.
|
||||
terminal_type: Optional[str] = f"http:{bind_host()}:8081"
|
||||
terminal_timeout: Optional[float] = 5.0
|
||||
curses_plot_interval: Optional[float] = 0.2
|
||||
http_plot_interval: Optional[float] = 1.0
|
||||
@@ -127,10 +144,4 @@ class TerminalConfig(BaseModel):
|
||||
|
||||
### ======================================================
|
||||
# Icecast models
|
||||
class IcecastConfig(BaseModel):
|
||||
icecast_host: str
|
||||
icecast_port: int
|
||||
icecast_mountpoint: str
|
||||
icecast_password: str
|
||||
icecast_description: Optional[str] = "OP25"
|
||||
icecast_genre: Optional[str] = "Public Safety"
|
||||
# (IcecastConfig itself is defined above ConfigGenerator, which references it.)
|
||||
Reference in New Issue
Block a user