mirror of
https://github.com/modernuo/ModernUO
synced 2026-08-11 22:23:06 -04:00
### Summary - Fixes `[AdvancedSearch` being accessible by players 😱 - Adds `[GenCommands` to generate the same commands html page on https://muo.gg/commands. - Fixes `[helpinfo` so all commands properly show up! > [!WARNING] > ### Developer Warning: > Commands must now be registered in the `Configure` bootup phase. > If a command is not registered early enough, it may not be available to systems like [helpinfo > that cache their information. > [!NOTE] > ### Developer Note: > Various commands related to generating content have been changed to _Developer_ and above access level. ### Screenshots <img width="673" alt="image" src="https://github.com/modernuo/ModernUO/assets/3953314/b105b5c9-5eb4-4ace-93ff-1bfb31e7132f"> <img width="547" alt="image" src="https://github.com/modernuo/ModernUO/assets/3953314/e97487e8-47a5-4aa7-89cc-9fe3deda584d">
52 lines
2.2 KiB
C#
52 lines
2.2 KiB
C#
using System;
|
|
using System.Net;
|
|
using Xunit;
|
|
|
|
namespace Server.Tests
|
|
{
|
|
public class IPAddressTests
|
|
{
|
|
[Theory]
|
|
[InlineData("192.168.100.254", "192.168.100.1", 16, true)]
|
|
[InlineData("192.168.100.254", "192.168.50.1", 24, false)]
|
|
[InlineData("192.168.100.1", "192.168.50.1", 32, false)]
|
|
[InlineData("192.168.50.1", "192.168.50.1", 32, true)]
|
|
[InlineData("192.168.50.4", "192.168.50.7", 30, true)]
|
|
[InlineData("192.168.50.4", "192.168.50.9", 30, false)]
|
|
[InlineData("::ffff:192.168.100.254", "192.168.100.1", 112, true)]
|
|
[InlineData("::ffff:192.168.100.254", "192.168.50.1", 104, true)]
|
|
[InlineData("::ffff:192.168.100.254", "192.168.50.1", 120, false)]
|
|
[InlineData("1234:5678:9ABC:1234:5678:9ABC:1234:5678", "1234:5677:0:0:0:0:0:0", 16, true)]
|
|
[InlineData("1234:5678:9ABC:1234:5678:9ABC:1234:5678", "1234:5677:0:0:0:0:0:0", 64, false)]
|
|
[InlineData("::1234:5678", "1234:5677::", 64, false)]
|
|
[InlineData("::1234:5678", "::9ABC:5677", 112, false)]
|
|
[InlineData("::1234:5678", "::1234:66AA", 112, true)]
|
|
[InlineData("::1234:5678", "::1235:FFFF", 109, true)]
|
|
[InlineData("::1234:5678", "::1238:ABAC", 109, false)]
|
|
public void TestIPvCIDR(string cidr, string addr, int cidrLength, bool shouldMatch)
|
|
{
|
|
var cidrAddress = IPAddress.Parse(cidr);
|
|
var address = IPAddress.Parse(addr);
|
|
|
|
Assert.Equal(shouldMatch, cidrAddress.MatchCidr(cidrLength, address));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("::ffff:192.168.1.1", 0UL, 0xffffc0a80101UL)]
|
|
[InlineData("192.168.1.1", 0UL, 0xffffc0a80101UL)]
|
|
[InlineData("4cce:1490:4577:d72f:693e:b42e:3465:f3db", 0x4cce14904577d72fUL, 0x693eb42e3465f3db)]
|
|
public void TestIPAddressToUInt128(string ipString, ulong upper, ulong lower)
|
|
{
|
|
var ip = IPAddress.Parse(ipString);
|
|
if (ip.IsIPv4MappedToIPv6)
|
|
{
|
|
ip = ip.MapToIPv4();
|
|
}
|
|
|
|
var actual = ip.ToUInt128();
|
|
Assert.Equal(new UInt128(upper, lower), actual);
|
|
var actual2 = actual.ToIpAddress();
|
|
Assert.Equal(ip, actual2);
|
|
}
|
|
}
|
|
}
|