Skip to content

Commit

Permalink
Merge pull request #93 from Psiphon-Inc/v170
Browse files Browse the repository at this point in the history
V170
  • Loading branch information
adamkruger authored Dec 7, 2021
2 parents 1a8e600 + 6744afa commit 90bcdce
Show file tree
Hide file tree
Showing 24 changed files with 493 additions and 347 deletions.
2 changes: 1 addition & 1 deletion i18n/transifex_pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def pull_app_translations():
# We need to run grunt to incorporate the new translations
print('Running grunt...')
os.chdir('../src/webui')
subprocess.run(['npx', 'grunt'], shell=True, check=True)
subprocess.run('npx grunt', shell=True, check=True)


def go():
Expand Down
Binary file modified src/3rdParty/psicash/Debug2015/psicash.lib
Binary file not shown.
Binary file modified src/3rdParty/psicash/Debug2015/psicash.pdb
Binary file not shown.
Binary file modified src/3rdParty/psicash/Release2015/psicash.lib
Binary file not shown.
2 changes: 1 addition & 1 deletion src/3rdParty/psicash/git.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.1.2-0-gd0f74c9
v2.2.0-0-g613169d
2 changes: 1 addition & 1 deletion src/3rdParty/psicash/psicash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class PsiCash {

/// Set values that will be included in the request metadata. This includes
/// client_version, client_region, sponsor_id, and propagation_channel_id.
error::Error SetRequestMetadataItem(const std::string& key, const std::string& value);
error::Error SetRequestMetadataItems(const std::map<std::string, std::string>& items);

/// Set current UI locale.
error::Error SetLocale(const std::string& locale);
Expand Down
Binary file modified src/3rdParty/psiphon-tunnel-core.exe
Binary file not shown.
37 changes: 29 additions & 8 deletions src/coretransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ void CoreTransport::TransportConnectHelper()

if (!WriteParameterFiles(in, out))
{
throw TransportFailed();
my_print(NOT_SENSITIVE, true, _T("%s:%d - WriteParameterFiles failed: %d"), __TFUNCTION__, __LINE__, GetLastError());
throw TransportFailed(false);
}

// Once a new upgrade has been paved, CoreTransport should never restart without the actual application restarting.
Expand All @@ -276,7 +277,8 @@ void CoreTransport::TransportConnectHelper()

if (!SpawnCoreProcess(out.configFilePath, out.serverListFilename))
{
throw TransportFailed();
my_print(NOT_SENSITIVE, true, _T("%s:%d - SpawnCoreProcess failed: %d"), __TFUNCTION__, __LINE__, GetLastError());
throw TransportFailed(false);
}

// Wait and poll for first active tunnel (or stop signal)
Expand Down Expand Up @@ -326,29 +328,48 @@ void CoreTransport::TransportConnectHelper()

bool CoreTransport::SpawnCoreProcess(const tstring& configFilename, const tstring& serverListFilename)
{
tstringstream commandLineFlags;
tstring exePath;
filesystem::path tempPath;
if (!GetSysTempPath(tempPath)) {
my_print(NOT_SENSITIVE, true, _T("%s:%d - GetSysTempPath failed: %d"), __TFUNCTION__, __LINE__, GetLastError());
return false;
}

filesystem::path exePath;
if (RequestingUrlProxyWithoutTunnel())
{
exePath = tempPath / URL_PROXY_EXE_NAME;

// In RequestingUrlProxyWithoutTunnel mode, we allow for multiple instances
// so we don't fail extract if the file already exists -- and don't try to
// kill any associated process holding a lock on it.
if (!ExtractExecutable(
IDR_PSIPHON_TUNNEL_CORE_EXE, URL_PROXY_EXE_NAME, exePath, true))
if (!ExtractExecutable(IDR_PSIPHON_TUNNEL_CORE_EXE, exePath, true))
{
my_print(NOT_SENSITIVE, true, _T("%s:%d - ExtractExecutable failed: %d"), __TFUNCTION__, __LINE__, GetLastError());

// This string contains PII (the username in the temp path) but won't be logged
auto errorDetail = WStringToUTF8(exePath.tstring() + L"\n\n" + SystemErrorMessage(GetLastError()));
UI_Notice("PsiphonUI::FileError", errorDetail);

return false;
}
}
else
{
if (!ExtractExecutable(
IDR_PSIPHON_TUNNEL_CORE_EXE, EXE_NAME, exePath))
exePath = tempPath / EXE_NAME;

if (!ExtractExecutable(IDR_PSIPHON_TUNNEL_CORE_EXE, exePath))
{
my_print(NOT_SENSITIVE, true, _T("%s:%d - ExtractExecutable failed: %d"), __TFUNCTION__, __LINE__, GetLastError());

// This string contains PII (the username in the temp path) but won't be logged
auto errorDetail = WStringToUTF8(exePath.tstring() + L"\n\n" + SystemErrorMessage(GetLastError()));
UI_Notice("PsiphonUI::FileError", errorDetail);

return false;
}
}

tstringstream commandLineFlags;
commandLineFlags << _T(" --config \"") << configFilename << _T("\"");

if (!RequestingUrlProxyWithoutTunnel())
Expand Down
16 changes: 4 additions & 12 deletions src/diagnostic_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "usersettings.h"
#include "config.h"
#include "psicashlib.h"
#include <VersionHelpers.h>

#pragma warning(push, 0)
#pragma warning(disable: 4244)
Expand Down Expand Up @@ -135,7 +136,6 @@ bool GetUserGroupInfo(UserGroupInfo& groupInfo)
HANDLE hToken = NULL;
HANDLE hTokenToCheck = NULL;
DWORD cbSize = 0;
OSVERSIONINFO osver = { sizeof(osver) };

// Open the primary access token of the process for query and duplicate.
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_DUPLICATE,
Expand All @@ -145,18 +145,10 @@ bool GetUserGroupInfo(UserGroupInfo& groupInfo)
goto Cleanup;
}

// Determine whether system is running Windows Vista or later operating
// systems (major version >= 6) because they support linked tokens, but
// previous versions (major version < 6) do not.
if (!GetVersionEx(&osver))
// Windows Vista or later operating systems (major version >= 6) support
// linked tokens, but previous versions (major version < 6) do not.
if (IsWindowsVistaOrGreater())
{
dwError = GetLastError();
goto Cleanup;
}

if (osver.dwMajorVersion >= 6)
{
// Running Windows Vista or later (major version >= 6).
// Determine token type: limited, elevated, or default.
TOKEN_ELEVATION_TYPE elevType;
if (!GetTokenInformation(hToken, TokenElevationType, &elevType,
Expand Down
19 changes: 15 additions & 4 deletions src/feedback_upload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,26 @@ void FeedbackUpload::SendFeedbackHelper()

bool FeedbackUpload::SpawnFeedbackUploadProcess(const tstring& configFilename, const string& diagnosticData)
{
tstringstream commandLineFlags;
tstring exePath;
filesystem::path tempPath;
if (!GetSysTempPath(tempPath)) {
my_print(NOT_SENSITIVE, true, _T("%s:%d - GetSysTempPath failed: %d"), __TFUNCTION__, __LINE__, GetLastError());
return false;
}

auto exePath = tempPath / EXE_NAME;

if (!ExtractExecutable(
IDR_PSIPHON_TUNNEL_CORE_EXE, EXE_NAME, exePath))
if (!ExtractExecutable(IDR_PSIPHON_TUNNEL_CORE_EXE, exePath))
{
my_print(NOT_SENSITIVE, true, _T("%s:%d - ExtractExecutable failed: %d"), __TFUNCTION__, __LINE__, GetLastError());

// This string contains PII (the username in the temp path) but won't be logged
auto errorDetail = WStringToUTF8(exePath.tstring() + L"\n\n" + SystemErrorMessage(GetLastError()));
UI_Notice("PsiphonUI::FileError", errorDetail);

return false;
}

tstringstream commandLineFlags;
commandLineFlags << _T(" --config \"") << configFilename << _T("\" --feedbackUpload");

m_psiphonTunnelCore = make_unique<PsiphonTunnelCore>(this, exePath);
Expand Down
10 changes: 9 additions & 1 deletion src/local_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,15 @@ bool LocalProxy::DoStart()
{
if (m_polipoPath.size() == 0)
{
if (!ExtractExecutable(IDR_POLIPO_EXE, POLIPO_EXE_NAME, m_polipoPath))
filesystem::path tempPath;
if (!GetSysTempPath(tempPath)) {
my_print(NOT_SENSITIVE, true, _T("%s:%d - GetSysTempPath failed: %d"), __TFUNCTION__, __LINE__, GetLastError());
return false;
}

m_polipoPath = tempPath / POLIPO_EXE_NAME;

if (!ExtractExecutable(IDR_POLIPO_EXE, m_polipoPath))
{
return false;
}
Expand Down
24 changes: 8 additions & 16 deletions src/psicashlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,13 @@ error::Error Lib::Init(bool forceReset) {
return WrapError(err, "PsiCash::Init failed");
}

err = PsiCash::SetRequestMetadataItem("client_version", CLIENT_VERSION);
err = PsiCash::SetRequestMetadataItems({
{"client_version", CLIENT_VERSION},
{"propagation_channel_id", PROPAGATION_CHANNEL_ID},
{"sponsor_id", SPONSOR_ID},
{"client_region", WStringToUTF8(GetDeviceRegion())} });
if (err) {
return WrapError(err, "SetRequestMetadataItem failed");
}
err = PsiCash::SetRequestMetadataItem("propagation_channel_id", PROPAGATION_CHANNEL_ID);
if (err) {
return WrapError(err, "SetRequestMetadataItem failed");
}
err = PsiCash::SetRequestMetadataItem("sponsor_id", SPONSOR_ID);
if (err) {
return WrapError(err, "SetRequestMetadataItem failed");
}
err = PsiCash::SetRequestMetadataItem("client_region", WStringToUTF8(GetDeviceRegion()));
if (err) {
return WrapError(err, "SetRequestMetadataItem failed");
return WrapError(err, "SetRequestMetadataItems failed");
}

try { my_print(NOT_SENSITIVE, true, _T("%s: PsiCash state: %S"), __TFUNCTION__, PsiCash::GetDiagnosticInfo(true).dump(-1, ' ', true).c_str()); }
Expand All @@ -72,9 +64,9 @@ error::Error Lib::Init(bool forceReset) {
}

error::Error Lib::UpdateClientRegion(const string& region) {
auto err = PsiCash::SetRequestMetadataItem("client_region", region);
auto err = PsiCash::SetRequestMetadataItems({ {"client_region", region} });
if (err) {
return WrapError(err, "SetRequestMetadataItem failed");
return WrapError(err, "SetRequestMetadataItems failed");
}

return error::nullerr;
Expand Down
Loading

0 comments on commit 90bcdce

Please sign in to comment.