Skip to content

Commit

Permalink
Fixing the Status screen & InstallHelper implementation (uninstall is…
Browse files Browse the repository at this point in the history
… still in progress). Notifier activation should now be more explicit.

Also improved the MainWindow layout a bit.
  • Loading branch information
wokhan committed Nov 9, 2020
1 parent b5ab3ad commit ee0e03f
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 240 deletions.
16 changes: 8 additions & 8 deletions Common/Net/WFP/FirewallHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,28 +332,28 @@ public static string GetCurrentProfileAsText()
return Rule.GetProfileAsText(GetCurrentProfile());
}

public static void UpdatePrivatePolicy(bool enable, bool blockInbound, bool blockOutbound, bool enableNotifBlocked)
public static void UpdatePrivatePolicy(bool enable, bool blockInbound, bool blockOutbound, bool disableInNotif)
{
UpdatePolicy(NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_PRIVATE, enable, blockInbound, blockOutbound, enableNotifBlocked);
UpdatePolicy(NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_PRIVATE, enable, blockInbound, blockOutbound, disableInNotif);
}

public static void UpdatePublicPolicy(bool enable, bool blockInbound, bool blockOutbound, bool enableNotifBlocked)
public static void UpdatePublicPolicy(bool enable, bool blockInbound, bool blockOutbound, bool disableInNotif)
{
UpdatePolicy(NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_PUBLIC, enable, blockInbound, blockOutbound, enableNotifBlocked);
UpdatePolicy(NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_PUBLIC, enable, blockInbound, blockOutbound, disableInNotif);
}

public static void UpdateDomainPolicy(bool enable, bool blockInbound, bool blockOutbound, bool enableNotifBlocked)
public static void UpdateDomainPolicy(bool enable, bool blockInbound, bool blockOutbound, bool disableInNotif)
{
UpdatePolicy(NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_DOMAIN, enable, blockInbound, blockOutbound, enableNotifBlocked);
UpdatePolicy(NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_DOMAIN, enable, blockInbound, blockOutbound, disableInNotif);
}


private static void UpdatePolicy(NET_FW_PROFILE_TYPE2_ profile, bool enable, bool blockInbound, bool blockOutbound, bool enableNotifBlocked)
private static void UpdatePolicy(NET_FW_PROFILE_TYPE2_ profile, bool enable, bool blockInbound, bool blockOutbound, bool disableInNotif)
{
firewallPolicy.FirewallEnabled[profile] = enable;
firewallPolicy.DefaultInboundAction[profile] = blockInbound ? NET_FW_ACTION_.NET_FW_ACTION_BLOCK : NET_FW_ACTION_.NET_FW_ACTION_ALLOW;
firewallPolicy.DefaultOutboundAction[profile] = blockOutbound ? NET_FW_ACTION_.NET_FW_ACTION_BLOCK : NET_FW_ACTION_.NET_FW_ACTION_ALLOW;
firewallPolicy.NotificationsDisabled[profile] = enableNotifBlocked;
firewallPolicy.NotificationsDisabled[profile] = disableInNotif;
}

