550 lines
13 KiB
C#
550 lines
13 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using BestHTTP.Logger;
|
|
using BestHTTP.PlatformSupport.FileSystem;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.Cookies
|
|
{
|
|
// Token: 0x02001FC0 RID: 8128
|
|
[Token(Token = "0x2001FC0")]
|
|
public static class CookieJar
|
|
{
|
|
// Token: 0x170020CF RID: 8399
|
|
// (get) Token: 0x0600CE2A RID: 52778 RVA: 0x002F6F10 File Offset: 0x002F5110
|
|
[Token(Token = "0x170020CF")]
|
|
public static bool IsSavingSupported
|
|
{
|
|
[Token(Token = "0x600CE2A")]
|
|
[Address(RVA = "0x1964750", Offset = "0x1963550", VA = "0x181964750")]
|
|
get
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
IIOService ioservice = HTTPManager.IOService;
|
|
string rootCacheFolder = HTTPManager.GetRootCacheFolder();
|
|
ILogger logger = HTTPManager.Logger;
|
|
}
|
|
while (num != 0);
|
|
return CookieJar._isSavingSupported;
|
|
}
|
|
}
|
|
|
|
// Token: 0x170020D0 RID: 8400
|
|
// (get) Token: 0x0600CE2B RID: 52779 RVA: 0x002F6F54 File Offset: 0x002F5154
|
|
// (set) Token: 0x0600CE2C RID: 52780 RVA: 0x002F6F68 File Offset: 0x002F5168
|
|
[Token(Token = "0x170020D0")]
|
|
private static string CookieFolder
|
|
{
|
|
[Token(Token = "0x600CE2B")]
|
|
[Address(RVA = "0x1964690", Offset = "0x1963490", VA = "0x181964690")]
|
|
get;
|
|
[Token(Token = "0x600CE2C")]
|
|
[Address(RVA = "0x1964AA0", Offset = "0x19638A0", VA = "0x181964AA0")]
|
|
set;
|
|
}
|
|
|
|
// Token: 0x170020D1 RID: 8401
|
|
// (get) Token: 0x0600CE2D RID: 52781 RVA: 0x002F6F7C File Offset: 0x002F517C
|
|
// (set) Token: 0x0600CE2E RID: 52782 RVA: 0x002F6F90 File Offset: 0x002F5190
|
|
[Token(Token = "0x170020D1")]
|
|
private static string LibraryPath
|
|
{
|
|
[Token(Token = "0x600CE2D")]
|
|
[Address(RVA = "0x19649E0", Offset = "0x19637E0", VA = "0x1819649E0")]
|
|
get;
|
|
[Token(Token = "0x600CE2E")]
|
|
[Address(RVA = "0x1964B00", Offset = "0x1963900", VA = "0x181964B00")]
|
|
set;
|
|
}
|
|
|
|
// Token: 0x0600CE2F RID: 52783 RVA: 0x002F6FA4 File Offset: 0x002F51A4
|
|
[Token(Token = "0x600CE2F")]
|
|
[Address(RVA = "0x1964320", Offset = "0x1963120", VA = "0x181964320")]
|
|
internal static void SetupFolder()
|
|
{
|
|
if (CookieJar.IsSavingSupported)
|
|
{
|
|
bool flag = string.IsNullOrEmpty(CookieJar.<CookieFolder>k__BackingField);
|
|
if (flag || flag)
|
|
{
|
|
CookieJar.<CookieFolder>k__BackingField = Path.Combine(HTTPManager.GetRootCacheFolder(), "Cookies");
|
|
CookieJar.<LibraryPath>k__BackingField = Path.Combine(CookieJar.<CookieFolder>k__BackingField, "Library");
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600CE30 RID: 52784 RVA: 0x002F6FF8 File Offset: 0x002F51F8
|
|
[Token(Token = "0x600CE30")]
|
|
[Address(RVA = "0x1963EB0", Offset = "0x1962CB0", VA = "0x181963EB0")]
|
|
internal static void Set(HTTPResponse response)
|
|
{
|
|
while (response != 0)
|
|
{
|
|
object locker = CookieJar.Locker;
|
|
CookieJar.Maintain();
|
|
List<Cookie> list = new List();
|
|
List<string> headerValues = response.GetHeaderValues("set-cookie");
|
|
if (headerValues != 0)
|
|
{
|
|
bool flag;
|
|
if (flag)
|
|
{
|
|
Uri currentUri = response.baseRequest.CurrentUri;
|
|
Cookie cookie;
|
|
if (cookie == 0)
|
|
{
|
|
goto IL_90;
|
|
}
|
|
if (!string.IsNullOrEmpty(cookie.<Value>k__BackingField))
|
|
{
|
|
int num = 0;
|
|
if (cookie.WillExpireInTheFuture())
|
|
{
|
|
Cookie cookie2;
|
|
if (cookie2 != 0)
|
|
{
|
|
DateTime <Date>k__BackingField = cookie2.<Date>k__BackingField;
|
|
cookie.<Date>k__BackingField = <Date>k__BackingField;
|
|
CookieJar.Cookies[num] = cookie;
|
|
list.Add(cookie);
|
|
goto IL_90;
|
|
}
|
|
goto IL_90;
|
|
}
|
|
}
|
|
IL_9C:
|
|
while (cookie == (ulong)(-1L))
|
|
{
|
|
}
|
|
List<Cookie> cookies = CookieJar.Cookies;
|
|
goto IL_AA;
|
|
IL_90:
|
|
CookieJar.Cookies.Add(cookie);
|
|
goto IL_9C;
|
|
}
|
|
IL_AA:
|
|
int num2 = 0;
|
|
if (response != 0)
|
|
{
|
|
throw new NullReferenceException();
|
|
}
|
|
if (num2 != -1)
|
|
{
|
|
}
|
|
response.<Cookies>k__BackingField = list;
|
|
num2++;
|
|
}
|
|
Monitor.Exit(headerValues);
|
|
if (headerValues == 0)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600CE31 RID: 52785 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x600CE31")]
|
|
[Address(RVA = "0x1962E90", Offset = "0x1961C90", VA = "0x181962E90")]
|
|
internal static void Maintain()
|
|
{
|
|
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
|
|
}
|
|
|
|
// Token: 0x0600CE32 RID: 52786 RVA: 0x002F7108 File Offset: 0x002F5308
|
|
[Token(Token = "0x600CE32")]
|
|
[Address(RVA = "0x1963360", Offset = "0x1962160", VA = "0x181963360")]
|
|
internal static void Persist()
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
if (!CookieJar.IsSavingSupported)
|
|
{
|
|
break;
|
|
}
|
|
object locker = CookieJar.Locker;
|
|
CookieJar.Maintain();
|
|
IIOService ioservice = HTTPManager.IOService;
|
|
IIOService ioservice2 = HTTPManager.IOService;
|
|
IIOService ioservice3 = HTTPManager.IOService;
|
|
BinaryWriter binaryWriter;
|
|
binaryWriter.Write(1);
|
|
int num2 = 0;
|
|
List<Cookie> cookies = CookieJar.Cookies;
|
|
bool flag;
|
|
if (flag)
|
|
{
|
|
num2++;
|
|
}
|
|
int num3 = 0;
|
|
if (num != 0)
|
|
{
|
|
goto IL_D0;
|
|
}
|
|
if (num3 != -1)
|
|
{
|
|
}
|
|
binaryWriter.Write((ushort)num2);
|
|
List<Cookie> cookies2 = CookieJar.Cookies;
|
|
bool flag2;
|
|
if (flag2)
|
|
{
|
|
}
|
|
num3++;
|
|
if (num != 0)
|
|
{
|
|
goto IL_D6;
|
|
}
|
|
if (num3 != -1)
|
|
{
|
|
}
|
|
num3++;
|
|
if (binaryWriter != 0)
|
|
{
|
|
}
|
|
if (num != 0)
|
|
{
|
|
goto IL_EE;
|
|
}
|
|
if (num3 != -1)
|
|
{
|
|
}
|
|
num3++;
|
|
if (num2 != 0)
|
|
{
|
|
}
|
|
if (num != 0)
|
|
{
|
|
goto IL_EE;
|
|
}
|
|
if (num3 != -1)
|
|
{
|
|
}
|
|
num3++;
|
|
num3++;
|
|
Monitor.Exit(num3);
|
|
}
|
|
while (num != 0);
|
|
return;
|
|
IL_D0:
|
|
throw new NullReferenceException();
|
|
IL_D6:
|
|
throw new NullReferenceException();
|
|
IL_EE:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600CE33 RID: 52787 RVA: 0x002F7210 File Offset: 0x002F5410
|
|
[Token(Token = "0x600CE33")]
|
|
[Address(RVA = "0x19627E0", Offset = "0x19615E0", VA = "0x1819627E0")]
|
|
internal static void Load()
|
|
{
|
|
for (;;)
|
|
{
|
|
int num = 0;
|
|
if (!CookieJar.IsSavingSupported)
|
|
{
|
|
break;
|
|
}
|
|
object locker = CookieJar.Locker;
|
|
CookieJar.SetupFolder();
|
|
CookieJar.Cookies.Clear();
|
|
IIOService ioservice = HTTPManager.IOService;
|
|
IIOService ioservice2 = HTTPManager.IOService;
|
|
IIOService ioservice3 = HTTPManager.IOService;
|
|
IIOService ioservice4 = HTTPManager.IOService;
|
|
BinaryReader binaryReader;
|
|
ushort num2 = binaryReader.ReadUInt16();
|
|
ushort num3 = binaryReader.ReadUInt16();
|
|
int num4 = 0;
|
|
if (num4 < (int)num3)
|
|
{
|
|
Cookie cookie = new Cookie();
|
|
cookie.LoadFrom(binaryReader);
|
|
if (cookie.WillExpireInTheFuture())
|
|
{
|
|
CookieJar.Cookies.Add(cookie);
|
|
}
|
|
num4++;
|
|
}
|
|
int num5 = 0;
|
|
if (binaryReader != 0)
|
|
{
|
|
}
|
|
if (num != 0)
|
|
{
|
|
goto IL_EE;
|
|
}
|
|
if (num5 != -1)
|
|
{
|
|
}
|
|
num5++;
|
|
if (num != 0)
|
|
{
|
|
goto IL_EE;
|
|
}
|
|
if (num5 != -1)
|
|
{
|
|
}
|
|
num5++;
|
|
int num6 = 0;
|
|
CookieJar.Cookies.Clear();
|
|
num6++;
|
|
if (num == 0)
|
|
{
|
|
if (num6 != -1)
|
|
{
|
|
}
|
|
if (num == 0)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
IL_EE:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600CE34 RID: 52788 RVA: 0x002F7328 File Offset: 0x002F5528
|
|
[Token(Token = "0x600CE34")]
|
|
[Address(RVA = "0x1962560", Offset = "0x1961360", VA = "0x181962560")]
|
|
public static List<Cookie> Get(Uri uri)
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
object locker = CookieJar.Locker;
|
|
CookieJar.Load();
|
|
List<Cookie> cookies = CookieJar.Cookies;
|
|
List<Cookie> cookies2 = CookieJar.Cookies;
|
|
bool flag;
|
|
if (flag)
|
|
{
|
|
int num2 = 0;
|
|
if (uri.Host.IndexOf(num2) != -1)
|
|
{
|
|
int num3 = 0;
|
|
if (uri.AbsolutePath.StartsWith(num3) && num == 0)
|
|
{
|
|
List<Cookie> list = new List();
|
|
}
|
|
}
|
|
}
|
|
num++;
|
|
Monitor.Exit(locker);
|
|
}
|
|
while (num != 0);
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600CE35 RID: 52789 RVA: 0x002F73C0 File Offset: 0x002F55C0
|
|
[Token(Token = "0x600CE35")]
|
|
[Address(RVA = "0x1963C90", Offset = "0x1962A90", VA = "0x181963C90")]
|
|
public static void Set(Uri uri, Cookie cookie)
|
|
{
|
|
CookieJar.Set(cookie);
|
|
}
|
|
|
|
// Token: 0x0600CE36 RID: 52790 RVA: 0x002F73D4 File Offset: 0x002F55D4
|
|
[Token(Token = "0x600CE36")]
|
|
[Address(RVA = "0x1963CF0", Offset = "0x1962AF0", VA = "0x181963CF0")]
|
|
public static void Set(Cookie cookie)
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
object locker = CookieJar.Locker;
|
|
CookieJar.Load();
|
|
CookieJar.Cookies.Add(cookie);
|
|
List<Cookie> cookies = CookieJar.Cookies;
|
|
Monitor.Exit(locker);
|
|
}
|
|
while (num != 0);
|
|
}
|
|
|
|
// Token: 0x0600CE37 RID: 52791 RVA: 0x002F7418 File Offset: 0x002F5618
|
|
[Token(Token = "0x600CE37")]
|
|
[Address(RVA = "0x1962450", Offset = "0x1961250", VA = "0x181962450")]
|
|
public static List<Cookie> GetAll()
|
|
{
|
|
int num;
|
|
List<Cookie> cookies;
|
|
do
|
|
{
|
|
num = 0;
|
|
object locker = CookieJar.Locker;
|
|
CookieJar.Load();
|
|
cookies = CookieJar.Cookies;
|
|
Monitor.Exit(locker);
|
|
}
|
|
while (num != 0);
|
|
return cookies;
|
|
}
|
|
|
|
// Token: 0x0600CE38 RID: 52792 RVA: 0x002F7448 File Offset: 0x002F5648
|
|
[Token(Token = "0x600CE38")]
|
|
[Address(RVA = "0x1961D70", Offset = "0x1960B70", VA = "0x181961D70")]
|
|
public static void Clear()
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
object locker = CookieJar.Locker;
|
|
CookieJar.Load();
|
|
CookieJar.Cookies.Clear();
|
|
Monitor.Exit(locker);
|
|
}
|
|
while (num != 0);
|
|
}
|
|
|
|
// Token: 0x0600CE39 RID: 52793 RVA: 0x002F7480 File Offset: 0x002F5680
|
|
[Token(Token = "0x600CE39")]
|
|
[Address(RVA = "0x1961E90", Offset = "0x1960C90", VA = "0x181961E90")]
|
|
public static void Clear(TimeSpan olderThan)
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
object locker = CookieJar.Locker;
|
|
CookieJar.Load();
|
|
List<Cookie> cookies = CookieJar.Cookies;
|
|
List<Cookie> cookies2 = CookieJar.Cookies;
|
|
bool flag;
|
|
if (flag)
|
|
{
|
|
object locker2 = CookieJar.Locker;
|
|
DateTime utcNow = DateTime.UtcNow;
|
|
DateTime dateTime;
|
|
if (!(dateTime < utcNow))
|
|
{
|
|
num++;
|
|
}
|
|
}
|
|
CookieJar.Cookies.RemoveAt(num);
|
|
Monitor.Exit(locker);
|
|
}
|
|
while (num != 0);
|
|
}
|
|
|
|
// Token: 0x0600CE3A RID: 52794 RVA: 0x002F74FC File Offset: 0x002F56FC
|
|
[Token(Token = "0x600CE3A")]
|
|
[Address(RVA = "0x1962100", Offset = "0x1960F00", VA = "0x181962100")]
|
|
public static void Clear(string domain)
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
object locker = CookieJar.Locker;
|
|
CookieJar.Load();
|
|
List<Cookie> cookies = CookieJar.Cookies;
|
|
List<Cookie> cookies2 = CookieJar.Cookies;
|
|
bool flag;
|
|
int num2;
|
|
if (flag && num2 == -1)
|
|
{
|
|
num++;
|
|
}
|
|
CookieJar.Cookies.RemoveAt(num);
|
|
Monitor.Exit(locker);
|
|
}
|
|
while (num != 0);
|
|
}
|
|
|
|
// Token: 0x0600CE3B RID: 52795 RVA: 0x002F7568 File Offset: 0x002F5768
|
|
[Token(Token = "0x600CE3B")]
|
|
[Address(RVA = "0x1963A10", Offset = "0x1962810", VA = "0x181963A10")]
|
|
public static void Remove(Uri uri, string name)
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
object locker = CookieJar.Locker;
|
|
CookieJar.Load();
|
|
List<Cookie> cookies = CookieJar.Cookies;
|
|
List<Cookie> cookies2 = CookieJar.Cookies;
|
|
if (CookieJar.<CookieFolder>k__BackingField.Equals(name, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
int num2 = 0;
|
|
if (uri.Host.IndexOf(num2) != -1)
|
|
{
|
|
CookieJar.Cookies.RemoveAt(num);
|
|
}
|
|
}
|
|
num++;
|
|
Monitor.Exit(locker);
|
|
}
|
|
while (num != 0);
|
|
}
|
|
|
|
// Token: 0x0600CE3C RID: 52796 RVA: 0x002F75F8 File Offset: 0x002F57F8
|
|
[Token(Token = "0x600CE3C")]
|
|
[Address(RVA = "0x1962340", Offset = "0x1961140", VA = "0x181962340")]
|
|
private static Cookie Find(Cookie cookie, out int idx)
|
|
{
|
|
int num = 0;
|
|
List<Cookie> cookies = CookieJar.Cookies;
|
|
List<Cookie> cookies2 = CookieJar.Cookies;
|
|
bool flag;
|
|
if (!flag)
|
|
{
|
|
num++;
|
|
}
|
|
idx.m_value = num;
|
|
return typeof(CookieJar).TypeHandle;
|
|
}
|
|
|
|
// Token: 0x0600CE3D RID: 52797 RVA: 0x002F7630 File Offset: 0x002F5830
|
|
// Note: this type is marked as 'beforefieldinit'.
|
|
[Token(Token = "0x600CE3D")]
|
|
[Address(RVA = "0x19645D0", Offset = "0x19633D0", VA = "0x1819645D0")]
|
|
static CookieJar()
|
|
{
|
|
TimeSpan timeSpan;
|
|
CookieJar.AccessThreshold = timeSpan;
|
|
CookieJar.Cookies = new List();
|
|
CookieJar.Locker = new object();
|
|
}
|
|
|
|
// Token: 0x040083E8 RID: 33768
|
|
[Token(Token = "0x40083E8")]
|
|
private const int Version = 1;
|
|
|
|
// Token: 0x040083E9 RID: 33769
|
|
[Token(Token = "0x40083E9")]
|
|
public static TimeSpan AccessThreshold;
|
|
|
|
// Token: 0x040083EA RID: 33770
|
|
[Token(Token = "0x40083EA")]
|
|
private static List<Cookie> Cookies;
|
|
|
|
// Token: 0x040083ED RID: 33773
|
|
[Token(Token = "0x40083ED")]
|
|
private static object Locker;
|
|
|
|
// Token: 0x040083EE RID: 33774
|
|
[Token(Token = "0x40083EE")]
|
|
private static bool _isSavingSupported;
|
|
|
|
// Token: 0x040083EF RID: 33775
|
|
[Token(Token = "0x40083EF")]
|
|
private static bool IsSupportCheckDone;
|
|
|
|
// Token: 0x040083F0 RID: 33776
|
|
[Token(Token = "0x40083F0")]
|
|
private static bool Loaded;
|
|
}
|
|
}
|