Fix remote access

This commit is contained in:
BaronGreenback
2021-03-11 21:36:58 +00:00
parent 5592967497
commit 3fdf0de6e3
5 changed files with 79 additions and 31 deletions

View File

@@ -514,5 +514,25 @@ namespace Jellyfin.Networking.Tests
Assert.Equal(intf, result);
}
[Theory]
[InlineData("185.10.10.10,200.200.200.200", "79.2.3.4", false, true)] // whitelist
[InlineData("185.10.10.10", "185.10.10.10", false, false)] // whitelist
[InlineData("185.10.10.10", "79.2.3.4", true, false)] // blacklist
public void TestRemoteAccess(string addresses, string remoteIp, bool blacklist, bool denied)
{
// Comma separated list of IP addresses or IP/netmask entries for networks that will be allowed to connect remotely.
// If left blank, all remote addresses will be allowed.
var conf = new NetworkConfiguration()
{
EnableIPV4 = true,
RemoteIPFilter = addresses.Split(","),
IsRemoteIPFilterBlacklist = blacklist
};
using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
Assert.NotEqual(nm.HasRemoteAccess(IPAddress.Parse(remoteIp)), denied);
}
}
}