Skip to content

Commit

Permalink
Final touches
Browse files Browse the repository at this point in the history
  • Loading branch information
DubyaDude committed Jun 15, 2020
1 parent 7d7d726 commit 3041f1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class Actions
//This endpoint is no longer up/used
//"stats.unity3d.com"

private static string[] analyticsURLs = new string[]
private static readonly string[] analyticsURLs = new string[]
{
"api.amplitude.com", //This is VRChat specific
"api.uca.cloud.unity3d.com",
Expand All @@ -26,23 +26,23 @@ public static class Actions
"data-optout-service.uca.cloud.unity3d.com"
};

private static string HostsFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "drivers/etc/");
private static string HostsFile = Path.Combine(HostsFolder, "hosts");
private static readonly string HostsFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "drivers/etc/");
private static readonly string HostsFile = Path.Combine(HostsFolder, "hosts");

public static void ModifyAnalyticsBlocking(bool isBlocking)
{
Output.WriteLine("====================================================================================");
try
{
List<string> hostsFile = getHostsFile();
List<string> hostsFile = GetHostsFile();
List<string> hostsFileEdited = new List<string>(hostsFile);

if (isBlocking)
BlockAnalytics(hostsFile, ref hostsFileEdited);
else
UnblockAnalytics(hostsFile, ref hostsFileEdited);

saveHostsFile(hostsFileEdited);
SaveHostsFile(hostsFileEdited);
}
catch(Exception e)
{
Expand Down Expand Up @@ -151,13 +151,13 @@ public static void UnblockAnalytics(List<string> hostsFile, ref List<string> hos
}
}

private static void saveHostsFile(List<string> lines)
private static void SaveHostsFile(List<string> lines)
{
File.WriteAllLines(HostsFile, lines);
Output.WriteLine(ConsoleColor.Green, $"\nSaved 'hosts' file");
}

private static List<string> getHostsFile()
private static List<string> GetHostsFile()
{
if (Directory.Exists(HostsFolder))
{
Expand Down
3 changes: 3 additions & 0 deletions VRChat Analytics Blocker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
<PropertyGroup>
<ApplicationIcon>dubya.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>VRChat_Analytics_Blocker.Runner</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="Costura, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll</HintPath>
Expand Down

0 comments on commit 3041f1d

Please sign in to comment.