diff --git a/backend/konduktor/adapters/remote/config.py b/backend/konduktor/adapters/remote/config.py index aac1e29..489ab2e 100644 --- a/backend/konduktor/adapters/remote/config.py +++ b/backend/konduktor/adapters/remote/config.py @@ -36,10 +36,15 @@ class Remote: username: str = "" def addresses(self) -> list[tuple[str, str]]: - """`(label, base url)`, primary first — the order every connect tries.""" + """`(label, base url)`, primary first — the order every connect tries. + + Each address keeps its OWN port. The fallback once borrowed the + primary's, so a reverse-proxied fallback (`konduktor.example.net`, + served on 443) was tried at `:8765` because the LAN address named it. + """ out = [("primary", _base(self.host, self.port))] if self.fallback_host: - out.append(("fallback", _base(self.fallback_host, self.fallback_port or self.port))) + out.append(("fallback", _base(self.fallback_host, self.fallback_port))) return out def public(self) -> dict: @@ -47,9 +52,11 @@ class Remote: def _base(host: str, port: int | None) -> str: + """An address as typed → a base URL. A full URL (`https://…`, the way to + reach a server behind the user's own reverse proxy) is taken exactly as + given, port and all; anything else is plain HTTP on its port, else 8765.""" host = host.strip() if host.startswith("http://") or host.startswith("https://"): - # A full URL (behind the user's own reverse proxy): taken as given. return host.rstrip("/") bare, inline = split_host(host) if inline is not None: diff --git a/backend/test_remote_protocol.py b/backend/test_remote_protocol.py index baa7ee9..be0dada 100644 --- a/backend/test_remote_protocol.py +++ b/backend/test_remote_protocol.py @@ -121,6 +121,24 @@ back = rp.unpack_analysis(rp.pack_analysis(PreparedAnalysis(measured=measured, k check("…and the detected key", back.key == key, back.key) check("no analysis is None", rp.pack_analysis(None) is None and rp.unpack_analysis(None) is None) +print("== remote addresses ==") +from konduktor.adapters.remote.config import Remote + +r = Remote(id="r", name="NAS", host="192.168.1.20", port=8765, fallback_host="konduktor.example.net") +check("each address is built from its own parts", + r.addresses() == [("primary", "http://192.168.1.20:8765"), ("fallback", "http://konduktor.example.net:8765")], + r.addresses()) +r = Remote(id="r", name="NAS", host="192.168.1.20", port=9000, fallback_host="konduktor.example.net") +check("…so a bare fallback gets the default port, not the primary's 9000", + r.addresses()[1] == ("fallback", "http://konduktor.example.net:8765"), r.addresses()) +r = Remote(id="r", name="NAS", host="192.168.1.20", port=9000, fallback_host="https://konduktor.example.net/") +check("a full URL is used exactly as typed (a reverse proxy's port)", + r.addresses()[1] == ("fallback", "https://konduktor.example.net"), r.addresses()) +r = Remote(id="r", name="NAS", host="http://nas.lan:8080") +check("…a URL with its own port keeps it", r.addresses() == [("primary", "http://nas.lan:8080")]) +check("host:port typed inline is split", Remote(id="r", name="N", host="nas.local:9001").addresses()[0][1] + == "http://nas.local:9001") + print("== versions ==") check("same version talks", rp.compatible((1, 0), (1, 0)) is None) check("a newer server minor talks", rp.compatible((1, 0), (1, 3)) is None) diff --git a/frontend/src/components/RemotePicker.tsx b/frontend/src/components/RemotePicker.tsx index e3ba51c..b1d8762 100644 --- a/frontend/src/components/RemotePicker.tsx +++ b/frontend/src/components/RemotePicker.tsx @@ -241,12 +241,12 @@ function RemoteFormView({ {field( 'Address', setHost(e.target.value)} placeholder="192.168.1.20 or nas.local:8765" />, - 'The server’s address on your network. Add :port if it is not 8765.', + 'The server’s address on your network. Add :port if it is not 8765, or enter a full https://… address if it sits behind a reverse proxy.', )} {field( 'Fallback address', - setFallback(e.target.value)} placeholder="Optional — e.g. its Tailscale address" />, - 'Tried when the first one does not answer — away from home, for instance.', + setFallback(e.target.value)} placeholder="Optional — e.g. https://konduktor.example.net" />, + 'Tried when the first one does not answer — away from home, for instance. Same rules: host[:port] for the server itself (8765 if no port), or a full https://… address used exactly as typed.', )} {field('Username', setUsername(e.target.value)} autoComplete="username" />)} {field(