Skip to content
This repository was archived by the owner on Oct 7, 2019. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Extensions/Oxide.CSharp/PluginCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,5 +494,34 @@ private static string GetHash(string filePath, HashAlgorithm algorithm)
return BitConverter.ToString(hash).Replace("-", string.Empty).ToLower();
}
}

private static bool FirewallBlocking()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think an entire method is needed, just check for a valid HTTP code in the existing downloading methods.

{
try
{
// we can use any url below that contains a CSharp source file.
var request =
(HttpWebRequest)WebRequest.Create(
$"https://devdrop.blob.core.windows.net/downloads/FirewallTest.cs");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't use a random plugin from a site that isn't controlled by us, there are plugins available on https://github.com/umods such as DevTest, though I don't see why this would help test this at all.

var response = (HttpWebResponse)request.GetResponse();
var statusCode = (int)response.StatusCode;
switch (statusCode)
{
case 401:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how checking for a valid response code would test if web requests are being blocked. If anything, you'd want no response or a response of 0.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested using squid & squidguard on my PFSense firewall. It gave 403 when denied, or 401 when set to required login/password for bypass. Other firewalls/content filters may display different behaviors.

Interface.Oxide.LogWarning($"Download required proxy login (code {statusCode})");
return true;
case 403:
Interface.Oxide.LogWarning($"Download was denied (code {statusCode})");
return true;
}
}
catch (Exception ex)
{
Interface.Oxide.LogError($"Something went wrong when testing firewall blocking");
Interface.Oxide.LogError(ex.Message);
}

return false;
}
}
}