public enum Status
Expand Down
2 changes: 1 addition & 1 deletion Common/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Common/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ This application has NOT been totally disabled.</value>
<value>Note: if you don't know what a profile is all about, the private one usually refers to your home network, while the public one is for public places (restaurant, hotels...). A domain profile is usually for workplaces.</value>
</data>
<data name="Status_FooterRemark" xml:space="preserve">
<value>* WFN is notified everytime an outgoing connection is blocked by the windows firewall. Notifications are shown in Notifier or alternatively in the security log menu. The recommended setting is "Block and prompt" for all profiles.</value>
<value>* WFN is notified everytime an outgoing connection is blocked by the windows firewall. Notifications are shown in Notifier or alternatively in the security log menu. Enabling this option is recommended since you wouldn't get notified at all otherwise.</value>
</data>
<data name="Status_WindowsFirewallGlobalStatus" xml:space="preserve">
<value>Windows firewall global status</value>
Expand Down
19 changes: 10 additions & 9 deletions Console/Helpers/InstallHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public static bool InstallCheck(Func<Func<bool>, string, string, bool> checkResu

if (Settings.Default.StartNotifierAfterLogin)
{
if (!checkResult(() => CreateNotifierTask(), $"{Resources.MSG_INST_OK} Notitifer auto-start after login enabled.", Resources.MSG_INST_TASK_ERR)) return false;
if (!checkResult(CreateNotifierTask, $"{Resources.MSG_INST_OK} Notifier has been enabled and will start on user's login.", Resources.MSG_INST_TASK_ERR)) return false;
}
else
{
if (!checkResult(() => RemoveNotifierTask(), $"{Resources.MSG_INST_OK} Notifier auto-start disabled.", Resources.MSG_UNINST_TASK_ERR)) return false;
if (!checkResult(RemoveNotifierTask, $"{Resources.MSG_UNINST_OK} Notifier has been disabled. You will not get any notification!", Resources.MSG_UNINST_TASK_ERR)) return false;
}

Settings.Default.Save();
Expand Down Expand Up @@ -68,7 +68,7 @@ public static bool Install([param: NotNull] Func<Func<bool>, string, string, boo

if (Settings.Default.StartNotifierAfterLogin)
{
if (!checkResult(() => CreateNotifierTask(), "Notifier will start after next windows login", Resources.MSG_INST_TASK_ERR)) return false;
if (!checkResult(CreateNotifierTask, "Notifier will start after next windows login", Resources.MSG_INST_TASK_ERR)) return false;
}

if (!checkResult(() => (ProcessHelper.GetProcessFeedback(
Expand All @@ -81,20 +81,21 @@ public static bool Install([param: NotNull] Func<Func<bool>, string, string, boo
, "Audit policy enabled."
, Resources.MSG_INST_ENABLE_LOG_ERR)) return false;

if (!checkResult(() => FirewallHelper.EnableWindowsFirewall()
, "Windows firewall enabled."
, Resources.MSG_INST_ENABLE_FW_ERR)) return false;
if (!checkResult(FirewallHelper.EnableWindowsFirewall, "Windows firewall enabled.", Resources.MSG_INST_ENABLE_FW_ERR)) return false;

if (!checkResult(() => CreateDefaultRules()
, Resources.MSG_INST_OK
, "Unable to create the default windows firewall rules.")) return false;
if (!checkResult(CreateDefaultRules, Resources.MSG_INST_OK, "Unable to create the default windows firewall rules.")) return false;

Settings.Default.IsInstalled = true;
Settings.Default.Save();

return true;
}

public static bool Uninstall([param: NotNull] Func<Func<bool>, string, string, bool> checkResult)
{
return checkResult(RemoveNotifierTask, "Disabling automatic startup", "Unable to disable automatic startup");
}

public static bool SetAuditPolConnection(bool enableSuccess, bool enableFailure)
{
string successOption = enableSuccess ? "/success:enable" : "/success:disable";
Expand Down
6 changes: 3 additions & 3 deletions Console/UI/Pages/Connections.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
<DataGrid.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Style TargetType="GroupItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<ControlTemplate TargetType="GroupItem">
<StackPanel>
<StackPanel.Resources>
<SolidColorBrush x:Key="color" Color="{Binding Color}" x:Shared="false" />
<SolidColorBrush x:Key="color" Color="{Binding Color}" />
</StackPanel.Resources>
<Grid Background="White" DataContext="{Binding Items[0]}">
<Grid.ColumnDefinitions>
Expand Down
5 changes: 3 additions & 2 deletions Console/UI/Pages/Options.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
<Label Content="Notifier settings" Style="{StaticResource SectionHeader}" />
<StackPanel Margin="10">
<TextBlock Margin="0,0,0,10" TextWrapping="Wrap" Text="The following options only apply if you chose 'Block and prompt' for the outgoing connections in the Firewall settings page, as they target the WFN notification window." />
<CheckBox Padding="5,0" Content="Use an animated notification" Margin="0,0,22,10.2" IsChecked="{Binding UseAnimation,Mode=TwoWay}" />
<CheckBox Padding="5,0" Content="Enable services detection*" ToolTip="Additionally tries to detect the service making a connection in the notifier." IsChecked="{Binding EnableServiceDetection,Mode=TwoWay}" IsEnabled="{Binding IsElevated,Source={x:Static Application.Current}}" />
<CheckBox Padding="3" Content="Start minimized" IsChecked="{Binding StartNotifierMinimized, Source={x:Static settings:Settings.Default}}" />
<CheckBox Padding="3" Content="Use an animated notification" IsChecked="{Binding UseAnimation,Mode=TwoWay}" />
<CheckBox Padding="3" Content="Enable services detection*" ToolTip="Additionally tries to detect the service making a connection in the notifier." IsChecked="{Binding EnableServiceDetection,Mode=TwoWay}" IsEnabled="{Binding IsElevated,Source={x:Static Application.Current}}" />
<Button x:Name="btnTestNotif" Click="btnTestNotif_Click" HorizontalAlignment="Center" ext:CustomAdorner.Image="/Wokhan.WindowsFirewallNotifier.Common;component/Resources/Notifier.ico" Content="Start Notifier now" />
</StackPanel>
<Label Content="Miscellaneous options" Style="{StaticResource SectionHeader}" />
Expand Down
Loading

0 comments on commit ee0e03f

Please sign in to comment.