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;
|
||||
};
|
||||
|
||||
bool is_ipv6() const {
|
||||
return (flags_ & Flags::IPv6) != 0;
|
||||
}
|
||||
|
||||
public:
|
||||
DcOption() = default;
|
||||
|
||||
@ -113,6 +109,10 @@ class DcOption {
|
||||
return ip_address_;
|
||||
}
|
||||
|
||||
bool is_ipv6() const {
|
||||
return (flags_ & Flags::IPv6) != 0;
|
||||
}
|
||||
|
||||
bool is_media_only() const {
|
||||
return (flags_ & Flags::MediaOnly) != 0;
|
||||
}
|
||||
|
@ -43,7 +43,8 @@ DcOptions DcOptionsSet::get_dc_options() const {
|
||||
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> static_options;
|
||||
|
||||
@ -85,6 +86,12 @@ vector<DcOptionsSet::ConnectionInfo> DcOptionsSet::find_all_connections(DcId dc_
|
||||
if (use_static) {
|
||||
if (!static_options.empty()) {
|
||||
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 {
|
||||
if (options.empty()) {
|
||||
|
Reference in New Issue
Block a user