-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathNetworkSettings.cpp
More file actions
68 lines (61 loc) · 1.95 KB
/
NetworkSettings.cpp
File metadata and controls
68 lines (61 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#include "winget/NetworkSettings.h"
#include "winget/AdminSettings.h"
#include "AppInstallerLogging.h"
namespace AppInstaller::Settings
{
void NetworkSettings::SetProxyUri(const std::optional<std::string>& proxyUri)
{
AICLI_LOG(Core, Info, << "Setting proxy");
if (proxyUri)
{
m_proxyUri = proxyUri.value();
AICLI_LOG(Core, Info, << "New value for proxy is " << m_proxyUri.value());
}
else
{
m_proxyUri.reset();
AICLI_LOG(Core, Info, << "Proxy will not be used");
}
}
InstallerDownloader NetworkSettings::GetInstallerDownloader() const
{
// The default is DeliveryOptimization.
// We use WinINet if specified by settings, or if we want to use proxy (as DO does not support that)
InstallerDownloader setting = User().Get<Setting::NetworkDownloader>();
if (m_proxyUri && setting != InstallerDownloader::WinInet)
{
AICLI_LOG(Core, Info, << "Forcing use of wininet for download as DO does not support proxy");
return InstallerDownloader::WinInet;
}
else if (setting == InstallerDownloader::Default)
{
return InstallerDownloader::DeliveryOptimization;
}
else
{
return setting;
}
}
NetworkSettings::NetworkSettings()
{
// Get the default proxy
try
{
m_proxyUri = GetAdminSetting(StringAdminSetting::DefaultProxy);
}
CATCH_LOG()
AICLI_LOG(Core, Info, << "Default proxy is " << (m_proxyUri ? m_proxyUri.value() : "not set"));
}
NetworkSettings& NetworkSettings::Instance()
{
static NetworkSettings networkSettings;
return networkSettings;
}
NetworkSettings& Network()
{
return NetworkSettings::Instance();
}
}