feat(relay): accept a full URL host so relays work behind an HTTPS proxy

Network relay boards (WebSwitch/KMTronic/Dingtian) were always reached at
http://<host>, so a board on the LAN behind a reverse proxy — the common remote
setup where the operator's 80/443 already go to Nginx Proxy Manager — couldn't be
reached from outside. relayBase() now keeps a scheme the operator supplies
(https://relay.example.com, optional sub-path) and only defaults to http:// for a
bare host/host:port. UI hint + test added.
This commit is contained in:
2026-08-06 09:26:16 +02:00
parent 9bfb44925b
commit 62cdabe114
5 changed files with 46 additions and 11 deletions
+16
View File
@@ -172,3 +172,19 @@ func TestDingtianSetRefusalIsAnError(t *testing.T) {
t.Fatal("a refused command answered HTTP 200 and was reported as success")
}
}
func TestRelayBase(t *testing.T) {
cases := map[string]string{
"192.168.1.5": "http://192.168.1.5",
"192.168.1.5:8080": "http://192.168.1.5:8080",
"https://relay.example.com": "https://relay.example.com",
"https://relay.example.com/": "https://relay.example.com",
"http://relay.example.com/sw/": "http://relay.example.com/sw",
" relay.local ": "http://relay.local",
}
for in, want := range cases {
if got := relayBase(in); got != want {
t.Errorf("relayBase(%q) = %q, want %q", in, got, want)
}
}
}