diff --git a/CHANGELOG.md b/CHANGELOG.md index 05b705f..c34f9cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,19 @@ every change carries a descriptive commit message. ## [Unreleased] +## [3.38.2] — 2026-10-25 + +### Fixed + +- **The start scripts name the address they were asked to bind.** The opening + `Starting pysim-simple-server on http://127.0.0.1:8080` line was hardcoded + while `--http-host`/`--http-port` were passed through to the server: + `./start.sh --http-host 10.0.28.161` bound correctly (the server's own + `listening on` banner named the address), but the first line still said + 127.0.0.1. `start.sh` and `start.bat` now parse both flags (space and `=` + forms, the last value wins like argparse) and echo the effective address; + the defaults are unchanged. + ## [3.38.1] — 2026-10-25 ### Performance diff --git a/frontend/index.html b/frontend/index.html index 2988b8f..c718c26 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -1959,7 +1959,7 @@ // ===== Version ===== // Single source of truth for the PWA version: shown in the header and used // by the server version check in pysimConnect(). -const SIMPLE_VERSION = '3.38.1'; +const SIMPLE_VERSION = '3.38.2'; document.getElementById('app-version').textContent = 'v' + SIMPLE_VERSION; // ===== view history (the browser Back/Forward buttons) ===== diff --git a/frontend/sw.js b/frontend/sw.js index c087251..8a31e62 100644 --- a/frontend/sw.js +++ b/frontend/sw.js @@ -1,4 +1,4 @@ -const CACHE = 'simple-v482'; +const CACHE = 'simple-v483'; const URLS = [ 'index.html', 'help.html', diff --git a/pyproject.toml b/pyproject.toml index 47c87cd..a80ed8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pysim-simple-server" -version = "3.38.1" +version = "3.38.2" description = "HTTP REST server wrapping pysim for the SIMple PWA" license = { text = "GPL-2.0-or-later" } requires-python = ">=3.9" diff --git a/pysim_simple_server/server.py b/pysim_simple_server/server.py index 51bbf7b..c2e6681 100644 --- a/pysim_simple_server/server.py +++ b/pysim_simple_server/server.py @@ -37,7 +37,7 @@ from osmocom.tlv import BER_TLV_IE from osmocom.utils import rpad -VERSION = '3.38.1' +VERSION = '3.38.2' MAX_ENVELOPE_SEGMENTS = 5 # max SMS segments for outgoing C-APDU in ENVELOPE diff --git a/start.bat b/start.bat index a493471..e324262 100644 --- a/start.bat +++ b/start.bat @@ -12,15 +12,41 @@ set VENV_DIR=%~dp0.venv set LOG=%~dp0simple_lastrun.log set PYTHONUNBUFFERED=1 +REM The address the opening line names (v3.38.2). The server parses the same +REM flags; this mirrors its last-one-wins rule for the echo. %* is not +REM affected by SHIFT, so the server still receives every argument. +set "HTTP_HOST=127.0.0.1" +set "HTTP_PORT=8080" +:parse_http_args +if "%~1"=="" goto http_args_done +if /i "%~1"=="--http-host" ( + set "HTTP_HOST=%~2" + shift + shift + goto parse_http_args +) +if /i "%~1"=="--http-port" ( + set "HTTP_PORT=%~2" + shift + shift + goto parse_http_args +) +set "ARG=%~1" +if /i "%ARG:~0,12%"=="--http-host=" set "HTTP_HOST=%ARG:~12%" +if /i "%ARG:~0,12%"=="--http-port=" set "HTTP_PORT=%ARG:~12%" +shift +goto parse_http_args +:http_args_done + if exist "%VENV_DIR%\Scripts\pysim-simple-server.exe" ( - echo Starting pysim-simple-server from venv on http://127.0.0.1:8080 + echo Starting pysim-simple-server from venv on http://%HTTP_HOST%:%HTTP_PORT% echo Log: simple_lastrun.log (overwritten on each start^). Press Ctrl+C to stop. "%VENV_DIR%\Scripts\pysim-simple-server.exe" --http-port 8080 -p 0 %* 2>&1 | powershell -NoProfile -Command "$input | Tee-Object -FilePath '%LOG%'" goto :eof ) if exist "%~dp0pysim_simple_server\__main__.py" ( - echo Starting pysim-simple-server from source on http://127.0.0.1:8080 + echo Starting pysim-simple-server from source on http://%HTTP_HOST%:%HTTP_PORT% echo Log: simple_lastrun.log (overwritten on each start^). Press Ctrl+C to stop. python -m pysim_simple_server --http-port 8080 -p 0 %* 2>&1 | powershell -NoProfile -Command "$input | Tee-Object -FilePath '%LOG%'" goto :eof @@ -28,7 +54,7 @@ if exist "%~dp0pysim_simple_server\__main__.py" ( where pysim-simple-server >nul 2>&1 if %errorlevel% equ 0 ( - echo Starting pysim-simple-server on http://127.0.0.1:8080 + echo Starting pysim-simple-server on http://%HTTP_HOST%:%HTTP_PORT% echo Log: simple_lastrun.log (overwritten on each start^). Press Ctrl+C to stop. pysim-simple-server --http-port 8080 -p 0 %* 2>&1 | powershell -NoProfile -Command "$input | Tee-Object -FilePath '%LOG%'" goto :eof diff --git a/start.sh b/start.sh index 7ff403b..d418350 100755 --- a/start.sh +++ b/start.sh @@ -10,6 +10,24 @@ set -e SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" VENV_DIR="$SCRIPT_DIR/.venv" +# The address the opening line names (v3.38.2). The server parses the same +# flags; start.sh passes its own --http-port 8080 before "$@", so a later user +# value wins (argparse keeps the last one) - mirror that here. +HTTP_HOST=127.0.0.1 +HTTP_PORT=8080 +PREV_ARG="" +for arg in "$@"; do + case "$PREV_ARG" in + --http-host) HTTP_HOST="$arg" ;; + --http-port) HTTP_PORT="$arg" ;; + esac + case "$arg" in + --http-host=*) HTTP_HOST="${arg#*=}" ;; + --http-port=*) HTTP_PORT="${arg#*=}" ;; + esac + PREV_ARG="$arg" +done + # Console + log file. The log contains card keys and request payloads (test # cards) - it is gitignored and must not be committed. LOG_FILE="$SCRIPT_DIR/simple_lastrun.log" @@ -73,7 +91,7 @@ if [ -f "$VENV_DIR/bin/pysim-simple-server" ]; then elif command -v pysim-simple-server &> /dev/null; then SERVER="pysim-simple-server" elif [ -f "$SCRIPT_DIR/pysim_simple_server/__main__.py" ]; then - echo "Starting pysim-simple-server from source on http://127.0.0.1:8080" + echo "Starting pysim-simple-server from source on http://$HTTP_HOST:$HTTP_PORT" echo "Log: simple_lastrun.log (overwritten on each start)." cd "$SCRIPT_DIR" && python3 -m pysim_simple_server --http-port 8080 $READER_ARGS "$@" exit $? @@ -84,7 +102,7 @@ else exit 1 fi -echo "Starting pysim-simple-server on http://127.0.0.1:8080" +echo "Starting pysim-simple-server on http://$HTTP_HOST:$HTTP_PORT" echo "Log: simple_lastrun.log (overwritten on each start)." echo "Press Ctrl+C to stop." echo "Extra arguments are passed to the server (e.g. ./start.sh --gsmtap)." diff --git a/tests/test_pcsc_startup.py b/tests/test_pcsc_startup.py index 74f914b..dfe17d5 100644 --- a/tests/test_pcsc_startup.py +++ b/tests/test_pcsc_startup.py @@ -150,6 +150,21 @@ class SourcePins(unittest.TestCase): # the old "is pcscd running" heuristic is gone self.assertNotIn('pgrep -x pcscd', src) + def test_the_start_message_names_the_requested_address(self): + src = (Path(m.__file__).parent.parent / 'start.sh').read_text() + self.assertIn('--http-host=*) HTTP_HOST="${arg#*=}"', src) + self.assertIn('--http-port=*) HTTP_PORT="${arg#*=}"', src) + self.assertIn('http://$HTTP_HOST:$HTTP_PORT', src) + # the old hardcoded address is gone (the defaults are named separately) + self.assertNotIn('http://127.0.0.1:8080', src) + + def test_the_start_bat_message_names_the_requested_address(self): + src = (Path(m.__file__).parent.parent / 'start.bat').read_text() + self.assertIn('--http-host=', src) + self.assertIn('--http-port=', src) + self.assertIn('%HTTP_HOST%:%HTTP_PORT%', src) + self.assertNotIn('http://127.0.0.1:8080', src) + if __name__ == '__main__': unittest.main()