// // Licensed under the MIT License. See LICENSE file in the project root for full license information. // namespace MUnique.OpenMU.Web.AdminPanel.Components.ConnectServer; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using MUnique.OpenMU.DataModel.Configuration; using MUnique.OpenMU.Persistence; /// /// A view item for the . /// public class ConnectServerConfigurationViewItem { /// /// Initializes a new instance of the class. /// /// The configuration. public ConnectServerConfigurationViewItem(ConnectServerDefinition config) { this.Configuration = config; } /// /// Gets the internal id of the configuration. /// [Browsable(false)] public Guid Id => this.Configuration.GetId(); /// /// Gets the underlying configuration object. /// [Browsable(false)] public ConnectServerDefinition Configuration { get; } /// /// Gets or sets the description of the server. /// /// /// Will be displayed in the server list in the admin panel as . /// [Required] public string Description { get => this.Configuration.Description; set => this.Configuration.Description = value; } /// /// Gets or sets the game client definition. /// [Required] public GameClientDefinition? GameClientDefinition { get => this.Configuration.Client; set => this.Configuration.Client = value; } /// /// Gets or sets a value indicating whether the client should get disconnected when a unknown packet is getting received. /// public bool DisconnectOnUnknownPacket { get => this.Configuration.DisconnectOnUnknownPacket; set => this.Configuration.DisconnectOnUnknownPacket = value; } /// /// Gets or sets the maximum size of the packets which should be received from the client. If this size is exceeded, the client will be disconnected. /// /// /// DOS protection. /// [Range(3, 255)] public int MaximumReceiveSize { get => this.Configuration.MaximumReceiveSize; set => this.Configuration.MaximumReceiveSize = (byte)value; } /// /// Gets or sets the network port on which the server is listening. /// [Range(1, 65535)] public int ClientListenerPort { get => this.Configuration.ClientListenerPort; set => this.Configuration.ClientListenerPort = (ushort)value; } /// /// Gets or sets the patch address. /// public string PatchAddress { get => this.Configuration.PatchAddress; set => this.Configuration.PatchAddress = value; } /// /// Gets or sets the maximum connections per ip. /// [Range(1, int.MaxValue)] public int MaxConnectionsPerAddress { get => this.Configuration.MaxConnectionsPerAddress; set => this.Configuration.MaxConnectionsPerAddress = value; } /// /// Gets or sets a value indicating whether the should be checked. /// public bool CheckMaxConnectionsPerAddress { get => this.Configuration.CheckMaxConnectionsPerAddress; set => this.Configuration.CheckMaxConnectionsPerAddress = value; } /// /// Gets or sets the maximum connections the connect server should handle. /// [Range(1, int.MaxValue)] public int MaxConnections { get => this.Configuration.MaxConnections; set => this.Configuration.MaxConnections = value; } /// /// Gets or sets the listener backlog for the client listener. /// [Range(1, int.MaxValue)] public int ListenerBacklog { get => this.Configuration.ListenerBacklog; set => this.Configuration.ListenerBacklog = value; } /// /// Gets or sets the maximum FTP requests per connection. /// [Range(1, int.MaxValue)] public int MaxFtpRequests { get => this.Configuration.MaxFtpRequests; set => this.Configuration.MaxFtpRequests = value; } /// /// Gets or sets the maximum ip requests per connection. /// [Range(1, int.MaxValue)] public int MaxIpRequests { get => this.Configuration.MaxIpRequests; set => this.Configuration.MaxIpRequests = value; } /// /// Gets or sets the maximum server list requests per connection. /// [Range(1, int.MaxValue)] public int MaxServerListRequests { get => this.Configuration.MaxServerListRequests; set => this.Configuration.MaxServerListRequests = value; } /// /// Gets or sets the timeout in seconds. /// [Range(10, 3600)] public int TimeoutSeconds { get => (int)this.Configuration.Timeout.TotalSeconds; set => this.Configuration.Timeout = new TimeSpan(value * TimeSpan.TicksPerSecond); } /// /// Gets or sets the current version major. /// [Range(0, 255)] public int CurrentVersionMajor { get => this.Configuration.CurrentPatchVersion?[0] ?? 0; set => (this.Configuration.CurrentPatchVersion ??= new byte[3])[0] = (byte)value; } /// /// Gets or sets the current version minor. /// [Range(0, 255)] public int CurrentVersionMinor { get => this.Configuration.CurrentPatchVersion?[1] ?? 0; set => (this.Configuration.CurrentPatchVersion ??= new byte[3])[1] = (byte)value; } /// /// Gets or sets the current version patch. /// [Range(0, 255)] public int CurrentVersionPatch { get => this.Configuration.CurrentPatchVersion?[2] ?? 0; set => (this.Configuration.CurrentPatchVersion ??= new byte[3])[2] = (byte)value; } }