first commit

This commit is contained in:
2026-09-02 16:31:50 +08:00
commit a461727193
911 changed files with 692450 additions and 0 deletions
@@ -0,0 +1,30 @@
using DotNetty.Transport.Channels;
using System.Net;
namespace JSMachine.WMS.Netty.Common.Util
{
public static class ChannelHandlerContextUtil
{
public static IPInfo ToIPInfo(this IChannelHandlerContext channel, AddressOnwer addressOnwer)
{
IPEndPoint iPAddress = addressOnwer == AddressOnwer.Local ? (IPEndPoint)channel.Channel.LocalAddress
: (IPEndPoint)channel.Channel.RemoteAddress;
string ip = iPAddress?.Address.MapToIPv4().ToString();
int port = iPAddress == null ? 0 : iPAddress.Port;
return new IPInfo { IP = ip, Port = port };
}
}
public class IPInfo
{
public string IP { get; set; }
public int Port { get; set; }
}
public enum AddressOnwer
{
Local = 0,
Remote = 1
}
}