Use Google DNS only if blocking is expected.
GitOrigin-RevId: 9a3b258d1ce9b0f084fb90bb1d86024b0cbee550
This commit is contained in:
parent
72ac6667ce
commit
0defd8c927
@ -457,6 +457,14 @@ void ConnectionCreator::get_proxy_link(int32 proxy_id, Promise<string> promise)
|
|||||||
promise.set_value(std::move(url));
|
promise.set_value(std::move(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActorId<GetHostByNameActor> ConnectionCreator::get_resolver() const {
|
||||||
|
if (G()->shared_config().get_option_boolean("expect_blocking", true)) {
|
||||||
|
return block_get_host_by_name_actor_.get();
|
||||||
|
} else {
|
||||||
|
return get_host_by_name_actor_.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConnectionCreator::ping_proxy(int32 proxy_id, Promise<double> promise) {
|
void ConnectionCreator::ping_proxy(int32 proxy_id, Promise<double> promise) {
|
||||||
if (proxy_id == 0) {
|
if (proxy_id == 0) {
|
||||||
ProxyInfo proxy{nullptr, IPAddress()};
|
ProxyInfo proxy{nullptr, IPAddress()};
|
||||||
@ -507,7 +515,7 @@ void ConnectionCreator::ping_proxy(int32 proxy_id, Promise<double> promise) {
|
|||||||
}
|
}
|
||||||
const Proxy &proxy = it->second;
|
const Proxy &proxy = it->second;
|
||||||
bool prefer_ipv6 = G()->shared_config().get_option_boolean("prefer_ipv6");
|
bool prefer_ipv6 = G()->shared_config().get_option_boolean("prefer_ipv6");
|
||||||
send_closure(get_host_by_name_actor_, &GetHostByNameActor::run, proxy.server().str(), proxy.port(), prefer_ipv6,
|
send_closure(get_resolver(), &GetHostByNameActor::run, proxy.server().str(), proxy.port(), prefer_ipv6,
|
||||||
PromiseCreator::lambda([actor_id = actor_id(this), promise = std::move(promise),
|
PromiseCreator::lambda([actor_id = actor_id(this), promise = std::move(promise),
|
||||||
proxy_id](Result<IPAddress> result) mutable {
|
proxy_id](Result<IPAddress> result) mutable {
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
@ -1243,10 +1251,11 @@ void ConnectionCreator::start_up() {
|
|||||||
|
|
||||||
GetHostByNameActor::Options options;
|
GetHostByNameActor::Options options;
|
||||||
options.scheduler_id = G()->get_gc_scheduler_id();
|
options.scheduler_id = G()->get_gc_scheduler_id();
|
||||||
options.resolver_types = {GetHostByNameActor::ResolverType::Google, GetHostByNameActor::ResolverType::Native};
|
|
||||||
options.ok_timeout = 5 * 60 - 1;
|
options.ok_timeout = 5 * 60 - 1;
|
||||||
options.error_timeout = 0;
|
options.error_timeout = 0;
|
||||||
get_host_by_name_actor_ = create_actor<GetHostByNameActor>("GetHostByNameActor", std::move(options));
|
get_host_by_name_actor_ = create_actor<GetHostByNameActor>("GetHostByNameActor", options);
|
||||||
|
options.resolver_types = {GetHostByNameActor::ResolverType::Google, GetHostByNameActor::ResolverType::Native};
|
||||||
|
block_get_host_by_name_actor_ = create_actor<GetHostByNameActor>("GetHostByNameActor", options);
|
||||||
|
|
||||||
ref_cnt_guard_ = create_reference(-1);
|
ref_cnt_guard_ = create_reference(-1);
|
||||||
|
|
||||||
@ -1373,7 +1382,7 @@ void ConnectionCreator::loop() {
|
|||||||
bool prefer_ipv6 = G()->shared_config().get_option_boolean("prefer_ipv6");
|
bool prefer_ipv6 = G()->shared_config().get_option_boolean("prefer_ipv6");
|
||||||
VLOG(connections) << "Resolve IP address " << resolve_proxy_query_token_ << " of " << proxy.server();
|
VLOG(connections) << "Resolve IP address " << resolve_proxy_query_token_ << " of " << proxy.server();
|
||||||
send_closure(
|
send_closure(
|
||||||
get_host_by_name_actor_, &GetHostByNameActor::run, proxy.server().str(), proxy.port(), prefer_ipv6,
|
get_resolver(), &GetHostByNameActor::run, proxy.server().str(), proxy.port(), prefer_ipv6,
|
||||||
PromiseCreator::lambda([actor_id = create_reference(resolve_proxy_query_token_)](Result<IPAddress> result) {
|
PromiseCreator::lambda([actor_id = create_reference(resolve_proxy_query_token_)](Result<IPAddress> result) {
|
||||||
send_closure(std::move(actor_id), &ConnectionCreator::on_proxy_resolved, std::move(result), false);
|
send_closure(std::move(actor_id), &ConnectionCreator::on_proxy_resolved, std::move(result), false);
|
||||||
}));
|
}));
|
||||||
|
@ -185,6 +185,7 @@ class ConnectionCreator : public NetQueryCallback {
|
|||||||
int32 max_proxy_id_ = 0;
|
int32 max_proxy_id_ = 0;
|
||||||
int32 active_proxy_id_ = 0;
|
int32 active_proxy_id_ = 0;
|
||||||
ActorOwn<GetHostByNameActor> get_host_by_name_actor_;
|
ActorOwn<GetHostByNameActor> get_host_by_name_actor_;
|
||||||
|
ActorOwn<GetHostByNameActor> block_get_host_by_name_actor_;
|
||||||
IPAddress proxy_ip_address_;
|
IPAddress proxy_ip_address_;
|
||||||
Timestamp resolve_proxy_timestamp_;
|
Timestamp resolve_proxy_timestamp_;
|
||||||
uint64 resolve_proxy_query_token_{0};
|
uint64 resolve_proxy_query_token_{0};
|
||||||
@ -322,6 +323,8 @@ class ConnectionCreator : public NetQueryCallback {
|
|||||||
Result<SocketFd> find_connection(const ProxyInfo &proxy, DcId dc_id, bool allow_media_only,
|
Result<SocketFd> find_connection(const ProxyInfo &proxy, DcId dc_id, bool allow_media_only,
|
||||||
FindConnectionExtra &extra);
|
FindConnectionExtra &extra);
|
||||||
|
|
||||||
|
ActorId<GetHostByNameActor> get_resolver() const;
|
||||||
|
|
||||||
void ping_proxy_resolved(int32 proxy_id, IPAddress ip_address, Promise<double> promise);
|
void ping_proxy_resolved(int32 proxy_id, IPAddress ip_address, Promise<double> promise);
|
||||||
|
|
||||||
void ping_proxy_socket_fd(SocketFd socket_fd, mtproto::TransportType transport_type, Promise<double> promise);
|
void ping_proxy_socket_fd(SocketFd socket_fd, mtproto::TransportType transport_type, Promise<double> promise);
|
||||||
|
Loading…
Reference in New Issue
Block a user