241 lines
5.8 KiB
C#
241 lines
5.8 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Net
|
|
{
|
|
// Token: 0x0200135B RID: 4955
|
|
[Token(Token = "0x200135B")]
|
|
[StructLayout(3)]
|
|
public class IPAddress
|
|
{
|
|
// Token: 0x06007D59 RID: 32089 RVA: 0x001A55E4 File Offset: 0x001A37E4
|
|
[Token(Token = "0x6007D59")]
|
|
[Address(RVA = "0x202BFA0", Offset = "0x202A9A0", VA = "0x18202BFA0")]
|
|
public static bool IsValid(string address)
|
|
{
|
|
return IPAddress.IsValidIPv4(address) || IPAddress.IsValidIPv6(address);
|
|
}
|
|
|
|
// Token: 0x06007D5A RID: 32090 RVA: 0x001A5604 File Offset: 0x001A3804
|
|
[Token(Token = "0x6007D5A")]
|
|
[Address(RVA = "0x202BE80", Offset = "0x202A880", VA = "0x18202BE80")]
|
|
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: 0x06007D5B RID: 32091 RVA: 0x001A5684 File Offset: 0x001A3884
|
|
[Token(Token = "0x6007D5B")]
|
|
[Address(RVA = "0x202BC40", Offset = "0x202A640", VA = "0x18202BC40")]
|
|
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: 0x06007D5C RID: 32092 RVA: 0x001A56EC File Offset: 0x001A38EC
|
|
[Token(Token = "0x6007D5C")]
|
|
[Address(RVA = "0x202BFD0", Offset = "0x202A9D0", VA = "0x18202BFD0")]
|
|
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: 0x06007D5D RID: 32093 RVA: 0x001A5750 File Offset: 0x001A3950
|
|
[Token(Token = "0x6007D5D")]
|
|
[Address(RVA = "0x202BB80", Offset = "0x202A580", VA = "0x18202BB80")]
|
|
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: 0x06007D5E RID: 32094 RVA: 0x001A579C File Offset: 0x001A399C
|
|
[Token(Token = "0x6007D5E")]
|
|
[Address(RVA = "0x202BD60", Offset = "0x202A760", VA = "0x18202BD60")]
|
|
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: 0x06007D5F RID: 32095 RVA: 0x001A57E0 File Offset: 0x001A39E0
|
|
[Token(Token = "0x6007D5F")]
|
|
[Address(RVA = "0x202BB00", Offset = "0x202A500", VA = "0x18202BB00")]
|
|
private static bool IsMaskValue(string component, int size)
|
|
{
|
|
return int.Parse(component) <= size;
|
|
}
|
|
|
|
// Token: 0x06007D60 RID: 32096 RVA: 0x001A57FC File Offset: 0x001A39FC
|
|
[Token(Token = "0x6007D60")]
|
|
[Address(RVA = "0x202BE20", Offset = "0x202A820", VA = "0x18202BE20")]
|
|
public static bool IsValidIPv6(string address)
|
|
{
|
|
return IPAddress.unsafeIsValidIPv6(address);
|
|
}
|
|
|
|
// Token: 0x06007D61 RID: 32097 RVA: 0x001A5814 File Offset: 0x001A3A14
|
|
[Token(Token = "0x6007D61")]
|
|
[Address(RVA = "0x202C0B0", Offset = "0x202AAB0", VA = "0x18202C0B0")]
|
|
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: 0x06007D62 RID: 32098 RVA: 0x001A58E8 File Offset: 0x001A3AE8
|
|
[Token(Token = "0x6007D62")]
|
|
[Address(RVA = "0x3C1670", Offset = "0x3C0070", VA = "0x1803C1670")]
|
|
public IPAddress()
|
|
{
|
|
}
|
|
}
|
|
}
|