forked from devedse/DeveLanCacheUI_Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLanCacheLogEntryRaw.cs
More file actions
106 lines (100 loc) · 3.62 KB
/
Copy pathLanCacheLogEntryRaw.cs
File metadata and controls
106 lines (100 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
namespace DeveLanCacheUI_Backend.LogReading.Models
{
public class LanCacheLogEntryRaw
{
//0
public required string CacheIdentifier { get; init; }
//1
public string RemoteAddress { get; init; }
//2 random slash
//3
public string ForwardedFor { get; init; }
//4 random dash
//5
public string RemoteUser { get; init; }
//6
public string TimeLocal { get; init; }
//7
public string Request { get; init; }
//8
public string Status { get; init; }
//9
public string BodyBytesSent { get; init; }
//10
public string Referer { get; init; }
//11
public string UserAgent { get; init; }
//12
public string UpstreamCacheStatus { get; init; }
//13
public string Host { get; init; }
//14
public string HttpRange { get; init; }
public required string OriginalLogLine { get; init; }
public string ParseException { get; init; }
public DateTime DateTime { get; private set; }
public long BodyBytesSentLong { get; private set; }
public string? DownloadIdentifier { get; private set; }
public void CalculateFields()
{
DateTime = DateTime.ParseExact(TimeLocal, "dd/MMM/yyyy:HH:mm:ss zzz", CultureInfo.InvariantCulture);
BodyBytesSentLong = long.Parse(BodyBytesSent);
if (CacheIdentifier == "steam")
{
var urlPart = Request.Split(' ')[1];
var splittedUrl = urlPart.Split('/');
if (splittedUrl[1] == "depot")
{
DownloadIdentifier = splittedUrl[2];
}
else
{
throw new InvalidOperationException($"Could not parse SteamDepotId from {Request}");
}
}
else if (CacheIdentifier == "blizzard")
{
var urlPart = Request.Split(' ')[1];
var splittedUrl = urlPart.Split('/');
if (splittedUrl.Length >= 3 && splittedUrl[2].StartsWith("bnt"))
{
splittedUrl[2] = "bnt";
}
DownloadIdentifier = string.Join("/", splittedUrl.Skip(1).Take(2));
}
else if (CacheIdentifier == "epicgames")
{
var urlPart = Request.Split(' ')[1];
var splittedUrl = urlPart.Split('/');
if (splittedUrl.Length >= 3 && splittedUrl[1] == "Builds")
{
DownloadIdentifier = splittedUrl[2];
}
else
{
throw new InvalidOperationException($"Could not parse epicgamesProjectID from {Request}. URL part: {urlPart}");
}
}
else if (CacheIdentifier == "riot")
{
DownloadIdentifier = "unknown";
}
else if (CacheIdentifier == "xboxlive")
{
var urlPart = Request.Split(' ')[1];
var lastPart = urlPart.Split('/').Last();
//BehaviourInteractive.DeadbyDaylightWindows_7.0.200.0_x64__b1gz2xhdanwfm.msixvc
var lastPartSplitted = lastPart.Split('_');
DownloadIdentifier = lastPartSplitted.First();
}
else if (CacheIdentifier == "wsus")
{
DownloadIdentifier = "unknown";
}
else
{
DownloadIdentifier = "UnknownDownloadIdentifier";
}
}
}
}