Skip to content
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

Add support for proxies #190 #4203

Merged
merged 34 commits into from Mar 14, 2024
Merged

Add support for proxies #190 #4203

merged 34 commits into from Mar 14, 2024

Conversation

florelis
Copy link
Member

@florelis florelis commented Feb 26, 2024

For #190
See spec on #4152
See #1776 for a related PR for the feature with the core implementation for proxies in wininet

This PR adds basic support for using proxies. Most of the changes are for enabling the configuration and blocking of the feature. This feature will be gated behind an experimental feature setting

  • Added Group Policy and Admin settings for enabling/disabling the use of proxy CLI arguments and for setting a default proxy.
    • Pending: Internal review for new Group Policy
    • Extended AdminSettings to support settings with string values, instead of only bool flags. The implementation is mostly a copy of the bool case. In the future we should look back at it to reduce duplication of code.
    • Added a set subcommand to settings that can set the admin settings
  • Added CLI arguments to select a proxy on each different invocation of winget, or to disable the use of a default one.
  • Updated calls to wininet and cpprestsdk to use the provided proxy, and added plumbing to get the arguments from the command line to the point of use.
  • Changed the flow around downloads to force winget to use proxies if available.

Manually tested on a VM using mitmproxy
Pending: Adding automated tests tests.

Microsoft Reviewers: Open in CodeFlow

@florelis florelis marked this pull request as ready for review February 27, 2024 20:27
@florelis florelis requested a review from a team as a code owner February 27, 2024 20:27
src/AppInstallerCLICore/ExecutionContextData.h Outdated Show resolved Hide resolved
doc/admx/en-US/DesktopAppInstaller.adml Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/NetworkSettings.cpp Outdated Show resolved Hide resolved
src/AppInstallerRepositoryCore/Rest/RestSourceFactory.cpp Outdated Show resolved Hide resolved
switch (setting)
{
case AppInstaller::Settings::StringAdminSetting::DefaultProxy:
return GroupPolicies().GetValueRef<ValuePolicy::DefaultProxy>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just double check, if DefaultProxy group policy is not set. The return will be std::nullopt? Why there's a reference_wrapper needed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, GroupPolicies().GetValue*() returns std::nullopt if the policy is not set.
Unless I'm misunderstanding what it does, the reference_wrapper allows us to return a reference of the value instead of copying it. That is the behavior I would expect if we were able to do std::optional<std::string&>.

src/AppInstallerCLICore/Commands/SettingsCommand.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Commands/SettingsCommand.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Workflows/WorkflowBase.cpp Outdated Show resolved Hide resolved
florelis and others added 4 commits March 14, 2024 13:32
Co-authored-by: yao-msft <50888816+yao-msft@users.noreply.github.com>
Co-authored-by: yao-msft <50888816+yao-msft@users.noreply.github.com>
@florelis florelis merged commit 7cea3d9 into microsoft:master Mar 14, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants