mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-13 20:47:04 +00:00
refactor: use tryParse for IP Address parsing
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
9d313d8c7c
commit
e59c50d0aa
1 changed files with 9 additions and 1 deletions
|
|
@ -319,7 +319,15 @@ namespace PepperDash.Essentials.WebSocketServer
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ip = touchpanel.Touchpanel.ConnectedIps.Any(ipInfo => csIpAddress.IsInSameSubnet(System.Net.IPAddress.Parse(ipInfo.DeviceIpAddress), csSubnetMask)) ? csIpAddress.ToString() : processorIp;
|
var ip = touchpanel.Touchpanel.ConnectedIps.Any(ipInfo =>
|
||||||
|
{
|
||||||
|
if (System.Net.IPAddress.TryParse(ipInfo.DeviceIpAddress, out var parsedIp))
|
||||||
|
{
|
||||||
|
return csIpAddress.IsInSameSubnet(parsedIp, csSubnetMask);
|
||||||
|
}
|
||||||
|
this.LogWarning("Invalid IP address: {deviceIpAddress}", ipInfo.DeviceIpAddress);
|
||||||
|
return false;
|
||||||
|
}) ? csIpAddress.ToString() : processorIp;
|
||||||
|
|
||||||
var appUrl = $"http://{ip}:{_parent.Config.DirectServer.Port}/mc/app?token={touchpanel.Key}";
|
var appUrl = $"http://{ip}:{_parent.Config.DirectServer.Port}/mc/app?token={touchpanel.Key}";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue