-
Notifications
You must be signed in to change notification settings - Fork 109
Added method to check if firewall blocks .cs files #1261
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -494,5 +494,34 @@ private static string GetHash(string filePath, HashAlgorithm algorithm) | |
| return BitConverter.ToString(hash).Replace("-", string.Empty).ToLower(); | ||
| } | ||
| } | ||
|
|
||
| private static bool FirewallBlocking() | ||
| { | ||
| 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"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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.