-
Notifications
You must be signed in to change notification settings - Fork 3
/
DialNineProcessor.cs
52 lines (39 loc) · 1.52 KB
/
DialNineProcessor.cs
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
// Copyright (c) 2023 Fox Council - VintageHive - https://github.com/FoxCouncil/VintageHive
using VintageHive.Proxy.Http;
namespace VintageHive.Processors;
internal static class DialNineProcessor
{
static readonly IReadOnlyList<string> BlockedDomains = new List<string> {
"ssl.google-analytics.com",
"www.google-analytics.com"
};
static readonly IReadOnlyList<string> StrippedDomains = new List<string>
{
"oocities.com"
};
public static async Task<bool> ProcessHttpsRequest(HttpRequest req, HttpResponse res)
{
if (!Mind.Db.ConfigLocalGet<bool>(req.ListenerSocket.RemoteIP, ConfigNames.ServiceDialnine))
{
return false;
}
if (BlockedDomains.Contains(req.Host.ToLower()))
{
Log.WriteLine(Log.LEVEL_INFO, nameof(DialNineProcessor), $"Blocking Domain -> {req.Host}", req.ListenerSocket.TraceId.ToString());
return false;
}
try
{
await res.SetExternal();
Log.WriteLine(Log.LEVEL_INFO, nameof(DialNineProcessor), $"Forwarding to external -> {req.Uri}", req.ListenerSocket.TraceId.ToString());
}
catch (Exception e)
{
// Custom Error Messages
Log.WriteLine(Log.LEVEL_ERROR, nameof(DialNineProcessor), e.Message, req.ListenerSocket.TraceId.ToString());
res.ErrorMessage = e.Message + "<br><br>" + e.InnerException?.Message ?? "";
res.SetNotFound();
}
return true;
}
}