Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/vcpkg/base/contractual-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ namespace vcpkg
inline constexpr StringLiteral EnvironmentVariableHome = "HOME";
inline constexpr StringLiteral EnvironmentVariableHttpProxy = "HTTP_PROXY";
inline constexpr StringLiteral EnvironmentVariableHttpsProxy = "HTTPS_PROXY";
inline constexpr StringLiteral EnvironmentVariableNoProxy = "NO_PROXY";
inline constexpr StringLiteral EnvironmentVariableInclude = "INCLUDE";
inline constexpr StringLiteral EnvironmentVariableJenkinsHome = "JENKINS_HOME";
inline constexpr StringLiteral EnvironmentVariableJenkinsUrl = "JENKINS_URL";
Expand Down
21 changes: 18 additions & 3 deletions src/tls12-download.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ static void set_delete_on_close_flag(const HANDLE std_out, const HANDLE target,

// these are sucked out to avoid
// warning C6262: Function uses '98624' bytes of stack. Consider moving some data to heap.
static wchar_t https_proxy_env[32767];
static wchar_t https_proxy_env[32768];
static wchar_t no_proxy_env[32768];
static char buffer[32768];

#ifndef NDEBUG
Expand Down Expand Up @@ -210,12 +211,10 @@ int __stdcall entry()

DWORD access_type;
const wchar_t* proxy_setting;
const wchar_t* proxy_bypass_setting;
if (GetEnvironmentVariableW(L"HTTPS_PROXY", https_proxy_env, sizeof(https_proxy_env) / sizeof(wchar_t)))
{
access_type = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
proxy_setting = https_proxy_env;
proxy_bypass_setting = L"<local>";
Copy link
Member

Choose a reason for hiding this comment

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

I observe tls12-download said <local> while the main product said nullptr; I think x-download is more widely used and thus want to resolve conflicts in favor of it, so I changed this one to nullptr.

write_message(std_out, L" (using proxy: ");
write_message(std_out, proxy_setting);
write_message(std_out, L")");
Expand All @@ -224,6 +223,22 @@ int __stdcall entry()
{
access_type = WINHTTP_ACCESS_TYPE_NO_PROXY;
proxy_setting = WINHTTP_NO_PROXY_NAME;
}
else
{
abort_api_failure(std_out, L"GetEnvironmentVariableW");
}

const wchar_t* proxy_bypass_setting;
if (GetEnvironmentVariableW(L"NO_PROXY", no_proxy_env, sizeof(no_proxy_env) / sizeof(wchar_t)))
{
proxy_bypass_setting = no_proxy_env;
write_message(std_out, L" (using proxy bypass: ");
write_message(std_out, no_proxy_env);
write_message(std_out, L")");
}
else if (GetLastError() == ERROR_ENVVAR_NOT_FOUND)
{
proxy_bypass_setting = WINHTTP_NO_PROXY_BYPASS;
}
else
Expand Down
15 changes: 14 additions & 1 deletion src/vcpkg/base/downloads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,20 @@ namespace vcpkg
WINHTTP_PROXY_INFO proxy;
proxy.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
proxy.lpszProxy = env_proxy_settings.data();
proxy.lpszProxyBypass = nullptr;

// Try to get bypass list from environment variable
auto maybe_no_proxy_env = get_environment_variable(EnvironmentVariableNoProxy);
std::wstring env_noproxy_settings;
if (auto p_no_proxy = maybe_no_proxy_env.get())
{
env_noproxy_settings = Strings::to_utf16(*p_no_proxy);
proxy.lpszProxyBypass = env_noproxy_settings.data();
}
else
{
proxy.lpszProxyBypass = nullptr;
}

if (!m_hSession.SetOption(context, sanitized_url, WINHTTP_OPTION_PROXY, &proxy, sizeof(proxy)))
{
return false;
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/base/system.process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ namespace vcpkg
// Enables proxy information to be passed to Curl, the underlying download library in cmake.exe
"http_proxy",
"https_proxy",
"no_proxy",
// Environment variables to tell git to use custom SSH executable or command
"GIT_SSH",
"GIT_SSH_COMMAND",
Expand Down