Prefer IPv4 for connections through proxy.
GitOrigin-RevId: 5512d66191496bc964829f1a7bfe79d1d4474fef
This commit is contained in:
parent
2c5f5a8587
commit
ef2eb1c3cf
@ -33,10 +33,6 @@ class DcOption {
|
|||||||
int32 flags;
|
int32 flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool is_ipv6() const {
|
|
||||||
return (flags_ & Flags::IPv6) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DcOption() = default;
|
DcOption() = default;
|
||||||
|
|
||||||
@ -113,6 +109,10 @@ class DcOption {
|
|||||||
return ip_address_;
|
return ip_address_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_ipv6() const {
|
||||||
|
return (flags_ & Flags::IPv6) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool is_media_only() const {
|
bool is_media_only() const {
|
||||||
return (flags_ & Flags::MediaOnly) != 0;
|
return (flags_ & Flags::MediaOnly) != 0;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,8 @@ DcOptions DcOptionsSet::get_dc_options() const {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<DcOptionsSet::ConnectionInfo> DcOptionsSet::find_all_connections(DcId dc_id, bool allow_media_only, bool use_static) {
|
vector<DcOptionsSet::ConnectionInfo> DcOptionsSet::find_all_connections(DcId dc_id, bool allow_media_only,
|
||||||
|
bool use_static) {
|
||||||
std::vector<ConnectionInfo> options;
|
std::vector<ConnectionInfo> options;
|
||||||
std::vector<ConnectionInfo> static_options;
|
std::vector<ConnectionInfo> static_options;
|
||||||
|
|
||||||
@ -85,6 +86,12 @@ vector<DcOptionsSet::ConnectionInfo> DcOptionsSet::find_all_connections(DcId dc_
|
|||||||
if (use_static) {
|
if (use_static) {
|
||||||
if (!static_options.empty()) {
|
if (!static_options.empty()) {
|
||||||
options = std::move(static_options);
|
options = std::move(static_options);
|
||||||
|
} else {
|
||||||
|
bool have_ipv4 = std::any_of(options.begin(), options.end(), [](auto &v) { return !v.option->is_ipv6(); });
|
||||||
|
if (have_ipv4) {
|
||||||
|
options.erase(std::remove_if(options.begin(), options.end(), [](auto &v) { return v.option->is_ipv6(); }),
|
||||||
|
options.end());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (options.empty()) {
|
if (options.empty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user