Merge pull request #827 from Rhefew/feature/ip-connection-limit
feat(plugins): implement customizable maximum concurrent connections (cherry picked from commit 0e30df9ae22a265c3486dea1eba259567631eb87)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// <copyright file="RemotePlayer.cs" company="MUnique">
|
||||
// <copyright file="RemotePlayer.cs" company="MUnique">
|
||||
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
|
||||
@@ -16,12 +16,14 @@ using MUnique.OpenMU.PlugIns;
|
||||
/// <summary>
|
||||
/// A player which is playing through a remote connection.
|
||||
/// </summary>
|
||||
public class RemotePlayer : Player, IClientVersionProvider
|
||||
public class RemotePlayer : Player, IClientVersionProvider, IHasIpAddress
|
||||
{
|
||||
private readonly byte[] _packetBuffer = new byte[0xFF];
|
||||
|
||||
private ClientVersion _clientVersion;
|
||||
|
||||
private readonly string? _ipAddress;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RemotePlayer"/> class.
|
||||
/// </summary>
|
||||
@@ -33,6 +35,9 @@ public class RemotePlayer : Player, IClientVersionProvider
|
||||
{
|
||||
this.Connection = connection;
|
||||
this._clientVersion = clientVersion;
|
||||
this._ipAddress = connection.EndPoint is System.Net.IPEndPoint ipEndPoint
|
||||
? (ipEndPoint.Address.IsIPv4MappedToIPv6 ? ipEndPoint.Address.MapToIPv4() : ipEndPoint.Address).ToString()
|
||||
: null;
|
||||
this.MainPacketHandler = new MainPacketHandlerPlugInContainer(this, gameContext.PlugInManager, gameContext.LoggerFactory);
|
||||
this.MainPacketHandler.Initialize();
|
||||
this.Connection!.PacketReceived += this.PacketReceivedAsync;
|
||||
@@ -42,6 +47,9 @@ public class RemotePlayer : Player, IClientVersionProvider
|
||||
/// <inheritdoc />
|
||||
public event EventHandler? ClientVersionChanged;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string? IpAddress => this._ipAddress;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the game server context.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user