Prefer static dc options when using a proxy.

This commit is contained in:
John Preston 2017-06-27 23:50:56 +03:00
parent 82912f4a0b
commit 7245319351
1 changed files with 30 additions and 4 deletions

View File

@ -408,6 +408,8 @@ bool DcOptions::getDcRSAKey(DcId dcId, const QVector<MTPlong> &fingerprints, int
DcOptions::Variants DcOptions::lookup(DcId dcId, DcType type) const {
auto lookupDesiredFlags = [type](int address, int protocol) -> std::vector<MTPDdcOption::Flags> {
auto throughProxy = (Global::ConnectionType() != dbictAuto);
switch (type) {
case DcType::Regular:
case DcType::Temporary: {
@ -416,11 +418,14 @@ DcOptions::Variants DcOptions::lookup(DcId dcId, DcType type) const {
switch (protocol) {
case Variants::Tcp: return {
// Regular TCP IPv4
throughProxy ? (MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_static) : qFlags(MTPDdcOption::Flag::f_tcpo_only),
throughProxy ? qFlags(MTPDdcOption::Flag::f_static) : MTPDdcOption::Flags(0),
qFlags(MTPDdcOption::Flag::f_tcpo_only),
MTPDdcOption::Flags(0)
};
case Variants::Http: return {
// Regular HTTP IPv4
throughProxy ? qFlags(MTPDdcOption::Flag::f_static) : MTPDdcOption::Flags(0),
MTPDdcOption::Flags(0),
};
}
@ -429,11 +434,14 @@ DcOptions::Variants DcOptions::lookup(DcId dcId, DcType type) const {
switch (protocol) {
case Variants::Tcp: return {
// Regular TCP IPv6
throughProxy ? (MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_ipv6 | MTPDdcOption::Flag::f_static) : (MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_ipv6),
throughProxy ? (MTPDdcOption::Flag::f_ipv6 | MTPDdcOption::Flag::f_static) : qFlags(MTPDdcOption::Flag::f_ipv6),
(MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_ipv6),
qFlags(MTPDdcOption::Flag::f_ipv6),
};
case Variants::Http: return {
// Regular HTTP IPv6
throughProxy ? (MTPDdcOption::Flag::f_ipv6 | MTPDdcOption::Flag::f_static) : qFlags(MTPDdcOption::Flag::f_ipv6),
qFlags(MTPDdcOption::Flag::f_ipv6),
};
}
@ -446,14 +454,20 @@ DcOptions::Variants DcOptions::lookup(DcId dcId, DcType type) const {
switch (protocol) {
case Variants::Tcp: return {
// Media download TCP IPv4
(MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_tcpo_only),
qFlags(MTPDdcOption::Flag::f_tcpo_only),
throughProxy ? (MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_static) : (MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_tcpo_only),
throughProxy ? (MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_static) : qFlags(MTPDdcOption::Flag::f_tcpo_only),
qFlags(MTPDdcOption::Flag::f_media_only),
throughProxy ? qFlags(MTPDdcOption::Flag::f_static) : MTPDdcOption::Flags(0),
(MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_tcpo_only),
throughProxy ? (MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_static) : qFlags(MTPDdcOption::Flag::f_tcpo_only),
throughProxy ? qFlags(MTPDdcOption::Flag::f_tcpo_only) : qFlags(MTPDdcOption::Flag::f_media_only),
MTPDdcOption::Flags(0),
};
case Variants::Http: return {
// Media download HTTP IPv4
throughProxy ? (MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_static) : qFlags(MTPDdcOption::Flag::f_media_only),
qFlags(MTPDdcOption::Flag::f_media_only),
throughProxy ? qFlags(MTPDdcOption::Flag::f_static) : MTPDdcOption::Flags(0),
MTPDdcOption::Flags(0),
};
}
@ -462,14 +476,20 @@ DcOptions::Variants DcOptions::lookup(DcId dcId, DcType type) const {
switch (protocol) {
case Variants::Tcp: return {
// Media download TCP IPv6
(MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_ipv6),
(MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_ipv6),
throughProxy ? (MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_ipv6 | MTPDdcOption::Flag::f_static) : (MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_ipv6),
throughProxy ? (MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_ipv6 | MTPDdcOption::Flag::f_static) : (MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_ipv6),
(MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_ipv6),
throughProxy ? (MTPDdcOption::Flag::f_ipv6 | MTPDdcOption::Flag::f_static) : qFlags(MTPDdcOption::Flag::f_ipv6),
(MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_ipv6),
throughProxy ? (MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_ipv6 | MTPDdcOption::Flag::f_static) : (MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_ipv6),
throughProxy ? (MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_ipv6) : (MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_ipv6),
qFlags(MTPDdcOption::Flag::f_ipv6)
};
case Variants::Http: return {
// Media download HTTP IPv6
throughProxy ? (MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_ipv6 | MTPDdcOption::Flag::f_static) : (MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_ipv6),
(MTPDdcOption::Flag::f_media_only | MTPDdcOption::Flag::f_ipv6),
throughProxy ? (MTPDdcOption::Flag::f_ipv6 | MTPDdcOption::Flag::f_static) : qFlags(MTPDdcOption::Flag::f_ipv6),
qFlags(MTPDdcOption::Flag::f_ipv6),
};
}
@ -482,11 +502,14 @@ DcOptions::Variants DcOptions::lookup(DcId dcId, DcType type) const {
switch (protocol) {
case Variants::Tcp: return {
// CDN TCP IPv4
throughProxy ? (MTPDdcOption::Flag::f_cdn | MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_static) : (MTPDdcOption::Flag::f_cdn | MTPDdcOption::Flag::f_tcpo_only),
throughProxy ? (MTPDdcOption::Flag::f_cdn | MTPDdcOption::Flag::f_static) : qFlags(MTPDdcOption::Flag::f_cdn),
(MTPDdcOption::Flag::f_cdn | MTPDdcOption::Flag::f_tcpo_only),
qFlags(MTPDdcOption::Flag::f_cdn),
};
case Variants::Http: return {
// CDN HTTP IPv4
throughProxy ? (MTPDdcOption::Flag::f_cdn | MTPDdcOption::Flag::f_static) : qFlags(MTPDdcOption::Flag::f_cdn),
qFlags(MTPDdcOption::Flag::f_cdn),
};
}
@ -495,11 +518,14 @@ DcOptions::Variants DcOptions::lookup(DcId dcId, DcType type) const {
switch (protocol) {
case Variants::Tcp: return {
// CDN TCP IPv6
throughProxy ? (MTPDdcOption::Flag::f_cdn | MTPDdcOption::Flag::f_ipv6 | MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_static) : (MTPDdcOption::Flag::f_cdn | MTPDdcOption::Flag::f_ipv6 | MTPDdcOption::Flag::f_tcpo_only),
throughProxy ? (MTPDdcOption::Flag::f_cdn | MTPDdcOption::Flag::f_ipv6 | MTPDdcOption::Flag::f_static) : (MTPDdcOption::Flag::f_cdn | MTPDdcOption::Flag::f_ipv6),
(MTPDdcOption::Flag::f_cdn | MTPDdcOption::Flag::f_tcpo_only | MTPDdcOption::Flag::f_ipv6),
(MTPDdcOption::Flag::f_cdn | MTPDdcOption::Flag::f_ipv6),
};
case Variants::Http: return {
// CDN HTTP IPv6
throughProxy ? (MTPDdcOption::Flag::f_cdn | MTPDdcOption::Flag::f_ipv6 | MTPDdcOption::Flag::f_static) : (MTPDdcOption::Flag::f_cdn | MTPDdcOption::Flag::f_ipv6),
(MTPDdcOption::Flag::f_cdn | MTPDdcOption::Flag::f_ipv6),
};
}