From e63f9dbcb3b0919ea45f4599e6b997045d7ddf60 Mon Sep 17 00:00:00 2001 From: Gene Date: Wed, 30 Aug 2023 11:51:47 +0200 Subject: [PATCH] v1.4.0-beta.43 - Fixes wrong IP address (127.0.x.x) reported on local UPnP service info --- src/HomeGenie/Service/HomeGenieService.cs | 25 ++++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/HomeGenie/Service/HomeGenieService.cs b/src/HomeGenie/Service/HomeGenieService.cs index 3daba2f3..e6c83a8d 100644 --- a/src/HomeGenie/Service/HomeGenieService.cs +++ b/src/HomeGenie/Service/HomeGenieService.cs @@ -1466,7 +1466,7 @@ private void SetupUpnp() host = Dns.GetHostEntry(Dns.GetHostName()); foreach (var ip in host.AddressList) { - if (ip.AddressFamily == AddressFamily.InterNetwork) + if (ip.AddressFamily == AddressFamily.InterNetwork && !ip.ToString().StartsWith("127.") && !ip.ToString().StartsWith("::1")) { localIP = ip.ToString(); break; @@ -1481,18 +1481,23 @@ private void SetupUpnp() } // string presentationUrl = "http://" + address + ":" + bindport; - //string friendlyName = "HomeGenie: " + Environment.MachineName; string manufacturer = "G-Labs"; - string manufacturerUrl = "http://genielabs.github.io/HomeGenie/"; + string manufacturerUrl = "https://github.com/genielabs"; string modelName = "HomeGenie"; - string modelDescription = "HomeGenie Home Automation Server"; - //string modelURL = "https://homegenie.it/"; - string modelNumber = "HG-1"; + string modelDescription = "HomeGenie Automation Server"; + string friendlyName = modelName + ": " + Environment.MachineName; + string modelUrl = "https://homegenie.it/"; + string version = "1"; + if (updateChecker.GetCurrentRelease() != null) + { + version = updateChecker.GetCurrentRelease().Version; + } + string modelNumber = "HG-" + version; string standardDeviceType = "HomeAutomationServer"; string uniqueDeviceName = systemConfiguration.HomeGenie.GUID; if (String.IsNullOrEmpty(uniqueDeviceName)) { - systemConfiguration.HomeGenie.GUID = uniqueDeviceName = System.Guid.NewGuid().ToString(); + systemConfiguration.HomeGenie.GUID = uniqueDeviceName = Guid.NewGuid().ToString(); systemConfiguration.Update(); } // @@ -1503,14 +1508,14 @@ private void SetupUpnp() localDevice.HasPresentation = true; localDevice.PresentationURL = presentationUrl; } - localDevice.FriendlyName = modelName + ": " + Environment.MachineName; + localDevice.FriendlyName = friendlyName; localDevice.Manufacturer = manufacturer; localDevice.ManufacturerURL = manufacturerUrl; localDevice.ModelName = modelName; localDevice.ModelDescription = modelDescription; - if (Uri.IsWellFormedUriString(manufacturerUrl, UriKind.Absolute)) + if (Uri.IsWellFormedUriString(modelUrl, UriKind.Absolute)) { - localDevice.ModelURL = new Uri(manufacturerUrl); + localDevice.ModelURL = new Uri(modelUrl); } localDevice.ModelNumber = modelNumber; localDevice.StandardDeviceType = standardDeviceType;