239 lines
5.7 KiB
C#
239 lines
5.7 KiB
C#
using System;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Net
|
|
{
|
|
// Token: 0x02001A18 RID: 6680
|
|
[Token(Token = "0x2001A18")]
|
|
public class IPAddress
|
|
{
|
|
// Token: 0x06009D01 RID: 40193 RVA: 0x00205C68 File Offset: 0x00203E68
|
|
[Token(Token = "0x6009D01")]
|
|
[Address(RVA = "0x4E9300", Offset = "0x4E8300", VA = "0x1804E9300")]
|
|
public static bool IsValid(string address)
|
|
{
|
|
return IPAddress.IsValidIPv4(address) || IPAddress.IsValidIPv6(address);
|
|
}
|
|
|
|
// Token: 0x06009D02 RID: 40194 RVA: 0x00205C88 File Offset: 0x00203E88
|
|
[Token(Token = "0x6009D02")]
|
|
[Address(RVA = "0x4E91E0", Offset = "0x4E81E0", VA = "0x1804E91E0")]
|
|
public static bool IsValidWithNetMask(string address)
|
|
{
|
|
int num2;
|
|
int num = num2 + 1;
|
|
string text = address.Substring(num);
|
|
if (num2 > 0)
|
|
{
|
|
int num3 = 0;
|
|
if (IPAddress.IsValidIPv4(address.Substring(num3, num2)) && (IPAddress.IsValidIPv4(text) || IPAddress.IsMaskValue(text, 32)))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
int num4;
|
|
num2 = num4;
|
|
int num5 = num4 + 1;
|
|
string text2 = address.Substring(num5);
|
|
if (num2 > 0)
|
|
{
|
|
int num6 = 0;
|
|
if (!IPAddress.IsValidIPv6(address.Substring(num6, num2)))
|
|
{
|
|
}
|
|
}
|
|
IL_66:
|
|
bool flag;
|
|
while (flag)
|
|
{
|
|
}
|
|
bool flag2;
|
|
return flag2;
|
|
goto IL_66;
|
|
}
|
|
|
|
// Token: 0x06009D03 RID: 40195 RVA: 0x00205D08 File Offset: 0x00203F08
|
|
[Token(Token = "0x6009D03")]
|
|
[Address(RVA = "0x4E8FA0", Offset = "0x4E7FA0", VA = "0x1804E8FA0")]
|
|
public static bool IsValidIPv4(string address)
|
|
{
|
|
if (address.m_stringLength != 0)
|
|
{
|
|
int num = 0;
|
|
string text = address + ".";
|
|
if (num < text.m_stringLength)
|
|
{
|
|
uint num3;
|
|
int num2 = text.IndexOf((char)num3, num);
|
|
if (num2 > num && num != 4)
|
|
{
|
|
num2 -= num;
|
|
if (int.Parse(text.Substring(num, num2)) <= 255)
|
|
{
|
|
num++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009D04 RID: 40196 RVA: 0x00205D70 File Offset: 0x00203F70
|
|
[Token(Token = "0x6009D04")]
|
|
[Address(RVA = "0x4E9330", Offset = "0x4E8330", VA = "0x1804E9330")]
|
|
private static bool unsafeIsValidIPv4(string address)
|
|
{
|
|
if (address.m_stringLength != 0)
|
|
{
|
|
int num = 0;
|
|
string text = address + ".";
|
|
if (num < text.m_stringLength)
|
|
{
|
|
uint num3;
|
|
int num2 = text.IndexOf((char)num3, num);
|
|
if (num2 > num)
|
|
{
|
|
if (num == 4)
|
|
{
|
|
goto IL_52;
|
|
}
|
|
num2 -= num;
|
|
if (int.Parse(text.Substring(num, num2)) > 255)
|
|
{
|
|
goto IL_52;
|
|
}
|
|
num++;
|
|
}
|
|
}
|
|
return num == 4;
|
|
}
|
|
IL_52:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009D05 RID: 40197 RVA: 0x00205DD4 File Offset: 0x00203FD4
|
|
[Token(Token = "0x6009D05")]
|
|
[Address(RVA = "0x4E8EE0", Offset = "0x4E7EE0", VA = "0x1804E8EE0")]
|
|
public static bool IsValidIPv4WithNetmask(string address)
|
|
{
|
|
int num2;
|
|
int num = num2 + 1;
|
|
string text = address.Substring(num);
|
|
if (num2 > 0)
|
|
{
|
|
int num3 = 0;
|
|
if (IPAddress.IsValidIPv4(address.Substring(num3, num2)))
|
|
{
|
|
return IPAddress.IsValidIPv4(text) || IPAddress.IsMaskValue(text, 32);
|
|
}
|
|
}
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009D06 RID: 40198 RVA: 0x00205E20 File Offset: 0x00204020
|
|
[Token(Token = "0x6009D06")]
|
|
[Address(RVA = "0x4E90C0", Offset = "0x4E80C0", VA = "0x1804E90C0")]
|
|
public static bool IsValidIPv6WithNetmask(string address)
|
|
{
|
|
int num2;
|
|
int num = num2 + 1;
|
|
string text = address.Substring(num);
|
|
if (num2 > 0)
|
|
{
|
|
int num3 = 0;
|
|
if (!IPAddress.IsValidIPv6(address.Substring(num3, num2)))
|
|
{
|
|
}
|
|
}
|
|
bool flag;
|
|
bool flag2;
|
|
return flag || flag2;
|
|
}
|
|
|
|
// Token: 0x06009D07 RID: 40199 RVA: 0x00205E64 File Offset: 0x00204064
|
|
[Token(Token = "0x6009D07")]
|
|
[Address(RVA = "0x4E8E60", Offset = "0x4E7E60", VA = "0x1804E8E60")]
|
|
private static bool IsMaskValue(string component, int size)
|
|
{
|
|
return int.Parse(component) <= size;
|
|
}
|
|
|
|
// Token: 0x06009D08 RID: 40200 RVA: 0x00205E80 File Offset: 0x00204080
|
|
[Token(Token = "0x6009D08")]
|
|
[Address(RVA = "0x4E9180", Offset = "0x4E8180", VA = "0x1804E9180")]
|
|
public static bool IsValidIPv6(string address)
|
|
{
|
|
return IPAddress.unsafeIsValidIPv6(address);
|
|
}
|
|
|
|
// Token: 0x06009D09 RID: 40201 RVA: 0x00205E98 File Offset: 0x00204098
|
|
[Token(Token = "0x6009D09")]
|
|
[Address(RVA = "0x4E9410", Offset = "0x4E8410", VA = "0x1804E9410")]
|
|
private static bool unsafeIsValidIPv6(string address)
|
|
{
|
|
if (address.m_stringLength != 0)
|
|
{
|
|
int num = 0;
|
|
string text = address + ":";
|
|
int num2 = 0;
|
|
if (num < text.m_stringLength)
|
|
{
|
|
uint num4;
|
|
int num3 = text.IndexOf((char)num4, num);
|
|
if (num == 8)
|
|
{
|
|
goto IL_C2;
|
|
}
|
|
int num5;
|
|
if (num == num3)
|
|
{
|
|
if (num3 != 1)
|
|
{
|
|
int stringLength = text.m_stringLength;
|
|
}
|
|
if (num != num2)
|
|
{
|
|
goto IL_C2;
|
|
}
|
|
num5 = num3 + 1;
|
|
num = num5;
|
|
num++;
|
|
}
|
|
num3 -= num5;
|
|
string text2 = text.Substring(num5, num3);
|
|
int stringLength2 = text.m_stringLength;
|
|
uint num6;
|
|
int num7;
|
|
if (num3 == stringLength2 && text2.IndexOf((char)num6) > 0)
|
|
{
|
|
if (!IPAddress.IsValidIPv4(text2))
|
|
{
|
|
goto IL_C2;
|
|
}
|
|
num++;
|
|
num7 = num3 + 1;
|
|
num++;
|
|
}
|
|
string text3 = text.Substring(num7, num3);
|
|
int num8;
|
|
if (num8 > 65535)
|
|
{
|
|
goto IL_C2;
|
|
}
|
|
num++;
|
|
}
|
|
return num != 8;
|
|
}
|
|
IL_C2:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009D0A RID: 40202 RVA: 0x00205F6C File Offset: 0x0020416C
|
|
[Token(Token = "0x6009D0A")]
|
|
[Address(RVA = "0x412370", Offset = "0x411370", VA = "0x180412370")]
|
|
public IPAddress()
|
|
{
|
|
}
|
|
}
|
|
}
|