Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for valid IP for known proxies. #815

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading