Skip to content

Commit

Permalink
Check for valid IP for known proxies.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Feb 22, 2024
1 parent 646412b commit 190aaa3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions Server/Components/Pages/ServerConfig.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Remotely.Server.Services;
using Remotely.Shared.Entities;
using Remotely.Shared.Interfaces;
using System.Net;
using System.Text.Json;

namespace Remotely.Server.Components.Pages;
Expand Down Expand Up @@ -105,12 +106,15 @@ private void AddBannedDevice()

private void AddKnownProxy()
{
if (string.IsNullOrWhiteSpace(_knownProxyToAdd))
if (IPAddress.TryParse(_knownProxyToAdd, out _))
{
return;
Input.KnownProxies.Add(_knownProxyToAdd);
}
else
{
ToastService.ShowToast2("Invalid IP address.", Enums.ToastType.Warning);
}

Input.KnownProxies.Add(_knownProxyToAdd);
_knownProxyToAdd = string.Empty;
}

Expand Down
5 changes: 4 additions & 1 deletion Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@
{
foreach (var proxy in knownProxies)
{
options.KnownProxies.Add(IPAddress.Parse(proxy));
if (IPAddress.TryParse(proxy, out var ip))
{
options.KnownProxies.Add(ip);
}
}
}
});
Expand Down

0 comments on commit 190aaa3

Please sign in to comment.