236 lines
5.8 KiB
C#
236 lines
5.8 KiB
C#
|
|
using System.ComponentModel.DataAnnotations;
|
||
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
||
|
|
|
||
|
|
namespace radiuscontroller.Models;
|
||
|
|
|
||
|
|
[Table("radcheck")]
|
||
|
|
public class RadCheck
|
||
|
|
{
|
||
|
|
[Key]
|
||
|
|
[Column("id")]
|
||
|
|
public int Id { get; set; }
|
||
|
|
|
||
|
|
[Required]
|
||
|
|
[Column("username")]
|
||
|
|
[StringLength(64)]
|
||
|
|
public string Username { get; set; } = string.Empty;
|
||
|
|
|
||
|
|
[Required]
|
||
|
|
[Column("attribute")]
|
||
|
|
[StringLength(64)]
|
||
|
|
public string Attribute { get; set; } = string.Empty;
|
||
|
|
|
||
|
|
[Required]
|
||
|
|
[Column("op")]
|
||
|
|
[StringLength(2)]
|
||
|
|
public string Op { get; set; } = ":=";
|
||
|
|
|
||
|
|
[Required]
|
||
|
|
[Column("value")]
|
||
|
|
[StringLength(253)]
|
||
|
|
public string Value { get; set; } = string.Empty;
|
||
|
|
}
|
||
|
|
|
||
|
|
[Table("radreply")]
|
||
|
|
public class RadReply
|
||
|
|
{
|
||
|
|
[Key]
|
||
|
|
[Column("id")]
|
||
|
|
public int Id { get; set; }
|
||
|
|
|
||
|
|
[Required]
|
||
|
|
[Column("username")]
|
||
|
|
[StringLength(64)]
|
||
|
|
public string Username { get; set; } = string.Empty;
|
||
|
|
|
||
|
|
[Required]
|
||
|
|
[Column("attribute")]
|
||
|
|
[StringLength(64)]
|
||
|
|
public string Attribute { get; set; } = string.Empty;
|
||
|
|
|
||
|
|
[Required]
|
||
|
|
[Column("op")]
|
||
|
|
[StringLength(2)]
|
||
|
|
public string Op { get; set; } = "=";
|
||
|
|
|
||
|
|
[Required]
|
||
|
|
[Column("value")]
|
||
|
|
[StringLength(253)]
|
||
|
|
public string Value { get; set; } = string.Empty;
|
||
|
|
}
|
||
|
|
|
||
|
|
[Table("radacct")]
|
||
|
|
public class RadAcct
|
||
|
|
{
|
||
|
|
[Key]
|
||
|
|
[Column("radacctid")]
|
||
|
|
public long RadAcctId { get; set; }
|
||
|
|
|
||
|
|
[Column("acctsessionid")]
|
||
|
|
public string AcctSessionId { get; set; } = string.Empty;
|
||
|
|
|
||
|
|
[Column("acctuniqueid")]
|
||
|
|
public string AcctUniqueId { get; set; } = string.Empty;
|
||
|
|
|
||
|
|
[Column("username")]
|
||
|
|
public string Username { get; set; } = string.Empty;
|
||
|
|
|
||
|
|
[Column("realm")]
|
||
|
|
public string? Realm { get; set; }
|
||
|
|
|
||
|
|
[Column("nasipaddress")]
|
||
|
|
public string NasIpAddress { get; set; } = string.Empty;
|
||
|
|
|
||
|
|
[Column("nasportid")]
|
||
|
|
public string? NasPortId { get; set; }
|
||
|
|
|
||
|
|
[Column("nasporttype")]
|
||
|
|
public string? NasPortType { get; set; }
|
||
|
|
|
||
|
|
[Column("acctstarttime")]
|
||
|
|
public DateTime? AcctStartTime { get; set; }
|
||
|
|
|
||
|
|
[Column("acctupdatetime")]
|
||
|
|
public DateTime? AcctUpdateTime { get; set; }
|
||
|
|
|
||
|
|
[Column("acctstoptime")]
|
||
|
|
public DateTime? AcctStopTime { get; set; }
|
||
|
|
|
||
|
|
[Column("acctinterval")]
|
||
|
|
public int? AcctInterval { get; set; }
|
||
|
|
|
||
|
|
[Column("acctsessiontime")]
|
||
|
|
public long? AcctSessionTime { get; set; }
|
||
|
|
|
||
|
|
[Column("acctauthentic")]
|
||
|
|
public string? AcctAuthentic { get; set; }
|
||
|
|
|
||
|
|
[Column("connectinfo_in")]
|
||
|
|
public string? ConnectInfoIn { get; set; }
|
||
|
|
|
||
|
|
[Column("connectinfo_out")]
|
||
|
|
public string? ConnectInfoOut { get; set; }
|
||
|
|
|
||
|
|
[Column("acctinputoctets")]
|
||
|
|
public long? AcctInputOctets { get; set; }
|
||
|
|
|
||
|
|
[Column("acctoutputoctets")]
|
||
|
|
public long? AcctOutputOctets { get; set; }
|
||
|
|
|
||
|
|
[Column("calledstationid")]
|
||
|
|
public string? CalledStationId { get; set; }
|
||
|
|
|
||
|
|
[Column("callingstationid")]
|
||
|
|
public string? CallingStationId { get; set; }
|
||
|
|
|
||
|
|
[Column("acctterminatecause")]
|
||
|
|
public string? AcctTerminateCause { get; set; }
|
||
|
|
|
||
|
|
[Column("servicetype")]
|
||
|
|
public string? ServiceType { get; set; }
|
||
|
|
|
||
|
|
[Column("framedprotocol")]
|
||
|
|
public string? FramedProtocol { get; set; }
|
||
|
|
|
||
|
|
[Column("framedipaddress")]
|
||
|
|
public string? FramedIpAddress { get; set; }
|
||
|
|
}
|
||
|
|
|
||
|
|
[Table("guest_profiles")]
|
||
|
|
public class GuestProfile
|
||
|
|
{
|
||
|
|
[Key]
|
||
|
|
[Column("id")]
|
||
|
|
public int Id { get; set; }
|
||
|
|
|
||
|
|
[Required]
|
||
|
|
[Column("guest_name")]
|
||
|
|
public string GuestName { get; set; } = string.Empty;
|
||
|
|
|
||
|
|
[Required]
|
||
|
|
[Column("username")]
|
||
|
|
public string Username { get; set; } = string.Empty;
|
||
|
|
|
||
|
|
[Column("created_at")]
|
||
|
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||
|
|
|
||
|
|
[Column("session_time_minutes")]
|
||
|
|
public int SessionTimeMinutes { get; set; }
|
||
|
|
|
||
|
|
[Column("data_limit_mb")]
|
||
|
|
public long DataLimitMb { get; set; }
|
||
|
|
|
||
|
|
[Column("status")]
|
||
|
|
public string Status { get; set; } = "Active";
|
||
|
|
}
|
||
|
|
|
||
|
|
[Table("admin_users")]
|
||
|
|
public class AdminUser
|
||
|
|
{
|
||
|
|
[Key]
|
||
|
|
[Column("id")]
|
||
|
|
public int Id { get; set; }
|
||
|
|
|
||
|
|
[Required]
|
||
|
|
[Column("username")]
|
||
|
|
public string Username { get; set; } = string.Empty;
|
||
|
|
|
||
|
|
[Required]
|
||
|
|
[Column("password_hash")]
|
||
|
|
public string PasswordHash { get; set; } = string.Empty;
|
||
|
|
|
||
|
|
[Column("created_at")]
|
||
|
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||
|
|
}
|
||
|
|
|
||
|
|
[Table("system_settings")]
|
||
|
|
public class SystemSetting
|
||
|
|
{
|
||
|
|
[Key]
|
||
|
|
[Column("key")]
|
||
|
|
public string Key { get; set; } = string.Empty;
|
||
|
|
|
||
|
|
[Required]
|
||
|
|
[Column("value")]
|
||
|
|
public string Value { get; set; } = string.Empty;
|
||
|
|
|
||
|
|
[Column("updated_at")]
|
||
|
|
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||
|
|
}
|
||
|
|
|
||
|
|
// DTOs
|
||
|
|
public class UserUsageDto
|
||
|
|
{
|
||
|
|
public int ProfileId { get; set; }
|
||
|
|
public string GuestName { get; set; } = string.Empty;
|
||
|
|
public string Username { get; set; } = string.Empty;
|
||
|
|
public string Password { get; set; } = string.Empty;
|
||
|
|
public DateTime CreatedAt { get; set; }
|
||
|
|
public int SessionTimeMinutes { get; set; }
|
||
|
|
public long DataLimitMb { get; set; }
|
||
|
|
public string Status { get; set; } = "Active";
|
||
|
|
|
||
|
|
public long TotalInputOctets { get; set; } // Upload
|
||
|
|
public long TotalOutputOctets { get; set; } // Download
|
||
|
|
public long TotalOctets => TotalInputOctets + TotalOutputOctets;
|
||
|
|
public double UsedDataMb => Math.Round((double)TotalOctets / (1024 * 1024), 2);
|
||
|
|
public long TotalSessionTimeSeconds { get; set; }
|
||
|
|
public bool IsCurrentlyConnected { get; set; }
|
||
|
|
}
|
||
|
|
|
||
|
|
public class RegistrationResultDto
|
||
|
|
{
|
||
|
|
public string GuestName { get; set; } = string.Empty;
|
||
|
|
public string Username { get; set; } = string.Empty;
|
||
|
|
public string Password { get; set; } = string.Empty;
|
||
|
|
public int SessionTimeMinutes { get; set; }
|
||
|
|
public long DataLimitMb { get; set; }
|
||
|
|
public DateTime ExpirationEstimate { get; set; }
|
||
|
|
}
|
||
|
|
|
||
|
|
public class SystemConfigDto
|
||
|
|
{
|
||
|
|
public int DefaultSessionTimeMinutes { get; set; } = 60;
|
||
|
|
public long DefaultDataLimitMb { get; set; } = 500;
|
||
|
|
}
|