diff --git a/src/discord/LocalSettings.cpp b/src/discord/LocalSettings.cpp index 5e460f4..004959b 100644 --- a/src/discord/LocalSettings.cpp +++ b/src/discord/LocalSettings.cpp @@ -116,6 +116,9 @@ bool LocalSettings::Load() if (j.contains("RemindUpdateCheckOn")) m_remindUpdatesOn = (time_t) (long long) j["RemindUpdateCheckOn"]; + + if (j.contains("AddExtraHeaders")) + m_bAddExtraHeaders = j["AddExtraHeaders"]; return true; } @@ -144,7 +147,8 @@ bool LocalSettings::Save() j["ImageBackgroundFileName"] = m_imageBackgroundFileName; j["WatermarkAlignment"] = int(m_imageAlignment); j["UserScale"] = m_userScale; - + j["AddExtraHeaders"] = m_bAddExtraHeaders; + if (m_bSaveWindowSize) { j["WindowWidth"] = m_width; j["WindowHeight"] = m_height; diff --git a/src/discord/LocalSettings.hpp b/src/discord/LocalSettings.hpp index 653fb58..21fb5b2 100644 --- a/src/discord/LocalSettings.hpp +++ b/src/discord/LocalSettings.hpp @@ -108,6 +108,12 @@ class LocalSettings void SetEnableTLSVerification(bool b) { m_bEnableTLSVerification = b; } + bool AddExtraHeaders() const { + return m_bAddExtraHeaders; + } + void SetAddExtraHeaders(bool b) { + m_bAddExtraHeaders = b; + } void StopUpdateCheckTemporarily(); bool DisableFormatting() const { return m_bDisableFormatting; @@ -158,6 +164,7 @@ class LocalSettings bool m_bDisableFormatting = false; bool m_bShowScrollBarOnGuildList = false; bool m_bCompactMemberList = false; + bool m_bAddExtraHeaders = true; time_t m_remindUpdatesOn = 0; int m_width = 1000; int m_height = 700; diff --git a/src/resource.h b/src/resource.h index 0c6d4cd..b66f978 100644 --- a/src/resource.h +++ b/src/resource.h @@ -381,7 +381,6 @@ #define IDC_UPLOADING_ETA 878 #define IDC_UPLOADING_XFERRATE 879 #define IDC_UPLOADING_ACTION 880 -#define IDC_ANIMATE1 881 #define IDC_PROGRESS_ANIMATE 881 #define IDC_MESSAGE_STYLE 882 #define IDC_ACTIVE_IMAGE_BROWSE 884 @@ -391,6 +390,7 @@ #define IDC_COMBO_ALIGNMENT 889 #define IDC_COMBO_GUI_SCALE 890 #define IDC_NOTIFICATION_HINT 891 +#define IDC_TOGGLE_XSUPERPROPS 892 #define ID_FILE_PREFERENCES 1001 #define ID_FILE_STOPALLSPEECH 1002 #define ID_FILE_EXIT 1003 @@ -469,7 +469,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 101 #define _APS_NEXT_COMMAND_VALUE 1069 -#define _APS_NEXT_CONTROL_VALUE 892 +#define _APS_NEXT_CONTROL_VALUE 893 #define _APS_NEXT_SYMED_VALUE 40000 #endif #endif diff --git a/src/resource.rc b/src/resource.rc index 39b003e..7324afc 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -598,7 +598,7 @@ BEGIN ICON IDI_WARNING_IC,IDC_ICON_WARN_CONNECT,12,55,21,20,SS_REALSIZEIMAGE LTEXT "For security reasons, when you update the URLs that Discord Messenger uses to interface with Discord's backend, you will be logged out. (your token is forgotten but not revoked)",IDC_STATIC,33,54,215,31 ICON IDI_WARNING_IC,IDC_ICON_WARN_WEBSOCKETSTUFF,12,87,21,20,SS_REALSIZEIMAGE - LTEXT "Wondering where the websocket gateway URL is located? Well, Discord Messenger issues a request to API_URL/gateway, which tells it the websocket URL to use.",IDC_STATIC,33,87,215,29 + LTEXT "NOTE: Discord Messenger automatically fetches the websocket gateway URL using the API_URL/gateway endpoint.",IDC_STATIC,33,82,214,19 GROUPBOX "Security Settings",IDC_STATIC,6,139,248,48 ICON IDI_WARNING_IC,IDC_ICON_WARN_WEBSOCKETSTUFF2,12,166,21,20,SS_REALSIZEIMAGE LTEXT "WARNING: Disabling TLS certificate verification could expose you to MITM (man-in-the-middle) attacks via certificate spoofing!",IDC_STATIC,33,165,215,19 @@ -608,6 +608,8 @@ BEGIN CONTROL "Check for updates using the GitHub API",IDC_CHECK_UPDATES, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,204,236,10 LTEXT "iProgramInCpp cannot see your IP address via the update service.",IDC_STATIC,12,219,231,10 + CONTROL "Add extra headers such as X-Super-Properties to HTTP requests.",IDC_TOGGLE_XSUPERPROPS, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,104,231,10 END IDD_DIALOG_UPLOADING DIALOGEX 0, 0, 275, 135 diff --git a/src/windows/NetworkerThread.cpp b/src/windows/NetworkerThread.cpp index ed57545..f47efe0 100644 --- a/src/windows/NetworkerThread.cpp +++ b/src/windows/NetworkerThread.cpp @@ -30,6 +30,11 @@ static bool g_bQuittingFromSSLError; int g_latestSSLError = 0; // HACK - used by httplib.h, to debug some weird issue +bool AddExtraHeaders() +{ + return GetLocalSettings()->AddExtraHeaders(); +} + int NetRequest::Priority() const { int prio = 0; @@ -205,12 +210,16 @@ void NetworkerThread::FulfillRequest(NetRequest& req) Headers headers; headers.insert(std::make_pair("User-Agent", GetClientConfig()->GetUserAgent())); - headers.insert(std::make_pair("X-Super-Properties", GetClientConfig()->GetSerializedBase64Blob())); - headers.insert(std::make_pair("X-Discord-Timezone", GetClientConfig()->GetTimezone())); - headers.insert(std::make_pair("X-Discord-Locale", GetClientConfig()->GetLocale())); - headers.insert(std::make_pair("Sec-Ch-Ua", GetClientConfig()->GetSecChUa())); - headers.insert(std::make_pair("Sec-Ch-Ua-Mobile", "?0")); - headers.insert(std::make_pair("Sec-Ch-Ua-Platform", GetClientConfig()->GetOS())); + + if (AddExtraHeaders()) + { + headers.insert(std::make_pair("X-Super-Properties", GetClientConfig()->GetSerializedBase64Blob())); + headers.insert(std::make_pair("X-Discord-Timezone", GetClientConfig()->GetTimezone())); + headers.insert(std::make_pair("X-Discord-Locale", GetClientConfig()->GetLocale())); + headers.insert(std::make_pair("Sec-Ch-Ua", GetClientConfig()->GetSecChUa())); + headers.insert(std::make_pair("Sec-Ch-Ua-Mobile", "?0")); + headers.insert(std::make_pair("Sec-Ch-Ua-Platform", GetClientConfig()->GetOS())); + } if (req.authorization.size()) { diff --git a/src/windows/OptionsDialog.cpp b/src/windows/OptionsDialog.cpp index f3cf25b..b480eaf 100644 --- a/src/windows/OptionsDialog.cpp +++ b/src/windows/OptionsDialog.cpp @@ -232,8 +232,9 @@ void WINAPI OnChildDialogInit(HWND hwndDlg) SetDlgItemText(hwndDlg, IDC_EDIT_DISCORDAPI, tstrAPI); SetDlgItemText(hwndDlg, IDC_EDIT_DISCORDCDN, tstrCDN); - CheckDlgButton(hwndDlg, IDC_ENABLE_TLS_CHECKS, GetLocalSettings()->EnableTLSVerification() ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_UPDATES, GetLocalSettings()->CheckUpdates() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_ENABLE_TLS_CHECKS, GetLocalSettings()->EnableTLSVerification() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CHECK_UPDATES, GetLocalSettings()->CheckUpdates() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_TOGGLE_XSUPERPROPS, GetLocalSettings()->AddExtraHeaders() ? BST_CHECKED : BST_UNCHECKED); free(tstrAPI); free(tstrCDN); @@ -457,6 +458,12 @@ INT_PTR CALLBACK ChildDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa break; } + case IDC_TOGGLE_XSUPERPROPS: + { + GetLocalSettings()->SetAddExtraHeaders(IsDlgButtonChecked(hWnd, IDC_TOGGLE_XSUPERPROPS)); + break; + } + case IDC_REVERTTODEFAULT: case IDC_UPDATE: {