diff --git a/src/NosCore.Networking/IChannel.cs b/src/NosCore.Networking/IChannel.cs index a1d7e15..b41e930 100644 --- a/src/NosCore.Networking/IChannel.cs +++ b/src/NosCore.Networking/IChannel.cs @@ -19,6 +19,12 @@ public interface IChannel /// string Id { get; } + /// + /// Gets the remote peer's IP address as a string, or null if the + /// underlying session has no routable endpoint yet. + /// + string? RemoteAddress { get; } + /// /// Disconnects the channel asynchronously. /// diff --git a/src/NosCore.Networking/NetworkChannel.cs b/src/NosCore.Networking/NetworkChannel.cs index 1e04c18..97c3b9a 100644 --- a/src/NosCore.Networking/NetworkChannel.cs +++ b/src/NosCore.Networking/NetworkChannel.cs @@ -5,6 +5,7 @@ // ----------------------------------- using System; +using System.Net; using System.Threading.Tasks; using SuperSocket.Connection; using SuperSocket.Server.Abstractions.Session; @@ -32,6 +33,12 @@ public NetworkChannel(IAppSession session) /// public string Id => _session.SessionID; + /// + /// Gets the remote peer's IP address as a string, or null if the + /// underlying session has no routable endpoint yet. + /// + public string? RemoteAddress => (_session.RemoteEndPoint as IPEndPoint)?.Address.ToString(); + /// /// Disconnects the channel asynchronously. /// diff --git a/src/NosCore.Networking/NosCore.Networking.csproj b/src/NosCore.Networking/NosCore.Networking.csproj index 1e9a358..ce41266 100644 --- a/src/NosCore.Networking/NosCore.Networking.csproj +++ b/src/NosCore.Networking/NosCore.Networking.csproj @@ -12,7 +12,7 @@ https://github.com/NosCoreIO/NosCore.Networking.git nostale, noscore, nostale private server source, nostale emulator - 7.1.0 + 7.2.0 false NosCore Networking MIT