progress
This commit is contained in:
parent
1109fed17e
commit
2e2d21bea7
8 changed files with 93 additions and 22 deletions
|
@ -9,6 +9,6 @@ namespace IPMeow.Lib.Server;
|
|||
public class DnsServer : IRoutedServer
|
||||
{
|
||||
public required IPAddress Address { get; set; }
|
||||
public required ICollection<Protocol> Protocols { get; set; }
|
||||
public required ICollection<Endpoint> Protocols { get; set; }
|
||||
public bool SupportsTls { get; set; }
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@ namespace IPMeow.Lib.Server;
|
|||
public interface IRoutedServer
|
||||
{
|
||||
public IPAddress Address { get; set; }
|
||||
public ICollection<Protocol> Protocols { get; set; }
|
||||
public ICollection<Endpoint> Protocols { get; set; }
|
||||
}
|
||||
|
|
|
@ -5,8 +5,9 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace IPMeow.Lib.Server;
|
||||
|
||||
public struct Protocol
|
||||
public struct Endpoint
|
||||
{
|
||||
public short Port { get; set; }
|
||||
public short? Port { get; set; }
|
||||
public string Protocol { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace IPMeow.Lib.Server;
|
|||
|
||||
public static class Protocols
|
||||
{
|
||||
private static readonly HashSet<Protocol> _protos = new()
|
||||
private static readonly HashSet<Endpoint> _protos = new()
|
||||
{
|
||||
Http,
|
||||
Dns,
|
||||
|
@ -24,26 +24,26 @@ public static class Protocols
|
|||
Imap
|
||||
};
|
||||
|
||||
public static readonly Protocol Http = new() { Name = "HTTP", Port = 80 };
|
||||
public static readonly Protocol Dns = new() { Name = "DNS", Port = 53 };
|
||||
public static readonly Protocol DnsOverTls = new() { Name = "DNS-over-TLS", Port = 853 };
|
||||
public static readonly Protocol DnsOverHttps = new() { Name = "DNS-over-HTTPS", Port = 443 };
|
||||
public static readonly Protocol Ntp = new() { Name = "NTP", Port = 123 };
|
||||
public static readonly Protocol Ssh = new() { Name = "SSH", Port = 22 };
|
||||
public static readonly Protocol Snmp = new() { Name = "SNMP", Port = 161 };
|
||||
public static readonly Protocol Ldap = new() { Name = "LDAP", Port = 389 };
|
||||
public static readonly Protocol Kerberos = new() { Name = "Kerberos", Port = 88 };
|
||||
public static readonly Protocol Radius = new() { Name = "RADIUS", Port = 1812 };
|
||||
public static readonly Protocol Smtp = new() { Name = "SMTP", Port = 25 };
|
||||
public static readonly Protocol Pop3 = new() { Name = "POP3", Port = 110 };
|
||||
public static readonly Protocol Imap = new() { Name = "IMAP", Port = 143 };
|
||||
public static readonly Endpoint Http = new() { Name = "HTTP", Port = 80 };
|
||||
public static readonly Endpoint Dns = new() { Name = "DNS", Port = 53 };
|
||||
public static readonly Endpoint DnsOverTls = new() { Name = "DNS-over-TLS", Port = 853 };
|
||||
public static readonly Endpoint DnsOverHttps = new() { Name = "DNS-over-HTTPS", Port = 443 };
|
||||
public static readonly Endpoint Ntp = new() { Name = "NTP", Port = 123 };
|
||||
public static readonly Endpoint Ssh = new() { Name = "SSH", Port = 22 };
|
||||
public static readonly Endpoint Snmp = new() { Name = "SNMP", Port = 161 };
|
||||
public static readonly Endpoint Ldap = new() { Name = "LDAP", Port = 389 };
|
||||
public static readonly Endpoint Kerberos = new() { Name = "Kerberos", Port = 88 };
|
||||
public static readonly Endpoint Radius = new() { Name = "RADIUS", Port = 1812 };
|
||||
public static readonly Endpoint Smtp = new() { Name = "SMTP", Port = 25 };
|
||||
public static readonly Endpoint Pop3 = new() { Name = "POP3", Port = 110 };
|
||||
public static readonly Endpoint Imap = new() { Name = "IMAP", Port = 143 };
|
||||
|
||||
public static Protocol? GetByPort(short port)
|
||||
public static Endpoint? GetByPort(short port)
|
||||
{
|
||||
return _protos.SingleOrDefault(s => s.Port == port);
|
||||
}
|
||||
|
||||
public static Protocol? GetByName(string name)
|
||||
public static Endpoint? GetByName(string name)
|
||||
{
|
||||
return _protos.SingleOrDefault(s => s.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
|
|
@ -8,6 +8,6 @@ public class Network
|
|||
{
|
||||
[Key]
|
||||
public required string Name { get; set; }
|
||||
public virtual ICollection<DnsServer> DnsServers { get; set; }
|
||||
public virtual ICollection<Prefix> Networks { get; set; }
|
||||
public virtual ICollection<IRoutedServer> ServiceServers { get; set; } = default!;
|
||||
public virtual ICollection<Prefix> Networks { get; set; } = default!;
|
||||
}
|
||||
|
|
30
src/IPMeow.Server/Address/AddressManager.cs
Normal file
30
src/IPMeow.Server/Address/AddressManager.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using IPMeow.Lib.Address;
|
||||
using IPMeow.Lib.Site;
|
||||
|
||||
namespace IPMeow.Server.Address;
|
||||
|
||||
public class AddressManager
|
||||
{
|
||||
private readonly Dictionary<MacAddress, (IPAddress, DateTime)> _dynAssignments = new();
|
||||
|
||||
public IPv6Address AssignRandomV6(MacAddress addr, Network n)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
IPv6Address ip = new(IPAddress.None);
|
||||
_dynAssignments.Add(addr, (ip, DateTime.UtcNow));
|
||||
}
|
||||
|
||||
public IPv4Address AssignRandomV4(MacAddress addr, Network n)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
IPv4Address ip = new(IPAddress.None);
|
||||
_dynAssignments.Add(addr, (ip, DateTime.UtcNow));
|
||||
}
|
||||
}
|
38
src/IPMeow.Server/Controllers/NetworkController.cs
Normal file
38
src/IPMeow.Server/Controllers/NetworkController.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using IPMeow.Lib.Request;
|
||||
using IPMeow.Lib.Site;
|
||||
using IPMeow.Server.Data;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace IPMeow.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/network/v6")]
|
||||
public class V6NetworkController : ControllerBase
|
||||
{
|
||||
public V6NetworkController(IpamContext data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
private readonly IpamContext _data;
|
||||
|
||||
[HttpGet("settings/{name}")]
|
||||
public async Task<Network?> GetSettings(string name)
|
||||
{
|
||||
return await _data.Networks.AsNoTracking().SingleOrDefaultAsync(x => x.Name == name);
|
||||
}
|
||||
}
|
||||
|
||||
[ApiController]
|
||||
[Route("api/network/v4")]
|
||||
public class V4NetworkController : ControllerBase
|
||||
{
|
||||
public V4NetworkController(IpamContext data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
private readonly IpamContext _data;
|
||||
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using IPMeow.Lib.Host;
|
||||
using IPMeow.Lib.Site;
|
||||
using IPMeow.Server.Data.Model;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
@ -9,6 +10,7 @@ public class IpamContext : DbContext
|
|||
public DbSet<Lib.Host.Host> Hosts => Set<Lib.Host.Host>();
|
||||
public DbSet<HostInterface> HostInterfaces => Set<HostInterface>();
|
||||
public DbSet<AddressAssignment> Assignments => Set<AddressAssignment>();
|
||||
public DbSet<Network> Networks => Set<Network>();
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder opt)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue