602 lines
14 KiB
C#
602 lines
14 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
using System.Threading;
|
|
using BestHTTP.Logger;
|
|
using BestHTTP.PlatformSupport.FileSystem;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.Cookies
|
|
{
|
|
// Token: 0x020019E3 RID: 6627
|
|
[Token(Token = "0x20019E3")]
|
|
[StructLayout(3)]
|
|
public static class CookieJar
|
|
{
|
|
// Token: 0x17001CCE RID: 7374
|
|
// (get) Token: 0x0600B250 RID: 45648 RVA: 0x0029E7D4 File Offset: 0x0029C9D4
|
|
[Token(Token = "0x17001CCE")]
|
|
public static bool IsSavingSupported
|
|
{
|
|
[Token(Token = "0x600B250")]
|
|
[Address(RVA = "0x1F04510", Offset = "0x1F02F10", VA = "0x181F04510")]
|
|
get
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
IIOService ioservice = HTTPManager.IOService;
|
|
string rootCacheFolder = HTTPManager.GetRootCacheFolder();
|
|
ILogger logger = HTTPManager.Logger;
|
|
num++;
|
|
if (num != -1)
|
|
{
|
|
}
|
|
}
|
|
while (num != 0);
|
|
return CookieJar._isSavingSupported;
|
|
}
|
|
}
|
|
|
|
// Token: 0x17001CCF RID: 7375
|
|
// (get) Token: 0x0600B251 RID: 45649 RVA: 0x0029E820 File Offset: 0x0029CA20
|
|
// (set) Token: 0x0600B252 RID: 45650 RVA: 0x0029E834 File Offset: 0x0029CA34
|
|
[Token(Token = "0x17001CCF")]
|
|
private static string CookieFolder
|
|
{
|
|
[Token(Token = "0x600B251")]
|
|
[Address(RVA = "0x1F04450", Offset = "0x1F02E50", VA = "0x181F04450")]
|
|
get;
|
|
[Token(Token = "0x600B252")]
|
|
[Address(RVA = "0x1F04880", Offset = "0x1F03280", VA = "0x181F04880")]
|
|
set;
|
|
}
|
|
|
|
// Token: 0x17001CD0 RID: 7376
|
|
// (get) Token: 0x0600B253 RID: 45651 RVA: 0x0029E848 File Offset: 0x0029CA48
|
|
// (set) Token: 0x0600B254 RID: 45652 RVA: 0x0029E85C File Offset: 0x0029CA5C
|
|
[Token(Token = "0x17001CD0")]
|
|
private static string LibraryPath
|
|
{
|
|
[Token(Token = "0x600B253")]
|
|
[Address(RVA = "0x1F047C0", Offset = "0x1F031C0", VA = "0x181F047C0")]
|
|
get;
|
|
[Token(Token = "0x600B254")]
|
|
[Address(RVA = "0x1F048E0", Offset = "0x1F032E0", VA = "0x181F048E0")]
|
|
set;
|
|
}
|
|
|
|
// Token: 0x0600B255 RID: 45653 RVA: 0x0029E870 File Offset: 0x0029CA70
|
|
[Token(Token = "0x600B255")]
|
|
[Address(RVA = "0x1F040E0", Offset = "0x1F02AE0", VA = "0x181F040E0")]
|
|
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: 0x0600B256 RID: 45654 RVA: 0x0029E8C4 File Offset: 0x0029CAC4
|
|
[Token(Token = "0x600B256")]
|
|
[Address(RVA = "0x1F03C50", Offset = "0x1F02650", VA = "0x181F03C50")]
|
|
internal static void Set(HTTPResponse response)
|
|
{
|
|
while (response != 0)
|
|
{
|
|
object locker = CookieJar.Locker;
|
|
CookieJar.Maintain();
|
|
List<Cookie> list = new List();
|
|
if (response.GetHeaderValues("set-cookie") != 0)
|
|
{
|
|
List.Enumerator enumerator;
|
|
if (enumerator != 0)
|
|
{
|
|
Uri currentUri = response.baseRequest.CurrentUri;
|
|
Cookie cookie;
|
|
if (cookie == 0)
|
|
{
|
|
goto IL_8D;
|
|
}
|
|
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_8D;
|
|
}
|
|
goto IL_8D;
|
|
}
|
|
}
|
|
IL_99:
|
|
while (cookie == (ulong)(-1L))
|
|
{
|
|
}
|
|
List<Cookie> cookies = CookieJar.Cookies;
|
|
goto IL_A7;
|
|
IL_8D:
|
|
CookieJar.Cookies.Add(cookie);
|
|
goto IL_99;
|
|
}
|
|
IL_A7:
|
|
int num2 = 0;
|
|
if (num2 != -1)
|
|
{
|
|
response.<Cookies>k__BackingField = list;
|
|
num2++;
|
|
}
|
|
if (response != 0)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
int num3 = 0;
|
|
num3++;
|
|
Monitor.Exit(response);
|
|
if (num3 != -1)
|
|
{
|
|
}
|
|
if (response == 0)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B257 RID: 45655 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x600B257")]
|
|
[Address(RVA = "0x1F02B90", Offset = "0x1F01590", VA = "0x181F02B90")]
|
|
internal static void Maintain()
|
|
{
|
|
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
|
|
}
|
|
|
|
// Token: 0x0600B258 RID: 45656 RVA: 0x0029E9E0 File Offset: 0x0029CBE0
|
|
[Token(Token = "0x600B258")]
|
|
[Address(RVA = "0x1F03080", Offset = "0x1F01A80", VA = "0x181F03080")]
|
|
internal static void Persist()
|
|
{
|
|
for (;;)
|
|
{
|
|
int 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;
|
|
List.Enumerator enumerator;
|
|
if (enumerator != 0)
|
|
{
|
|
num2++;
|
|
}
|
|
int num3 = 0;
|
|
if (num3 == -1)
|
|
{
|
|
goto IL_6B;
|
|
}
|
|
binaryWriter.Write((ushort)num2);
|
|
List<Cookie> cookies2 = CookieJar.Cookies;
|
|
List.Enumerator enumerator2;
|
|
if (enumerator2 != 0)
|
|
{
|
|
goto IL_6B;
|
|
}
|
|
IL_72:
|
|
num3++;
|
|
if (num3 != -1)
|
|
{
|
|
num3++;
|
|
}
|
|
if (num != 0)
|
|
{
|
|
goto IL_E1;
|
|
}
|
|
if (binaryWriter != 0)
|
|
{
|
|
}
|
|
if (num3 != -1)
|
|
{
|
|
num3++;
|
|
}
|
|
if (num != 0)
|
|
{
|
|
goto IL_F9;
|
|
}
|
|
int num4;
|
|
if (num3 != 0)
|
|
{
|
|
num4 = 0;
|
|
}
|
|
if (num3 != -1)
|
|
{
|
|
num3++;
|
|
}
|
|
if (num != 0)
|
|
{
|
|
goto IL_FF;
|
|
}
|
|
num3++;
|
|
int num5 = 0;
|
|
Monitor.Exit(num4);
|
|
if (num5 != -1)
|
|
{
|
|
}
|
|
if (num == 0)
|
|
{
|
|
break;
|
|
}
|
|
continue;
|
|
IL_6B:
|
|
if (num == 0)
|
|
{
|
|
goto IL_72;
|
|
}
|
|
goto IL_DB;
|
|
}
|
|
return;
|
|
IL_DB:
|
|
throw new NullReferenceException();
|
|
IL_E1:
|
|
throw new NullReferenceException();
|
|
IL_F9:
|
|
throw new NullReferenceException();
|
|
IL_FF:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600B259 RID: 45657 RVA: 0x0029EAF4 File Offset: 0x0029CCF4
|
|
[Token(Token = "0x600B259")]
|
|
[Address(RVA = "0x1F024A0", Offset = "0x1F00EA0", VA = "0x181F024A0")]
|
|
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 (num5 != -1)
|
|
{
|
|
num5++;
|
|
}
|
|
if (num != 0)
|
|
{
|
|
goto IL_F2;
|
|
}
|
|
if (num5 != -1)
|
|
{
|
|
num5++;
|
|
}
|
|
if (num != 0)
|
|
{
|
|
goto IL_F8;
|
|
}
|
|
int num6 = 0;
|
|
CookieJar.Cookies.Clear();
|
|
num6++;
|
|
if (num6 != -1)
|
|
{
|
|
}
|
|
if (num == 0)
|
|
{
|
|
if (0 != -1)
|
|
{
|
|
}
|
|
if (num == 0)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
IL_F2:
|
|
throw new NullReferenceException();
|
|
IL_F8:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600B25A RID: 45658 RVA: 0x0029EC10 File Offset: 0x0029CE10
|
|
[Token(Token = "0x600B25A")]
|
|
[Address(RVA = "0x1F021E0", Offset = "0x1F00BE0", VA = "0x181F021E0")]
|
|
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);
|
|
if (num != -1)
|
|
{
|
|
}
|
|
}
|
|
while (num != 0);
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600B25B RID: 45659 RVA: 0x0029ECAC File Offset: 0x0029CEAC
|
|
[Token(Token = "0x600B25B")]
|
|
[Address(RVA = "0x1F03A10", Offset = "0x1F02410", VA = "0x181F03A10")]
|
|
public static void Set(Uri uri, Cookie cookie)
|
|
{
|
|
CookieJar.Set(cookie);
|
|
}
|
|
|
|
// Token: 0x0600B25C RID: 45660 RVA: 0x0029ECC0 File Offset: 0x0029CEC0
|
|
[Token(Token = "0x600B25C")]
|
|
[Address(RVA = "0x1F03A70", Offset = "0x1F02470", VA = "0x181F03A70")]
|
|
public static void Set(Cookie cookie)
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
object locker = CookieJar.Locker;
|
|
CookieJar.Load();
|
|
CookieJar.Cookies.Add(cookie);
|
|
CookieJar.Cookies[num] = cookie;
|
|
Monitor.Exit(locker);
|
|
if (num != -1)
|
|
{
|
|
}
|
|
}
|
|
while (num != 0);
|
|
}
|
|
|
|
// Token: 0x0600B25D RID: 45661 RVA: 0x0029ED10 File Offset: 0x0029CF10
|
|
[Token(Token = "0x600B25D")]
|
|
[Address(RVA = "0x1F020A0", Offset = "0x1F00AA0", VA = "0x181F020A0")]
|
|
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);
|
|
if (num != -1)
|
|
{
|
|
}
|
|
}
|
|
while (num != 0);
|
|
return cookies;
|
|
}
|
|
|
|
// Token: 0x0600B25E RID: 45662 RVA: 0x0029ED44 File Offset: 0x0029CF44
|
|
[Token(Token = "0x600B25E")]
|
|
[Address(RVA = "0x1F01960", Offset = "0x1F00360", VA = "0x181F01960")]
|
|
public static void Clear()
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
object locker = CookieJar.Locker;
|
|
CookieJar.Load();
|
|
CookieJar.Cookies.Clear();
|
|
Monitor.Exit(locker);
|
|
if (num != -1)
|
|
{
|
|
}
|
|
}
|
|
while (num != 0);
|
|
}
|
|
|
|
// Token: 0x0600B25F RID: 45663 RVA: 0x0029ED80 File Offset: 0x0029CF80
|
|
[Token(Token = "0x600B25F")]
|
|
[Address(RVA = "0x1F01AA0", Offset = "0x1F004A0", VA = "0x181F01AA0")]
|
|
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);
|
|
if (num != -1)
|
|
{
|
|
}
|
|
}
|
|
while (num != 0);
|
|
}
|
|
|
|
// Token: 0x0600B260 RID: 45664 RVA: 0x0029EE00 File Offset: 0x0029D000
|
|
[Token(Token = "0x600B260")]
|
|
[Address(RVA = "0x1F01D30", Offset = "0x1F00730", VA = "0x181F01D30")]
|
|
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);
|
|
if (num != -1)
|
|
{
|
|
}
|
|
}
|
|
while (num != 0);
|
|
}
|
|
|
|
// Token: 0x0600B261 RID: 45665 RVA: 0x0029EE70 File Offset: 0x0029D070
|
|
[Token(Token = "0x600B261")]
|
|
[Address(RVA = "0x1F03770", Offset = "0x1F02170", VA = "0x181F03770")]
|
|
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);
|
|
if (num != -1)
|
|
{
|
|
}
|
|
}
|
|
while (num != 0);
|
|
}
|
|
|
|
// Token: 0x0600B262 RID: 45666 RVA: 0x0029EF04 File Offset: 0x0029D104
|
|
[Token(Token = "0x600B262")]
|
|
[Address(RVA = "0x1F01F90", Offset = "0x1F00990", VA = "0x181F01F90")]
|
|
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: 0x0600B263 RID: 45667 RVA: 0x0029EF3C File Offset: 0x0029D13C
|
|
// Note: this type is marked as 'beforefieldinit'.
|
|
[Token(Token = "0x600B263")]
|
|
[Address(RVA = "0x1F04390", Offset = "0x1F02D90", VA = "0x181F04390")]
|
|
static CookieJar()
|
|
{
|
|
TimeSpan timeSpan;
|
|
CookieJar.AccessThreshold = timeSpan;
|
|
CookieJar.Cookies = new List();
|
|
CookieJar.Locker = new object();
|
|
}
|
|
|
|
// Token: 0x040075A5 RID: 30117
|
|
[Token(Token = "0x40075A5")]
|
|
private const int Version = 1;
|
|
|
|
// Token: 0x040075A6 RID: 30118
|
|
[Token(Token = "0x40075A6")]
|
|
public static TimeSpan AccessThreshold;
|
|
|
|
// Token: 0x040075A7 RID: 30119
|
|
[Token(Token = "0x40075A7")]
|
|
private static List<Cookie> Cookies;
|
|
|
|
// Token: 0x040075AA RID: 30122
|
|
[Token(Token = "0x40075AA")]
|
|
private static object Locker;
|
|
|
|
// Token: 0x040075AB RID: 30123
|
|
[Token(Token = "0x40075AB")]
|
|
private static bool _isSavingSupported;
|
|
|
|
// Token: 0x040075AC RID: 30124
|
|
[Token(Token = "0x40075AC")]
|
|
private static bool IsSupportCheckDone;
|
|
|
|
// Token: 0x040075AD RID: 30125
|
|
[Token(Token = "0x40075AD")]
|
|
private static bool Loaded;
|
|
}
|
|
}
|