From 7a2feba897c29ff71571770bb1e51d0e6e6793f0 Mon Sep 17 00:00:00 2001 From: Amaury Van Bemten Date: Wed, 13 May 2020 10:15:41 +0200 Subject: [PATCH] Surround IPv6 addresses by square braquets in HTTP CONNECT requests --- tdnet/td/net/HttpProxy.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tdnet/td/net/HttpProxy.cpp b/tdnet/td/net/HttpProxy.cpp index 87c34f9b8..ce9a441aa 100644 --- a/tdnet/td/net/HttpProxy.cpp +++ b/tdnet/td/net/HttpProxy.cpp @@ -20,7 +20,13 @@ void HttpProxy::send_connect() { CHECK(state_ == State::SendConnect); state_ = State::WaitConnectResponse; - string host = PSTRING() << ip_address_.get_ip_str() << ':' << ip_address_.get_port(); + string host; + if (ip_address_.is_ipv6()) { + host = PSTRING() << "[" << ip_address_.get_ip_str() << "]" << ':' << ip_address_.get_port(); + } else { + host = PSTRING() << ip_address_.get_ip_str() << ':' << ip_address_.get_port(); + } + string proxy_authorization; if (!username_.empty() || !password_.empty()) { auto userinfo = PSTRING() << username_ << ':' << password_;