-
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?
Conversation
// 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"); |
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 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 statusCode = (int)response.StatusCode; | ||
switch (statusCode) | ||
{ | ||
case 401: |
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 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.
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 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.
@@ -494,5 +494,34 @@ private static string GetHash(string filePath, HashAlgorithm algorithm) | |||
return BitConverter.ToString(hash).Replace("-", string.Empty).ToLower(); | |||
} | |||
} | |||
|
|||
private static bool FirewallBlocking() |
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.
This is for issue: #1063
This adds a method to the CSharp plugin compiler to check if a client's proxy/firewall prevents downloading CSharp source files.
The changes compile and matches the formatting conventions and standards used.
Points to consider and limitations; The method needs to be invoked. I wasn't sure where to call it from, so I left it uncalled. This could be used extension wide to check all filetypes instead of just CSharp Files. If that is desired it will need to be moved outside the plugin compiler (I believe) and we will need to upload a file of each type somewhere and test each one inside the method.