Skip to content
Closed
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
19 changes: 14 additions & 5 deletions src/vcpkg/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,14 @@ namespace vcpkg::Build
* Visual Studio, we even cannot set HTTP(S)_PROXY in CLI, if we want to open or close Proxy we need to
* restart VS.
*/

// 2021-05-09 Fix: Detect If there's already HTTP(S)_PROXY presented in the environment variables.
// If so, we no longer overwrite them.
bool proxy_from_env = (System::get_environment_variable("HTTP_PROXY").has_value() ||
System::get_environment_variable("HTTPS_PROXY").has_value());

auto ieProxy = System::get_windows_ie_proxy_server();
if (ieProxy.has_value())
if (ieProxy.has_value() && !proxy_from_env)
{
std::string server = Strings::to_utf8(ieProxy.get()->server);

Expand All @@ -424,10 +430,9 @@ namespace vcpkg::Build
{
auto protocol = kvp[0];
auto address = kvp[1];
if (!Strings::contains(address, "://"))
{
address = Strings::concat(protocol, "://", address);
}
// No longer append protocol prefix to address. Because HTTPS_PROXY's address is not always
// an HTTPS proxy, an HTTP proxy can also proxy HTTPS requests without end-to-end security
// (As an HTTP Proxy can see your cleartext while an HTTPS proxy can't).
protocol = Strings::concat(Strings::ascii_to_uppercase(protocol.c_str()), "_PROXY");
env.emplace(protocol, address);
System::print2("-- Setting ", protocol, " environment variables to ", address, "\n");
Expand Down Expand Up @@ -460,6 +465,10 @@ namespace vcpkg::Build
env.emplace("HTTPS_PROXY", server.c_str());
}
}
else if (proxy_from_env)
{
System::print2("-- Using HTTP(S)_PROXY in environment variables.\n");
}
return {env};
});

Expand Down
27 changes: 19 additions & 8 deletions src/vcpkg/registries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ namespace
}

std::string m_repo;
std::string m_baseline_identifier;
mutable std::string m_baseline_identifier;
DelayedInit<LockFile::Entry> m_lock_entry;
mutable Optional<fs::path> m_stale_versions_tree;
DelayedInit<fs::path> m_versions_tree;
Expand Down Expand Up @@ -558,13 +558,24 @@ namespace
{
auto e = get_lock_entry(paths);
e.ensure_up_to_date(paths);
Checks::exit_maybe_upgrade(
VCPKG_LINE_INFO,
"Error: the git registry entry for \"%s\" must have a \"baseline\" field that is a valid git "
"commit SHA (40 lowercase hexadecimal characters).\n"
"The current HEAD of that repo is \"%s\".\n",
m_repo,
e.value());
std::string latest_commit_sha = e.value();

// For easy use, please just considering HEAD as 'use latest'.
if (Strings::equals(m_baseline_identifier, "HEAD"))
{
m_baseline_identifier = latest_commit_sha;
System::print2("Using HEAD commit SHA ", latest_commit_sha, " for git registry ", m_repo, ".\n");
}
else
{
Checks::exit_maybe_upgrade(
VCPKG_LINE_INFO,
"Error: the git registry entry for \"%s\" must have a \"baseline\" field that is a valid git "
"commit SHA (40 lowercase hexadecimal characters).\n"
"The current HEAD of that repo is \"%s\".\n",
m_repo,
e.value());
}
}

auto path_to_baseline = registry_versions_dir_name / fs::u8path("baseline.json");
Expand Down