-
Notifications
You must be signed in to change notification settings - Fork 7.1k
MWB: Firewall for subnet only should be configured according to setting value #39492
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
Conversation
This comment has been minimized.
This comment has been minimized.
is this respecting the group policy too? |
Good catch, you are right, we should use a higher level wrapper instead of the raw property to consider the gpo. |
When user clicks the button to switch 'same subnet only' option, we should at least let users know that they need to click another button to make it work in firewall, use #39574 to track |
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.
Pull Request Overview
This PR updates the firewall rule configuration for MouseWithoutBorders so that the subnet-only option is only applied when explicitly enabled.
- Updated the SendCustomAction method signature to include an optional value parameter and modified AddFirewallRule accordingly.
- Adjusted the firewall rule launch process to conditionally add the subnet restriction based on the provided parameter.
- Updated the spell-check expectations to include the new "samesubnetonly" parameter name.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/settings-ui/Settings.UI/ViewModels/MouseWithoutBordersViewModel.cs | Added an optional parameter to SendCustomAction and updated AddFirewallRule to conditionally append the subnet-only flag. |
src/modules/MouseWithoutBorders/ModuleInterface/dllmain.cpp | Modified the firewall process launcher to accept parameters and conditionally include the subnet restriction. |
.github/actions/spell-check/expect.txt | Added "samesubnetonly" to the list of allowed words for spell-checking. |
Comments suppressed due to low confidence (1)
.github/actions/spell-check/expect.txt:1413
- [nitpick] Verify that the naming convention for 'samesubnetonly' remains consistent across the codebase; consider aligning with the property name if necessary.
samesubnetonly
var param = string.Empty; | ||
if (SameSubnetOnly) | ||
{ | ||
param += "-samesubnetonly"; | ||
} | ||
|
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.
[nitpick] Consider using a more scalable approach (such as a collection or an argument builder) to construct command parameters in case additional flags need to be appended in the future.
var param = string.Empty; | |
if (SameSubnetOnly) | |
{ | |
param += "-samesubnetonly"; | |
} | |
var parameters = new List<string>(); | |
if (SameSubnetOnly) | |
{ | |
parameters.Add("-samesubnetonly"); | |
} | |
var param = string.Join(" ", parameters); |
Copilot uses AI. Check for mistakes.
@@ -567,7 +567,16 @@ class MouseWithoutBorders : public PowertoyModuleIface | |||
executable_args.append(L"\" & echo \"Adding an inbound firewall rule for PowerToys.MouseWithoutBorders.exe\""); | |||
executable_args.append(L" & netsh advfirewall firewall add rule name=\"PowerToys.MouseWithoutBorders\" dir=in action=allow program=\""); | |||
executable_args.append(executable_path); | |||
executable_args.append(L"\" enable=yes remoteip=LocalSubnet profile=any protocol=tcp & pause\""); | |||
|
|||
std::wstring extra_rule_params = L""; |
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.
[nitpick] Consider adding a comment to clarify the purpose of the '-samesubnetonly' flag to improve code readability for future maintainers.
std::wstring extra_rule_params = L""; | |
std::wstring extra_rule_params = L""; | |
// If the '-samesubnetonly' flag is present, restrict the firewall rule to apply only to devices on the same subnet. |
Copilot uses AI. Check for mistakes.
Offline talked with @yeelam-gordon , instead of adding such firewall, and maintain a copy of logic in code to check subnet, we more intend to maintain the subnet control in code, so the fix should be just delete the subnet toggle in firewall set up |
390c868
to
75121ca
Compare
Summary of the Pull Request
We should not configure subnet only if user explicitly set the option to false
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
Subnetonly toggle to off


Subnet only toggle to on: