mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Added proxy check IP exposure warning before status check.
This commit is contained in:
@@ -339,6 +339,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_proxy_invalid" = "The proxy link is invalid.";
|
||||
"lng_proxy_unsupported" = "Your Telegram Desktop version doesn't support this proxy type or the proxy link is invalid. Please update Telegram Desktop to the latest version.";
|
||||
"lng_proxy_incorrect_secret" = "This proxy link uses invalid **secret** parameter. Please contact the proxy provider and ask him to update MTProxy source code and configure it with a correct **secret** value. Then let him provide a new link.";
|
||||
"lng_proxy_check_ip_warning_title" = "Warning";
|
||||
"lng_proxy_check_ip_warning" = "This will expose your IP address to the admin of the proxy server.";
|
||||
"lng_proxy_check_ip_proceed" = "Proceed";
|
||||
|
||||
"lng_edit_deleted" = "This message was deleted";
|
||||
"lng_edit_limit_reached#one" = "You've reached the message text limit. Please make the text shorter by {count} character.";
|
||||
|
||||
@@ -1647,7 +1647,22 @@ void ProxiesBoxController::ShowApplyConfirmation(
|
||||
}
|
||||
};
|
||||
statusLabel->setClickHandlerFilter([=](const auto &...) {
|
||||
runCheck();
|
||||
auto &proxy = Core::App().settings().proxy();
|
||||
if (proxy.checkIpWarningShown()) {
|
||||
runCheck();
|
||||
} else {
|
||||
box->uiShow()->showBox(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_proxy_check_ip_warning(),
|
||||
.confirmed = [=] {
|
||||
auto &proxy = Core::App().settings().proxy();
|
||||
proxy.setCheckIpWarningShown(true);
|
||||
Local::writeSettings();
|
||||
runCheck();
|
||||
},
|
||||
.confirmText = tr::lng_proxy_check_ip_proceed(),
|
||||
.title = tr::lng_proxy_check_ip_warning_title(),
|
||||
}));
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -107,7 +107,8 @@ QByteArray SettingsProxy::serialize() const {
|
||||
serializedList,
|
||||
0,
|
||||
ranges::plus(),
|
||||
&Serialize::bytearraySize);
|
||||
&Serialize::bytearraySize)
|
||||
+ 1 * sizeof(qint32); // _checkIpWarningShown
|
||||
auto stream = Serialize::ByteArrayWriter(size);
|
||||
stream
|
||||
<< qint32(_tryIPv6 ? 1 : 0)
|
||||
@@ -118,6 +119,7 @@ QByteArray SettingsProxy::serialize() const {
|
||||
for (const auto &i : serializedList) {
|
||||
stream << i;
|
||||
}
|
||||
stream << qint32(_checkIpWarningShown ? 1 : 0);
|
||||
return std::move(stream).result();
|
||||
}
|
||||
|
||||
@@ -150,6 +152,11 @@ bool SettingsProxy::setFromSerialized(const QByteArray &serialized) {
|
||||
}
|
||||
}
|
||||
|
||||
auto checkIpWarningShown = qint32(0);
|
||||
if (!stream.atEnd()) {
|
||||
stream >> checkIpWarningShown;
|
||||
}
|
||||
|
||||
if (!stream.ok()) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for Core::SettingsProxy::setFromSerialized()"));
|
||||
@@ -158,6 +165,7 @@ bool SettingsProxy::setFromSerialized(const QByteArray &serialized) {
|
||||
|
||||
_tryIPv6 = (tryIPv6 == 1);
|
||||
_useProxyForCalls = (useProxyForCalls == 1);
|
||||
_checkIpWarningShown = (checkIpWarningShown == 1);
|
||||
_settings = IntToProxySettings(settings);
|
||||
_selected = DeserializeProxyData(selectedProxy);
|
||||
|
||||
@@ -176,6 +184,14 @@ bool SettingsProxy::isDisabled() const {
|
||||
return _settings == MTP::ProxyData::Settings::Disabled;
|
||||
}
|
||||
|
||||
bool SettingsProxy::checkIpWarningShown() const {
|
||||
return _checkIpWarningShown;
|
||||
}
|
||||
|
||||
void SettingsProxy::setCheckIpWarningShown(bool value) {
|
||||
_checkIpWarningShown = value;
|
||||
}
|
||||
|
||||
bool SettingsProxy::tryIPv6() const {
|
||||
return _tryIPv6;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ public:
|
||||
[[nodiscard]] MTP::ProxyData selected() const;
|
||||
void setSelected(MTP::ProxyData value);
|
||||
|
||||
[[nodiscard]] bool checkIpWarningShown() const;
|
||||
void setCheckIpWarningShown(bool value);
|
||||
|
||||
[[nodiscard]] const std::vector<MTP::ProxyData> &list() const;
|
||||
[[nodiscard]] std::vector<MTP::ProxyData> &list();
|
||||
|
||||
@@ -44,6 +47,7 @@ public:
|
||||
private:
|
||||
bool _tryIPv6 = false;
|
||||
bool _useProxyForCalls = false;
|
||||
bool _checkIpWarningShown = false;
|
||||
MTP::ProxyData::Settings _settings = MTP::ProxyData::Settings::System;
|
||||
MTP::ProxyData _selected;
|
||||
std::vector<MTP::ProxyData> _list;
|
||||
|
||||
Reference in New Issue
Block a user