refactor: keep pure logic importable in tests on any OS

- netinfo_helper imports the Linux-only fcntl inside ipv4_of(), so detect()
  can be unit-tested on Windows/macOS
- SUPPORTED_API_VERSIONS moves to src/native/apiVersion.js (no Vite-only
  imports), so rediscovery.js runs under plain Node

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-28 23:33:16 +03:00
co-authored by Claude Opus 5.5
parent d80f53a31e
commit ffca0ace43
4 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -21,7 +21,6 @@ reports no IP instead of a wrong one.
Standalone on purpose: standard library only, no app imports, no database.
Run: python -m services.netinfo_helper
"""
import fcntl
import json
import os
import platform
@@ -37,6 +36,7 @@ SIOCGIFADDR = 0x8915
def ipv4_of(ifname: str) -> str | None:
"""Primary IPv4 address of an interface, or None if it has none."""
import fcntl # Linux-only; imported here so detect() stays testable anywhere
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
try:
packed = fcntl.ioctl(s.fileno(), SIOCGIFADDR, struct.pack("256s", ifname[:15].encode()))