Skip to content

Commit

Permalink
Minor HTTP-proxy fixes.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 03d1ca116707c358cd1a414046222236ee2d09b4
  • Loading branch information
levlam committed Aug 17, 2018
1 parent 25826e2 commit c19ab1a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions td/mtproto/HttpTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
6 changes: 5 additions & 1 deletion td/telegram/net/ConnectionCreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand Down Expand Up @@ -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<ConnectionData> promise, std::unique_ptr<detail::StatsCallback> stats_callback)
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/net/DcOptionsSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ vector<DcOptionsSet::ConnectionInfo> 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);
Expand Down
1 change: 1 addition & 0 deletions tdnet/td/net/HttpReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ Status HttpReader::parse_head(MutableSlice head) {
query_->code_ = to_integer<int32>(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(' ');
Expand Down

0 comments on commit c19ab1a

Please sign in to comment.