diff options
| author | levlam <levlam@telegram.org> | 2018-07-01 04:12:20 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2018-07-01 04:12:20 +0300 |
| commit | 9b0a138dd191fc2847dbb7041df1d9324bcab1c2 (patch) | |
| tree | 1a60a6ea46f4d592f954d4e02031d877beb096d0 /tdnet/td/net/GetHostByNameActor.cpp | |
| parent | 9e6ddb14a7ba06efd452d2700ea22b9a1ff42818 (diff) | |
Add prefer_ipv6 parameter tp GetHostByNameActor.
GitOrigin-RevId: 727fc30d94657399f1e49efc208b6951a7677d2f
Diffstat (limited to 'tdnet/td/net/GetHostByNameActor.cpp')
| -rw-r--r-- | tdnet/td/net/GetHostByNameActor.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tdnet/td/net/GetHostByNameActor.cpp b/tdnet/td/net/GetHostByNameActor.cpp index f2b9313f6..ed6d8ce7e 100644 --- a/tdnet/td/net/GetHostByNameActor.cpp +++ b/tdnet/td/net/GetHostByNameActor.cpp @@ -15,13 +15,13 @@ GetHostByNameActor::GetHostByNameActor(int32 ok_timeout, int32 error_timeout) : ok_timeout_(ok_timeout), error_timeout_(error_timeout) { } -void GetHostByNameActor::run(std::string host, int port, td::Promise<td::IPAddress> promise) { - auto r_ip = load_ip(std::move(host), port); +void GetHostByNameActor::run(std::string host, int port, bool prefer_ipv6, td::Promise<td::IPAddress> promise) { + auto r_ip = load_ip(std::move(host), port, prefer_ipv6); promise.set_result(std::move(r_ip)); } -Result<td::IPAddress> GetHostByNameActor::load_ip(string host, int port) { - auto &value = cache_.emplace(host, Value{{}, 0}).first->second; +Result<td::IPAddress> GetHostByNameActor::load_ip(string host, int port, bool prefer_ipv6) { + auto &value = cache_[prefer_ipv6].emplace(host, Value{{}, 0}).first->second; auto begin_time = td::Time::now(); if (value.expire_at > begin_time) { auto ip = value.ip.clone(); @@ -33,7 +33,7 @@ Result<td::IPAddress> GetHostByNameActor::load_ip(string host, int port) { } td::IPAddress ip; - auto status = ip.init_host_port(host, port); + auto status = ip.init_host_port(host, port, prefer_ipv6); auto end_time = td::Time::now(); LOG(WARNING) << "Init host = " << host << ", port = " << port << " in " << end_time - begin_time << " seconds to " << ip; |
