Shuffle built-in datacenter IP addresses.
This commit is contained in:
parent
4b7c1aee03
commit
1d5d505789
@ -1176,20 +1176,21 @@ void ConnectionCreator::hangup() {
|
|||||||
DcOptions ConnectionCreator::get_default_dc_options(bool is_test) {
|
DcOptions ConnectionCreator::get_default_dc_options(bool is_test) {
|
||||||
DcOptions res;
|
DcOptions res;
|
||||||
enum class HostType : int32 { IPv4, IPv6, Url };
|
enum class HostType : int32 { IPv4, IPv6, Url };
|
||||||
auto add_ip_ports = [&res](int32 dc_id, const vector<string> &ips, const vector<int> &ports,
|
auto add_ip_ports = [&res](int32 dc_id, vector<string> ip_address_strings, const vector<int> &ports,
|
||||||
HostType type = HostType::IPv4) {
|
HostType type = HostType::IPv4) {
|
||||||
IPAddress ip_address;
|
IPAddress ip_address;
|
||||||
|
Random::shuffle(ip_address_strings);
|
||||||
for (auto port : ports) {
|
for (auto port : ports) {
|
||||||
for (auto &ip : ips) {
|
for (auto &ip_address_string : ip_address_strings) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case HostType::IPv4:
|
case HostType::IPv4:
|
||||||
ip_address.init_ipv4_port(ip, port).ensure();
|
ip_address.init_ipv4_port(ip_address_string, port).ensure();
|
||||||
break;
|
break;
|
||||||
case HostType::IPv6:
|
case HostType::IPv6:
|
||||||
ip_address.init_ipv6_port(ip, port).ensure();
|
ip_address.init_ipv6_port(ip_address_string, port).ensure();
|
||||||
break;
|
break;
|
||||||
case HostType::Url:
|
case HostType::Url:
|
||||||
ip_address.init_host_port(ip, port).ensure();
|
ip_address.init_host_port(ip_address_string, port).ensure();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
res.dc_options.emplace_back(DcId::internal(dc_id), ip_address);
|
res.dc_options.emplace_back(DcId::internal(dc_id), ip_address);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user