2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-01 06:55:58 +00:00

Support multiple proxies in local storage.

This commit is contained in:
John Preston
2018-04-27 21:26:45 +04:00
parent 8e99135f37
commit 900d1ddb36
12 changed files with 205 additions and 146 deletions

View File

@@ -236,6 +236,34 @@ namespace {
_MsStarter _msStarter;
}
bool ProxyData::valid() const {
if (type == Type::None || host.isEmpty() || !port) {
return false;
} else if (type == Type::Mtproto && !ValidSecret(password)) {
return false;
}
return true;
}
ProxyData::operator bool() const {
return valid();
}
bool ProxyData::operator==(const ProxyData &other) const {
if (!valid()) {
return !other.valid();
}
return (type == other.type)
&& (host == other.host)
&& (port == other.port)
&& (user == other.user)
&& (password == other.password);
}
bool ProxyData::operator!=(const ProxyData &other) const {
return !(*this == other);
}
bool ProxyData::ValidSecret(const QString &secret) {
return QRegularExpression("^[a-fA-F0-9]{32}$").match(secret).hasMatch();
}