示例#1
0
        public static CMsgIPAddress ObfuscatePrivateIP(this CMsgIPAddress msgIpAddress)
        {
            var localIp = msgIpAddress;

            if (localIp.ShouldSerializev6())
            {
                localIp.v6[0] ^= 0x0D;
                localIp.v6[1] ^= 0xF0;
                localIp.v6[2] ^= 0xAD;
                localIp.v6[3] ^= 0xBA;

                localIp.v6[4] ^= 0x0D;
                localIp.v6[5] ^= 0xF0;
                localIp.v6[6] ^= 0xAD;
                localIp.v6[7] ^= 0xBA;

                localIp.v6[8]  ^= 0x0D;
                localIp.v6[9]  ^= 0xF0;
                localIp.v6[10] ^= 0xAD;
                localIp.v6[11] ^= 0xBA;

                localIp.v6[12] ^= 0x0D;
                localIp.v6[13] ^= 0xF0;
                localIp.v6[14] ^= 0xAD;
                localIp.v6[15] ^= 0xBA;
            }
            else
            {
                localIp.v4 ^= MsgClientLogon.ObfuscationMask;
            }

            return(localIp);
        }
示例#2
0
 public static IPAddress GetIPAddress(this CMsgIPAddress ipAddr)
 {
     if (ipAddr.ShouldSerializev6())
     {
         return(new IPAddress(ipAddr.v6));
     }
     else
     {
         return(GetIPAddress(ipAddr.v4));
     }
 }
示例#3
0
        public static CMsgIPAddress GetMsgIPAddress(IPAddress ipAddr)
        {
            var msgIpAddress = new CMsgIPAddress();

            byte[] addrBytes = ipAddr.GetAddressBytes();

            if (ipAddr.AddressFamily == AddressFamily.InterNetworkV6)
            {
                msgIpAddress.v6 = addrBytes;
            }
            else
            {
                Array.Reverse(addrBytes);

                msgIpAddress.v4 = BitConverter.ToUInt32(addrBytes, 0);
            }

            return(msgIpAddress);
        }