Files
niko c12fbe3fc6 m
2026-04-12 16:51:38 +02:00

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: 0x020020A0 RID: 8352
[Token(Token = "0x20020A0")]
public static class CookieJar
{
// Token: 0x1700216C RID: 8556
// (get) Token: 0x0600D1F8 RID: 53752 RVA: 0x002FF43C File Offset: 0x002FD63C
[Token(Token = "0x1700216C")]
public static bool IsSavingSupported
{
[Token(Token = "0x600D1F8")]
[Address(RVA = "0x2408650", Offset = "0x2407650", VA = "0x182408650")]
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: 0x1700216D RID: 8557
// (get) Token: 0x0600D1F9 RID: 53753 RVA: 0x002FF480 File Offset: 0x002FD680
// (set) Token: 0x0600D1FA RID: 53754 RVA: 0x002FF494 File Offset: 0x002FD694
[Token(Token = "0x1700216D")]
private static string CookieFolder
{
[Token(Token = "0x600D1F9")]
[Address(RVA = "0x2408590", Offset = "0x2407590", VA = "0x182408590")]
get;
[Token(Token = "0x600D1FA")]
[Address(RVA = "0x24089A0", Offset = "0x24079A0", VA = "0x1824089A0")]
set;
}
// Token: 0x1700216E RID: 8558
// (get) Token: 0x0600D1FB RID: 53755 RVA: 0x002FF4A8 File Offset: 0x002FD6A8
// (set) Token: 0x0600D1FC RID: 53756 RVA: 0x002FF4BC File Offset: 0x002FD6BC
[Token(Token = "0x1700216E")]
private static string LibraryPath
{
[Token(Token = "0x600D1FB")]
[Address(RVA = "0x24088E0", Offset = "0x24078E0", VA = "0x1824088E0")]
get;
[Token(Token = "0x600D1FC")]
[Address(RVA = "0x2408A00", Offset = "0x2407A00", VA = "0x182408A00")]
set;
}
// Token: 0x0600D1FD RID: 53757 RVA: 0x002FF4D0 File Offset: 0x002FD6D0
[Token(Token = "0x600D1FD")]
[Address(RVA = "0x2408220", Offset = "0x2407220", VA = "0x182408220")]
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: 0x0600D1FE RID: 53758 RVA: 0x002FF524 File Offset: 0x002FD724
[Token(Token = "0x600D1FE")]
[Address(RVA = "0x2407DB0", Offset = "0x2406DB0", VA = "0x182407DB0")]
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: 0x0600D1FF RID: 53759 RVA: 0x0000220F File Offset: 0x0000040F
[Token(Token = "0x600D1FF")]
[Address(RVA = "0x2406D90", Offset = "0x2405D90", VA = "0x182406D90")]
internal static void Maintain()
{
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
}
// Token: 0x0600D200 RID: 53760 RVA: 0x002FF634 File Offset: 0x002FD834
[Token(Token = "0x600D200")]
[Address(RVA = "0x2407260", Offset = "0x2406260", VA = "0x182407260")]
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: 0x0600D201 RID: 53761 RVA: 0x002FF73C File Offset: 0x002FD93C
[Token(Token = "0x600D201")]
[Address(RVA = "0x24066E0", Offset = "0x24056E0", VA = "0x1824066E0")]
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: 0x0600D202 RID: 53762 RVA: 0x002FF854 File Offset: 0x002FDA54
[Token(Token = "0x600D202")]
[Address(RVA = "0x2406460", Offset = "0x2405460", VA = "0x182406460")]
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: 0x0600D203 RID: 53763 RVA: 0x002FF8EC File Offset: 0x002FDAEC
[Token(Token = "0x600D203")]
[Address(RVA = "0x2407B90", Offset = "0x2406B90", VA = "0x182407B90")]
public static void Set(Uri uri, Cookie cookie)
{
CookieJar.Set(cookie);
}
// Token: 0x0600D204 RID: 53764 RVA: 0x002FF900 File Offset: 0x002FDB00
[Token(Token = "0x600D204")]
[Address(RVA = "0x2407BF0", Offset = "0x2406BF0", VA = "0x182407BF0")]
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: 0x0600D205 RID: 53765 RVA: 0x002FF944 File Offset: 0x002FDB44
[Token(Token = "0x600D205")]
[Address(RVA = "0x2406350", Offset = "0x2405350", VA = "0x182406350")]
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: 0x0600D206 RID: 53766 RVA: 0x002FF974 File Offset: 0x002FDB74
[Token(Token = "0x600D206")]
[Address(RVA = "0x2405C70", Offset = "0x2404C70", VA = "0x182405C70")]
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: 0x0600D207 RID: 53767 RVA: 0x002FF9AC File Offset: 0x002FDBAC
[Token(Token = "0x600D207")]
[Address(RVA = "0x2405D90", Offset = "0x2404D90", VA = "0x182405D90")]
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: 0x0600D208 RID: 53768 RVA: 0x002FFA28 File Offset: 0x002FDC28
[Token(Token = "0x600D208")]
[Address(RVA = "0x2406000", Offset = "0x2405000", VA = "0x182406000")]
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: 0x0600D209 RID: 53769 RVA: 0x002FFA94 File Offset: 0x002FDC94
[Token(Token = "0x600D209")]
[Address(RVA = "0x2407910", Offset = "0x2406910", VA = "0x182407910")]
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: 0x0600D20A RID: 53770 RVA: 0x002FFB24 File Offset: 0x002FDD24
[Token(Token = "0x600D20A")]
[Address(RVA = "0x2406240", Offset = "0x2405240", VA = "0x182406240")]
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: 0x0600D20B RID: 53771 RVA: 0x002FFB5C File Offset: 0x002FDD5C
// Note: this type is marked as 'beforefieldinit'.
[Token(Token = "0x600D20B")]
[Address(RVA = "0x24084D0", Offset = "0x24074D0", VA = "0x1824084D0")]
static CookieJar()
{
TimeSpan timeSpan;
CookieJar.AccessThreshold = timeSpan;
CookieJar.Cookies = new List();
CookieJar.Locker = new object();
}
// Token: 0x040085A1 RID: 34209
[Token(Token = "0x40085A1")]
private const int Version = 1;
// Token: 0x040085A2 RID: 34210
[Token(Token = "0x40085A2")]
public static TimeSpan AccessThreshold;
// Token: 0x040085A3 RID: 34211
[Token(Token = "0x40085A3")]
private static List<Cookie> Cookies;
// Token: 0x040085A6 RID: 34214
[Token(Token = "0x40085A6")]
private static object Locker;
// Token: 0x040085A7 RID: 34215
[Token(Token = "0x40085A7")]
private static bool _isSavingSupported;
// Token: 0x040085A8 RID: 34216
[Token(Token = "0x40085A8")]
private static bool IsSupportCheckDone;
// Token: 0x040085A9 RID: 34217
[Token(Token = "0x40085A9")]
private static bool Loaded;
}
}