-
Notifications
You must be signed in to change notification settings - Fork 809
Feature: Firewall app #3378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Feature: Firewall app #3378
Changes from 106 commits
Commits
Show all changes
110 commits
Select commit
Hold shift + click to select a range
66c672f
Fix null deref in FileNameValidator and BooleansOrConverter. Use Gene…
fcddf1b
BindingProxy: Docs and use nameof.
4525d29
Add and set ValidationErrorTemplate for CheckBoxes.
d6fdd8f
Fix obvious typo in ChildWindowStyles restricting the window height t…
39a6c6a
Reuse FileExistsValidator in EmptyOrFileExistsValidator.
c9e73e5
ListHelper: code documentation and refactoring of Modify as generic. …
f58adf9
PowershellHelper: Support commands exceeding the command line limit o…
9023d2d
NetworkInterfaceView: Fix all warnings.
42530bd
ProfileChildWindow: Remove size limit for wider content.
5e2411c
Add NetworkProfile enum and a property for later use in NetworkInterf…
34e7047
Add NETworkManager.Interfaces project to avoid certain circular refer…
80a33d0
Add generic converter for DataGrid column collapsing, checking proper…
53ea911
Add converter to use size factors in XAML.
9064595
Add ValidationHelper to convert ViewModel HasError states to style ch…
99fe27b
Add converters for localized enum conversion (int, string).
adb2920
Add empty variants of FilePath and Int32 validators.
3d29a0b
Fix 2 warnings in ProfilesView. Scnr.
65969a5
Add localization strings for Firewall application. Separate commit to…
be56e92
Add Firewall application.
f92d09b
Firewall App PR: Replace changelog pr placeholder with actual pr number.
ef95654
Add powershell argument quote sanitizing in Firewall model.
86a013a
Merge branch 'main' into firewall-pr
BornToBeRoot b61a90f
RuleGrid style improvements.
e24e3cf
Add missing referenced rule configuration screenshot.
1ab5284
Merge remote-tracking branch 'origin/firewall-pr' into firewall-pr
3877c87
Merge branch 'BornToBeRoot:main' into firewall-pr
1cdcd85
Add Firewall application.
05a8484
Firewall App PR: Replace changelog pr placeholder with actual pr number.
620172b
Fix null deref in FileNameValidator and BooleansOrConverter. Use Gene…
d9874ac
BindingProxy: Docs and use nameof.
e278f2c
Add and set ValidationErrorTemplate for CheckBoxes.
339c00b
Fix obvious typo in ChildWindowStyles restricting the window height t…
4acd64d
Reuse FileExistsValidator in EmptyOrFileExistsValidator.
47ac311
ListHelper: code documentation and refactoring of Modify as generic. …
70402b2
PowershellHelper: Support commands exceeding the command line limit o…
65edb6b
NetworkInterfaceView: Fix all warnings.
002e2e8
ProfileChildWindow: Remove size limit for wider content.
d2ab9b4
Add NetworkProfile enum and a property for later use in NetworkInterf…
d3385d8
Add NETworkManager.Interfaces project to avoid certain circular refer…
ac54782
Add generic converter for DataGrid column collapsing, checking proper…
2bd1ea5
Add converter to use size factors in XAML.
233819e
Add ValidationHelper to convert ViewModel HasError states to style ch…
1a17ee9
Add converters for localized enum conversion (int, string).
49589ab
Add empty variants of FilePath and Int32 validators.
bade2cc
Fix 2 warnings in ProfilesView. Scnr.
5a30d37
Add localization strings for Firewall application. Separate commit to…
e6098c0
Add Firewall application.
9d29586
Firewall App PR: Replace changelog pr placeholder with actual pr number.
3113c7c
Add powershell argument quote sanitizing in Firewall model.
3c9071c
RuleGrid style improvements.
f1e46f5
Add missing referenced rule configuration screenshot.
47579fe
Add Firewall application.
98c32ea
Firewall App PR: Replace changelog pr placeholder with actual pr number.
5b7c406
Fix merge going wrong somewhere inbetween a rebase.
1f98439
Merge remote-tracking branch 'origin/firewall-pr' into firewall-pr
9732cc5
Fix another merge error in Strings.Designer.cs
2f7e59d
Add localization strings for Firewall application. Separate commit to…
ef2bc36
Add Firewall application.
8c845cb
Firewall App PR: Replace changelog pr placeholder with actual pr number.
8e1694b
Add Firewall application.
28860d5
Firewall App PR: Replace changelog pr placeholder with actual pr number.
78cc251
Fix another merge error in Strings.Designer.cs
2bfed92
Revert language changes - they are handled by transifex
BornToBeRoot 0f866f3
Add localization strings for Firewall application. Separate commit to…
e4cb7eb
Add Firewall application.
cdf2ca7
Firewall App PR: Replace changelog pr placeholder with actual pr number.
8dd4613
Revert language changes - they are handled by transifex
BornToBeRoot facc504
Fix: Duplicate string due to rebase
BornToBeRoot 8bde342
Apply "dotnet format ."
BornToBeRoot b665322
Upgrade version
BornToBeRoot fdf5b06
Reorder Firewall icon / Add some summary blocks
BornToBeRoot 8a3f550
Copilot fixes
BornToBeRoot 059b0d4
Documentation page fixed for firewall, hosts file editor and web console
BornToBeRoot c091724
Merge branch 'main' into firewall-pr
4436522
Merge remote-tracking branch 'origin/firewall-pr' into firewall-pr
6586af1
Rediscard auto-merged Czech translation.
60e1332
Address copy-paste error in typed binding proxies.
baf2f9d
Unsubscribe CommandExecuted event in ProfileChildWindow.
1beef14
Unsubscribe CommandExecuted event in FirewallView.
c0017ea
Fix logic bug in EmptyOrFirewallPortRangeValidator.
c18114b
Remove changelog entry, duplicated due to merge.
e78e03a
Trim input in PortRangeToPortSpecificationConverter.
cc44d76
FirewallView: Make ViewModel initialization null safe.
e3cef76
Explain, why MaxLengthHistory handling is just fine.
709210d
Fix another auto-merge issue. This is *slightly* tedious. ;)
b854cbe
Chore: Refactoring
BornToBeRoot b227470
Update ApplicationName.cs
BornToBeRoot a3d56c7
Update NetworkInterfaceInfo.cs
BornToBeRoot 7258cef
Restore language files from main branch
BornToBeRoot b1a4cf2
Update FirewallView.xaml
BornToBeRoot 02b94cd
Reformat
BornToBeRoot cc5c8bd
Update FirewallView.xaml
BornToBeRoot ffa0c2d
Fix FirewallRuleProgram de-/serialization issue, probably introduced …
163c844
Reorder Firewall content to match ProfileName. Fixes invalid applicat…
54136da
Update documentation screenshots for new FirewallView design.
a76cd00
Allow horizontal buttons to wrap and minimize used space.
2d3364d
Refactoring settings
BornToBeRoot 83b6f2c
Chore: Use field key (Refactored via Rider)
BornToBeRoot 82322d1
Chore: Refactoring
BornToBeRoot ea787f8
Chore: Create CLAUDE.md and reference AGENTS.md
BornToBeRoot 0d4e7ef
Chore: Fix bug for sntp tabs / make it generic
BornToBeRoot 5ce349f
Chore: Refactor buttons
BornToBeRoot 804e874
Merge branch 'main' into feature/firewall
BornToBeRoot 9d7fd69
Feature: Firewall
BornToBeRoot 7af4428
Merge branch 'main' into feature/firewall
BornToBeRoot 9024e98
Fix: Dialog view
BornToBeRoot 9b5cb11
Docs: Reorder app sidebar
BornToBeRoot 65d15cd
Merge branch 'main' into feature/firewall
BornToBeRoot 9146e0b
Merge branch 'main' into feature/firewall
BornToBeRoot da4aca8
Merge branch 'main' into feature/firewall
BornToBeRoot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| See [AGENTS.md](AGENTS.md) for project guidelines and conventions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| See [AGENTS.md](../AGENTS.md) in the repository root for project guidelines and conventions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
Source/NETworkManager.Converters/BoolArrayToFwRuleCategoriesConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| using System; | ||
| using System.Globalization; | ||
| using System.Linq; | ||
| using System.Windows.Data; | ||
| using NETworkManager.Models.Network; | ||
| using NETworkManager.Localization.Resources; | ||
|
|
||
|
|
||
| namespace NETworkManager.Converters; | ||
|
|
||
| public class BoolArrayToFwRuleCategoriesConverter : IValueConverter | ||
| { | ||
| public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
| { | ||
| if (targetType != typeof(string)) return null; | ||
| const int expectedLength = 3; | ||
| var fallback = GetTranslation(Enum.GetName(NetworkProfiles.NotConfigured), false); | ||
| if (value is not bool[] { Length: expectedLength } boolArray) | ||
| return fallback; | ||
| var result = string.Empty; | ||
| var numSelected = boolArray.CountAny(true); | ||
| switch (numSelected) | ||
| { | ||
| case 0: | ||
| return fallback; | ||
| case < 2: | ||
| return GetTranslation(Enum.GetName(typeof(NetworkProfiles), | ||
| Array.FindIndex(boolArray, b => b)), false); | ||
| } | ||
|
|
||
| if (boolArray.All(b => b)) | ||
| return Strings.All; | ||
|
|
||
| for (var i = 0; i < expectedLength; i++) | ||
| { | ||
| if (boolArray[i]) | ||
| result += $", {GetTranslation(Enum.GetName(typeof(NetworkProfiles), i), true)}"; | ||
| } | ||
|
|
||
| return result[2..]; | ||
|
|
||
| } | ||
|
|
||
| public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| private static string GetTranslation(string key, bool trimmed) | ||
| { | ||
| return Strings.ResourceManager.GetString(trimmed ? $"{key}_Short3" : key, Strings.Culture); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
Source/NETworkManager.Converters/CollectionPropertyBooleanOrConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| using System; | ||
| using System.Collections.Concurrent; | ||
| using System.Collections.Generic; | ||
| using System.Globalization; | ||
| using System.Reflection; | ||
| using System.Windows.Data; | ||
| using NETworkManager.Interfaces.ViewModels; | ||
|
|
||
| namespace NETworkManager.Converters | ||
| { | ||
| /// <summary> | ||
| /// A generic converter that checks a property of items in a collection. | ||
| /// If ANY item's property is considered "present" (not null, not empty), it returns Visible. | ||
| /// </summary> | ||
| /// <typeparam name="T">The type of item in the collection.</typeparam> | ||
| public class CollectionPropertyBooleanOrConverter<T> : IValueConverter | ||
| { | ||
| public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
| { | ||
| // 1. Validate inputs | ||
| if (value is not IEnumerable<T> collection) | ||
| return false; | ||
|
|
||
| if (parameter is not string propertyName || string.IsNullOrEmpty(propertyName)) | ||
| return false; | ||
|
|
||
| // 2. Get PropertyInfo via Reflection or cache. | ||
| if (!Cache.TryGetValue(propertyName, out var propertyInfo)) | ||
| { | ||
| propertyInfo = typeof(T).GetProperty(propertyName); | ||
| Cache.TryAdd(propertyName, propertyInfo); | ||
| } | ||
|
|
||
| if (propertyInfo == null) | ||
| return false; | ||
|
|
||
| // 3. Iterate collection and check property | ||
| foreach (var item in collection) | ||
| { | ||
| if (item == null) continue; | ||
|
|
||
| var propValue = propertyInfo.GetValue(item); | ||
|
|
||
| if (propValue is true) | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
|
|
||
| public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| private ConcurrentDictionary<string, PropertyInfo> Cache { get; } = new(); | ||
| } | ||
|
|
||
| // Concrete implementation for XAML usage | ||
| public class FirewallRuleViewModelBooleanOrConverter : CollectionPropertyBooleanOrConverter<IFirewallRuleViewModel>; | ||
| } | ||
|
|
90 changes: 90 additions & 0 deletions
90
Source/NETworkManager.Converters/CollectionPropertyVisibilityConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| using System; | ||
| using System.Collections; | ||
| using System.Collections.Concurrent; | ||
| using System.Collections.Generic; | ||
| using System.Globalization; | ||
| using System.Reflection; | ||
| using System.Windows; | ||
| using System.Windows.Data; | ||
| using NETworkManager.Interfaces.ViewModels; | ||
|
|
||
| namespace NETworkManager.Converters | ||
| { | ||
| /// <summary> | ||
| /// A generic converter that checks a property of items in a collection. | ||
| /// If ANY item's property is considered "present" (not null, not empty), it returns Visible. | ||
| /// </summary> | ||
| /// <typeparam name="T">The type of item in the collection.</typeparam> | ||
| public class CollectionPropertyVisibilityConverter<T> : IValueConverter | ||
| { | ||
| public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
| { | ||
| // 1. Validate inputs | ||
| if (value is not IEnumerable<T> collection) | ||
| return Visibility.Collapsed; | ||
|
|
||
| if (parameter is not string propertyName || string.IsNullOrEmpty(propertyName)) | ||
| return Visibility.Collapsed; | ||
|
|
||
| // 2. Get PropertyInfo via Reflection or cache. | ||
| if (!Cache.TryGetValue(propertyName, out var propertyInfo)) | ||
| { | ||
| propertyInfo = typeof(T).GetProperty(propertyName); | ||
| Cache.TryAdd(propertyName, propertyInfo); | ||
| } | ||
|
|
||
| if (propertyInfo == null) | ||
| return Visibility.Collapsed; | ||
|
|
||
| // 3. Iterate collection and check property | ||
| foreach (var item in collection) | ||
| { | ||
| if (item == null) continue; | ||
|
|
||
| var propValue = propertyInfo.GetValue(item); | ||
|
|
||
| if (HasContent(propValue)) | ||
| { | ||
| return Visibility.Visible; | ||
| } | ||
| } | ||
|
|
||
| return Visibility.Collapsed; | ||
| } | ||
|
|
||
| private static bool HasContent(object value) | ||
| { | ||
| if (value == null) return false; | ||
|
|
||
| // Handle Strings | ||
| if (value is string str) | ||
| return !string.IsNullOrWhiteSpace(str); | ||
|
|
||
| // Handle Collections (Lists, Arrays, etc.) | ||
| if (value is ICollection col) | ||
| return col.Count > 0; | ||
|
|
||
| // Handle Generic Enumerable (fallback) | ||
| if (value is IEnumerable enumValue) | ||
| { | ||
| var enumerator = enumValue.GetEnumerator(); | ||
| var result = enumerator.MoveNext(); // Has at least one item | ||
| (enumerator as IDisposable)?.Dispose(); | ||
| return result; | ||
| } | ||
|
|
||
| // Default: If it's an object and not null, it's "True" | ||
| return true; | ||
| } | ||
|
|
||
| public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| private ConcurrentDictionary<string, PropertyInfo> Cache { get; } = new(); | ||
| } | ||
|
|
||
| // Concrete implementation for XAML usage | ||
| public class FirewallRuleViewModelVisibilityConverter : CollectionPropertyVisibilityConverter<IFirewallRuleViewModel>; | ||
| } |
34 changes: 34 additions & 0 deletions
34
Source/NETworkManager.Converters/EmptyToIntMaxValueConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| using System; | ||
| using System.Globalization; | ||
| using System.Windows.Data; | ||
|
|
||
| namespace NETworkManager.Converters; | ||
|
|
||
| public class EmptyToIntMaxValueConverter : IValueConverter | ||
| { | ||
| public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
| { | ||
| const int fallback = int.MaxValue; | ||
| if (targetType == typeof(int)) | ||
| { | ||
| if (value is not string strValue) | ||
| return fallback; | ||
| if (string.IsNullOrWhiteSpace(strValue)) | ||
| return fallback; | ||
| if (!int.TryParse(strValue, out int parsedIntValue)) | ||
| return fallback; | ||
| return parsedIntValue; | ||
| } | ||
|
|
||
| if (targetType != typeof(string)) | ||
| return null; | ||
| if (value is not int intValue) | ||
| return null; | ||
| return intValue is fallback ? string.Empty : intValue.ToString(); | ||
| } | ||
|
|
||
| public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
| { | ||
| return Convert(value, targetType, parameter, culture); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| using System; | ||
| using System.Globalization; | ||
| using System.Windows.Data; | ||
|
|
||
|
|
||
| namespace NETworkManager.Converters; | ||
|
|
||
| /// <summary> | ||
| /// A value converter that facilitates the conversion between enumeration values and their corresponding integer indices or string names. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// This converter is designed to either: | ||
| /// - Convert an enumeration value to its integer index within the enumeration. | ||
| /// - Convert an enumeration value to its string representation. | ||
| /// When converting back, the same logic is applied to handle appropriate conversion. | ||
| /// </remarks> | ||
| public class EnumToIntConverter : IValueConverter | ||
| { | ||
| /// <summary> | ||
| /// Converts an Enum value to its corresponding integer index or string representation | ||
| /// based on the target type. If the target type is an Enum, the method attempts | ||
| /// to return the name of the enum value. If the provided value is an Enum, it | ||
| /// returns the integer index of the value within the Enum's definition. | ||
| /// </summary> | ||
| /// <param name="value">The value to convert. This can be an Enum instance or null.</param> | ||
| /// <param name="targetType">The target type for the conversion. Typically either Enum or int.</param> | ||
| /// <param name="parameter">An optional parameter for additional input, not used in this method.</param> | ||
| /// <param name="culture">The culture information for the conversion process.</param> | ||
| /// <returns> | ||
| /// If the targetType is an Enum, a string representation of the Enum name is returned. | ||
| /// If the value is an Enum, the integer index of the Enum value is returned. | ||
| /// If neither condition is met, null is returned. | ||
| /// </returns> | ||
| public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
| { | ||
| if (targetType.IsEnum) | ||
| { | ||
| return value is null ? string.Empty : | ||
| Enum.GetName(targetType, value); | ||
| } | ||
| if (value is Enum enumVal) | ||
| { | ||
| return Array.IndexOf(Enum.GetValues(enumVal.GetType()), enumVal); | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| /// Converts a value back into its corresponding enumeration value or integer representation. | ||
| /// This method is typically used in two-way data bindings where an integer or string needs | ||
| /// to be converted back to the corresponding enum value. | ||
| /// <param name="value">The value to be converted back. This can be an integer or a string representation of an enumeration value.</param> | ||
| /// <param name="targetType">The type of the target object, typically the type of the enumeration.</param> | ||
| /// <param name="parameter">An optional parameter for the conversion. Not used in this implementation.</param> | ||
| /// <param name="culture">The culture information to use during the conversion process.</param> | ||
| /// <return>The enumeration value corresponding to the input value.</return> | ||
| public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
| { | ||
| return Convert(value, targetType, parameter, culture); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
With
ConvertBackcallingConvert, converting an int back to an enum will hittargetType.IsEnumand return a string enum name rather than an enum value. This will break two-way bindings. ConvertBack should map an index/name back to an enum value (e.g., Enum.GetValues(targetType).GetValue(index) or Enum.Parse) and return the enum instance.