2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +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();
}

View File

@@ -420,13 +420,6 @@ enum DBIWorkMode {
dbiwmWindowOnly = 2,
};
enum DBIConnectionType {
dbictAuto = 0,
dbictHttpAuto = 1, // not used
dbictHttpProxy = 2,
dbictTcpProxy = 3,
};
struct ProxyData {
enum class Type {
None,
@@ -440,6 +433,11 @@ struct ProxyData {
uint32 port = 0;
QString user, password;
bool valid() const;
explicit operator bool() const;
bool operator==(const ProxyData &other) const;
bool operator!=(const ProxyData &other) const;
static bool ValidSecret(const QString &secret);
};