Skip to content

Commit 60ea54e

Browse files
committed
chores and cleanups (guard checks, etc)
1 parent 617d3ab commit 60ea54e

File tree

5 files changed

+54
-48
lines changed

5 files changed

+54
-48
lines changed

CS2ServerPicker/App.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
Environment.NewLine +
132132
"Author: FN-FAL113 (github username)" + Environment.NewLine +
133133
"License: GNU General Public License V3" + Environment.NewLine +
134-
"App Version: 2.4.0",
134+
"App Version: 2.4.1",
135135
"App Info"
136136
)
137137
End Sub

CS2ServerPicker/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices
3232
' by using the '*' as shown below:
3333
' <Assembly: AssemblyVersion("1.0.*")>
3434

35-
<Assembly: AssemblyVersion("2.4.0.0")>
36-
<Assembly: AssemblyFileVersion("2.4.0.0")>
35+
<Assembly: AssemblyVersion("2.4.1.0")>
36+
<Assembly: AssemblyFileVersion("2.4.1.0")>
3737
<Assembly: NeutralResourcesLanguage("en")>

CS2ServerPicker/Services/DataGridViewService.vb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
Module DataGridViewService
22

3-
' cache server flag image to prevent unnecessary requests
4-
53
Public Sub Load_Server_List()
64
Dim serverDict As Dictionary(Of String, String) = IIf(App.Get_Is_Clustered(), App.Get_Server_Dictionary_Clustered(), App.Get_Server_Dictionary_Unclustered)
75

CS2ServerPicker/Services/ErrorService.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Module ErrorService
44
Public Sub Log_Exception_To_File(exception As Exception, errorFrom As String)
5-
File.AppendAllText(System.AppDomain.CurrentDomain.BaseDirectory + "error_" + DateTimeOffset.Now.ToUnixTimeSeconds.ToString() + ".txt",
5+
File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "error_" + DateTimeOffset.Now.ToUnixTimeSeconds.ToString() + ".txt",
66
errorFrom + Environment.NewLine + exception.Message)
77
End Sub
88
End Module

