From c19ab1adbc41a7b08a588de1f41fc2a504e6edfd Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 17 Aug 2018 19:03:07 +0300 Subject: [PATCH] Minor HTTP-proxy fixes. GitOrigin-RevId: 03d1ca116707c358cd1a414046222236ee2d09b4 --- td/mtproto/HttpTransport.cpp | 1 + td/telegram/net/ConnectionCreator.cpp | 6 +++++- td/telegram/net/DcOptionsSet.cpp | 2 +- tdnet/td/net/HttpReader.cpp | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/td/mtproto/HttpTransport.cpp b/td/mtproto/HttpTransport.cpp index ed14d1a2..dfccf286 100644 --- a/td/mtproto/HttpTransport.cpp +++ b/td/mtproto/HttpTransport.cpp @@ -70,6 +70,7 @@ void Transport::write(BufferWriter &&message, bool quick_ack) { auto r_head = hc.finish(); CHECK(r_head.is_ok()); Slice src = r_head.ok(); + // LOG(DEBUG) << src; MutableSlice dst = message.prepare_prepend(); CHECK(dst.size() >= src.size()) << dst.size() << " >= " << src.size(); std::memcpy(dst.end() - src.size(), src.begin(), src.size()); diff --git a/td/telegram/net/ConnectionCreator.cpp b/td/telegram/net/ConnectionCreator.cpp index c08ef0f5..72928b7f 100644 --- a/td/telegram/net/ConnectionCreator.cpp +++ b/td/telegram/net/ConnectionCreator.cpp @@ -631,7 +631,8 @@ void ConnectionCreator::disable_proxy_impl() { void ConnectionCreator::on_proxy_changed(bool from_db) { send_closure(G()->state_manager(), &StateManager::on_proxy, - active_proxy_id_ != 0 && proxies_[active_proxy_id_].type() != Proxy::Type::Mtproto); + active_proxy_id_ != 0 && proxies_[active_proxy_id_].type() != Proxy::Type::Mtproto && + proxies_[active_proxy_id_].type() != Proxy::Type::HttpCaching); if (!from_db) { for (auto &child : children_) { @@ -989,6 +990,7 @@ void ConnectionCreator::client_loop(ClientInfo &client) { extra.stat); if (proxy.use_socks5_proxy() || proxy.use_http_tcp_proxy()) { + VLOG(connections) << "client_loop: create new transparent proxy connection " << extra.debug_str; class Callback : public TransparentProxy::Callback { public: explicit Callback(Promise promise, std::unique_ptr stats_callback) @@ -1036,6 +1038,8 @@ void ConnectionCreator::client_loop(ClientInfo &client) { create_reference(token))}; } } else { + VLOG(connections) << "client_loop: create new direct connection " << extra.debug_str; + ConnectionData data; data.socket_fd = std::move(socket_fd); data.stats_callback = std::move(stats_callback); diff --git a/td/telegram/net/DcOptionsSet.cpp b/td/telegram/net/DcOptionsSet.cpp index e4210768..41b34d00 100644 --- a/td/telegram/net/DcOptionsSet.cpp +++ b/td/telegram/net/DcOptionsSet.cpp @@ -84,7 +84,7 @@ vector DcOptionsSet::find_all_connections(DcId dc_ } if (only_http) { - if (!option.is_obfuscated_tcp_only() && !option.is_static()) { + if (!option.is_obfuscated_tcp_only() && !option.is_static() && (prefer_ipv6 || !option.is_ipv6())) { info.use_http = true; info.stat = &option_stat->http_stat; options.push_back(info); diff --git a/tdnet/td/net/HttpReader.cpp b/tdnet/td/net/HttpReader.cpp index 778d7eae..9ec34178 100644 --- a/tdnet/td/net/HttpReader.cpp +++ b/tdnet/td/net/HttpReader.cpp @@ -666,6 +666,7 @@ Status HttpReader::parse_head(MutableSlice head) { query_->code_ = to_integer(parser.read_till(' ')); parser.skip(' '); query_->reason_ = parser.read_till('\r'); + LOG(DEBUG) << "Receive HTTP response " << query_->code_ << " " << query_->reason_; } else { auto url_version = parser.read_till('\r'); auto space_pos = url_version.rfind(' ');