|
|
|
@ -82,7 +82,7 @@ void WebhookActor::relax_wakeup_at(double wakeup_at, const char *source) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WebhookActor::resolve_ip_address() {
|
|
|
|
void WebhookActor::resolve_ip_address() {
|
|
|
|
if (fix_ip_address_) {
|
|
|
|
if (fix_ip_address_ || is_ip_address_being_resolved_) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (td::Time::now() < next_ip_address_resolve_time_) {
|
|
|
|
if (td::Time::now() < next_ip_address_resolve_time_) {
|
|
|
|
@ -90,23 +90,27 @@ void WebhookActor::resolve_ip_address() {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool future_created = false;
|
|
|
|
is_ip_address_being_resolved_ = true;
|
|
|
|
if (future_ip_address_.empty()) {
|
|
|
|
auto promise = td::PromiseCreator::lambda([actor_id = actor_id(this)](td::Result<td::IPAddress> r_ip_address) {
|
|
|
|
td::PromiseActor<td::IPAddress> promise;
|
|
|
|
send_closure(actor_id, &WebhookActor::on_resolved_ip_address, std::move(r_ip_address));
|
|
|
|
init_promise_future(&promise, &future_ip_address_);
|
|
|
|
});
|
|
|
|
future_created = true;
|
|
|
|
|
|
|
|
send_closure(parameters_->get_host_by_name_actor_id_, &td::GetHostByNameActor::run, url_.host_, url_.port_, false,
|
|
|
|
send_closure(parameters_->get_host_by_name_actor_id_, &td::GetHostByNameActor::run, url_.host_, url_.port_, false,
|
|
|
|
td::PromiseCreator::from_promise_actor(std::move(promise)));
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (future_ip_address_.is_ready()) {
|
|
|
|
void WebhookActor::on_resolved_ip_address(td::Result<td::IPAddress> r_ip_address) {
|
|
|
|
|
|
|
|
CHECK(is_ip_address_being_resolved_);
|
|
|
|
|
|
|
|
is_ip_address_being_resolved_ = false;
|
|
|
|
|
|
|
|
|
|
|
|
next_ip_address_resolve_time_ =
|
|
|
|
next_ip_address_resolve_time_ =
|
|
|
|
td::Time::now() + IP_ADDRESS_CACHE_TIME + td::Random::fast(0, IP_ADDRESS_CACHE_TIME / 10);
|
|
|
|
td::Time::now() + IP_ADDRESS_CACHE_TIME + td::Random::fast(0, IP_ADDRESS_CACHE_TIME / 10);
|
|
|
|
relax_wakeup_at(next_ip_address_resolve_time_, "resolve_ip_address");
|
|
|
|
relax_wakeup_at(next_ip_address_resolve_time_, "on_resolved_ip_address");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCOPE_EXIT {
|
|
|
|
|
|
|
|
loop();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
auto r_ip_address = future_ip_address_.move_as_result();
|
|
|
|
|
|
|
|
if (r_ip_address.is_error()) {
|
|
|
|
if (r_ip_address.is_error()) {
|
|
|
|
CHECK(!(r_ip_address.error() == td::Status::Error<td::FutureActor<td::IPAddress>::HANGUP_ERROR_CODE>()));
|
|
|
|
|
|
|
|
return on_error(r_ip_address.move_as_error());
|
|
|
|
return on_error(r_ip_address.move_as_error());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
auto new_ip_address = r_ip_address.move_as_ok();
|
|
|
|
auto new_ip_address = r_ip_address.move_as_ok();
|
|
|
|
@ -122,11 +126,6 @@ void WebhookActor::resolve_ip_address() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
VLOG(webhook) << "IP address was verified";
|
|
|
|
VLOG(webhook) << "IP address was verified";
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (future_created) {
|
|
|
|
|
|
|
|
future_ip_address_.set_event(td::EventCreator::yield(actor_id()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
td::Status WebhookActor::create_connection() {
|
|
|
|
td::Status WebhookActor::create_connection() {
|
|
|
|
@ -605,8 +604,7 @@ void WebhookActor::handle(td::unique_ptr<td::HttpQuery> response) {
|
|
|
|
td::MutableSlice(), std::move(response->args_),
|
|
|
|
td::MutableSlice(), std::move(response->args_),
|
|
|
|
std::move(response->headers_), std::move(response->files_),
|
|
|
|
std::move(response->headers_), std::move(response->files_),
|
|
|
|
parameters_->shared_data_, response->peer_address_, false);
|
|
|
|
parameters_->shared_data_, response->peer_address_, false);
|
|
|
|
auto promised_query =
|
|
|
|
auto promised_query = PromisedQueryPtr(query.release(), PromiseDeleter(td::Promise<td::unique_ptr<Query>>()));
|
|
|
|
PromisedQueryPtr(query.release(), PromiseDeleter(td::PromiseActor<td::unique_ptr<Query>>()));
|
|
|
|
|
|
|
|
send_closure(callback_, &Callback::send, std::move(promised_query));
|
|
|
|
send_closure(callback_, &Callback::send, std::move(promised_query));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
first_error_410_time_ = 0;
|
|
|
|
first_error_410_time_ = 0;
|
|
|
|
|