CS2ServerPicker/Settings.vb

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,66 +13,74 @@
1313
Private Sub ResetFirewallButton_Click(sender As Object, e As EventArgs) Handles ResetFirewallButton.Click
1414
Dim resetWindowsFirewallRes As DialogResult = MessageBox.Show("This will attempt to reset windows firewall to its default state. Confirm action?", "Reset Windows Firewall", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
1515

16-
If resetWindowsFirewallRes = DialogResult.Yes Then
17-
Try
18-
Dim proc As Process = Create_Custom_CMD_Process()
16+
If resetWindowsFirewallRes = DialogResult.No Then
17+
Return
18+
End If
1919

20-
proc.StartInfo.Arguments = "/c netsh advfirewall reset"
21-
proc.Start()
22-
proc.WaitForExit()
20+
Try
21+
Dim proc As Process = Create_Custom_CMD_Process()
2322

24-
If proc.ExitCode = 1 Or proc.ExitCode < 0 Then
25-
Throw New Exception("Sdtout: " + proc.StandardOutput.ReadToEnd() + Environment.NewLine + "Stderr: " + proc.StandardError.ReadToEnd())
26-
End If
23+
proc.StartInfo.Arguments = "/c netsh advfirewall reset"
24+
proc.Start()
25+
proc.WaitForExit()
2726

28-
MessageBox.Show("Windows firewall reset successful!", "Reset Windows Firewall", MessageBoxButtons.OK, MessageBoxIcon.Information)
27+
If proc.ExitCode = 1 Or proc.ExitCode < 0 Then
28+
Throw New Exception("Sdtout: " + proc.StandardOutput.ReadToEnd() + Environment.NewLine + "Stderr: " + proc.StandardError.ReadToEnd())
29+
End If
2930

30-
proc.Dispose()
31-
Catch ex As Exception
32-
Log_Exception_To_File(ex, "An error has occurred while resetting windows firewall!")
31+
MessageBox.Show("Windows firewall reset successful!", "Reset Windows Firewall", MessageBoxButtons.OK, MessageBoxIcon.Information)
3332

34-
MessageBox.Show("An error has occurred while resetting windows firewall!", "Error")
35-
End Try
36-
End If
33+
proc.Dispose()
34+
Catch ex As Exception
35+
Log_Exception_To_File(ex, "An error has occurred while resetting windows firewall!")
36+
37+
MessageBox.Show("An error has occurred while resetting windows firewall!", "Error")
38+
End Try
3739
End Sub
3840

3941
Private Sub CheckFirewallButton_Click(sender As Object, e As EventArgs) Handles CheckFirewallButton.Click
4042
Dim checkWindowsFirewallRes As DialogResult = MessageBox.Show("This will attempt to check current state of windows firewall. Confirm action?", "Check Windows Firewall", MessageBoxButtons.YesNo, MessageBoxIcon.Information)
4143

42-
If checkWindowsFirewallRes = DialogResult.Yes Then
43-
Try
44-
Dim proc As Process = Create_Custom_CMD_Process()
44+
If checkWindowsFirewallRes = DialogResult.No Then
45+
Return
46+
End If
4547

46-
proc.StartInfo.Arguments = "/c netsh advfirewall show allprofiles state"
47-
proc.Start()
48-
proc.WaitForExit()
48+
Try
49+
Dim proc As Process = Create_Custom_CMD_Process()
4950

50-
If proc.ExitCode = 1 Or proc.ExitCode < 0 Then
51-
Throw New Exception("On firewall check" + Environment.NewLine + "StdOut: " + proc.StandardOutput.ReadToEnd() + Environment.NewLine + "StdErr: " + proc.StandardError.ReadToEnd())
52-
End If
51+
proc.StartInfo.Arguments = "/c netsh advfirewall show allprofiles state"
52+
proc.Start()
53+
proc.WaitForExit()
5354

54-
If proc.StandardOutput.ReadToEnd().Contains("OFF") Then
55-
Dim enableWinFirewallRes As DialogResult = MessageBox.Show("This will attempt to enable windows firewall. Confirm action?", "Enable Windows Firewall", MessageBoxButtons.YesNo, MessageBoxIcon.Information)
55+
If proc.ExitCode = 1 Or proc.ExitCode < 0 Then
56+
Throw New Exception("On firewall check" + Environment.NewLine + "StdOut: " + proc.StandardOutput.ReadToEnd() + Environment.NewLine + "StdErr: " + proc.StandardError.ReadToEnd())
57+
End If
5658

57-
proc.StartInfo.Arguments = "/c netsh advfirewall set allprofiles state on"
58-
proc.Start()
59-
proc.WaitForExit()
59+
If proc.StandardOutput.ReadToEnd().Contains("OFF") Then
60+
Dim enableWinFirewallRes As DialogResult = MessageBox.Show("This will attempt to enable windows firewall. Confirm action?", "Enable Windows Firewall", MessageBoxButtons.YesNo, MessageBoxIcon.Information)
6061

61-
If proc.ExitCode = 1 Or proc.ExitCode < 0 Then
62-
Throw New Exception("On firewall enable" + Environment.NewLine + "StdOut: " + proc.StandardOutput.ReadToEnd() + Environment.NewLine + "StdErr: " + proc.StandardError.ReadToEnd())
63-
End If
62+
If enableWinFirewallRes = DialogResult.No Then
63+
Return
64+
End If
6465

65-
MessageBox.Show("Windows firewall profile states successfully enabled!", "Enable Windows Firewall", MessageBoxButtons.OK, MessageBoxIcon.Information)
66-
Else
67-
MessageBox.Show("Windows firewall profile states are all enabled.", "Windows Firewall Status", MessageBoxButtons.OK, MessageBoxIcon.Information)
66+
proc.StartInfo.Arguments = "/c netsh advfirewall set allprofiles state on"
67+
proc.Start()
68+
proc.WaitForExit()
69+
70+
If proc.ExitCode = 1 Or proc.ExitCode < 0 Then
71+
Throw New Exception("On firewall enable" + Environment.NewLine + "StdOut: " + proc.StandardOutput.ReadToEnd() + Environment.NewLine + "StdErr: " + proc.StandardError.ReadToEnd())
6872
End If
6973

70-
proc.Dispose()
71-
Catch ex As Exception
72-
Log_Exception_To_File(ex, "An error has occurred while checking/enabling windows firewall!")
74+
MessageBox.Show("Windows firewall profile states successfully enabled!", "Enable Windows Firewall", MessageBoxButtons.OK, MessageBoxIcon.Information)
75+
Else
76+
MessageBox.Show("Windows firewall profile states are all enabled.", "Windows Firewall Status", MessageBoxButtons.OK, MessageBoxIcon.Information)
77+
End If
7378

74-
MessageBox.Show("An error has occurred while checking/enabling windows firewall!", "Error")
75-
End Try
76-
End If
79+
proc.Dispose()
80+
Catch ex As Exception
81+
Log_Exception_To_File(ex, "An error has occurred while checking/enabling windows firewall!")
82+
83+
MessageBox.Show("An error has occurred while checking/enabling windows firewall!", "Error")
84+
End Try
7785
End Sub
7886
End Class

0 commit comments

Comments
 (0)