Test cleanup

This commit is contained in:
femsci 2023-10-19 18:25:22 +02:00
parent 359c370b49
commit 6c5e9b8716
Signed by: femsci
GPG key ID: 08F7911F0E650C67
3 changed files with 20 additions and 19 deletions

View file

@ -8,8 +8,7 @@ public class Host : IBindable
{ {
[Key] [Key]
public required string Id { get; set; } public required string Id { get; set; }
[MaxLength(16)] public Int128 Duid { get; set; }
public byte[] Duid { get; set; } = default!;
public HostType HostType { get; set; } public HostType HostType { get; set; }
public required IPAddressCollection Addresses { get; set; } public required IPAddressCollection Addresses { get; set; }
public required MacAddress Mac { get; set; } public required MacAddress Mac { get; set; }

View file

@ -2,11 +2,20 @@ using System.ComponentModel.DataAnnotations;
namespace IPMeow.Lib.Host; namespace IPMeow.Lib.Host;
public enum HostInterfaceType
{
Ethernet,
Infiniband,
Wireless,
Virtual
}
public class HostInterface public class HostInterface
{ {
[Key] [Key]
public required string Id { get; set; } public required string Id { get; set; }
public byte[] IAID { get; set; } = default!; public byte[] IAID { get; set; } = default!;
public HostInterfaceType InterfaceType { get; set; }
public DateTime LastPinged { get; set; } public DateTime LastPinged { get; set; }
public DateTime LastAssignment { get; set; } public DateTime LastAssignment { get; set; }

View file

@ -13,6 +13,9 @@ public class DnsTest
[Fact] [Fact]
public async Task TestDns() public async Task TestDns()
{ {
using UdpClient udp = new UdpClient(AddressFamily.InterNetwork);
udp.Connect(IPAddress.Parse("1.1.1.1"), 53);
DnsMessage msg = new() DnsMessage msg = new()
{ {
IsRecursionDesired = true, IsRecursionDesired = true,
@ -32,24 +35,14 @@ public class DnsTest
ResponseCode = 0, ResponseCode = 0,
}; };
await Send(msg);
Console.WriteLine("sendt");
msg.IsRecursionDesired = false;
msg.IsAuthoritative = false;
msg.MessageType = DnsMessageType.Reply;
msg.Opcode = DnsMessageOpcode.Status;
msg.ResponseCode = DnsResponseCode.NxDomain;
await Send(msg);
}
private async Task Send(DnsMessage msg)
{
var data = msg.Serialize(); var data = msg.Serialize();
using UdpClient udp = new UdpClient(AddressFamily.InterNetwork);
udp.Connect(IPAddress.Parse("1.1.1.1"), 53);
await udp.SendAsync(data); await udp.SendAsync(data);
var rec = await udp.ReceiveAsync();
var res = DnsMessage.Deserialize(rec.Buffer);
Assert.Equal(DnsMessageType.Reply, res.MessageType);
Assert.Equal(0xbabe, res.MessageId);
} }
} }