webcam: fix default host fallback

Fallback to the loopback if unable to determine the
local ip address.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-08-08 16:55:59 -04:00
parent 0188b81d4a
commit 6e253b0d42
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 2 additions and 3 deletions

View File

@ -63,10 +63,9 @@ class WebcamManager:
machine: Machine = self.server.lookup_component("machine")
pubnet = await machine.get_public_network()
ip: Optional[str] = pubnet.get("address")
default_host = f"http://{pubnet['hostname']}"
if ip is not None:
if ip:
default_host = f"http://{ip}"
WebCam.set_default_host(default_host)
WebCam.set_default_host(default_host)
db: MoonrakerDatabase = self.server.lookup_component("database")
saved_cams: Dict[str, Any] = await db.get_item("webcams", default={})
for cam_data in saved_cams.values():