Remove unused+unmaintained PROXY_HTTPS code.

Bug: none
Change-Id: I09cfe14c2990d25343fd06a6d3bde7d651d7d46c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/342041
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41966}
This commit is contained in:
Tommi 2024-03-21 16:30:10 +01:00 committed by WebRTC LUCI CQ
parent 08848ea04c
commit 81be7b2394
14 changed files with 31 additions and 443 deletions

View file

@ -119,12 +119,6 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateClientTcpSocket(
<< socket->GetError();
}
if (proxy_info.type == PROXY_HTTPS) {
socket =
new AsyncHttpsProxySocket(socket, user_agent, proxy_info.address,
proxy_info.username, proxy_info.password);
}
// Assert that at most one TLS option is used.
int tlsOpts = tcp_options.opts & (PacketSocketFactory::OPT_TLS |
PacketSocketFactory::OPT_TLS_FAKE |

View file

@ -100,12 +100,6 @@ static const SocketAddress kAlternateAddrs[2] = {
static const SocketAddress kIPv6AlternateAddrs[2] = {
SocketAddress("2401:4030:1:2c00:be30:abcd:efab:cdef", 0),
SocketAddress("2601:0:1000:1b03:2e41:38ff:fea6:f2a4", 0)};
// Addresses for HTTP proxy servers.
static const SocketAddress kHttpsProxyAddrs[2] = {
SocketAddress("11.11.11.1", 443), SocketAddress("22.22.22.1", 443)};
// Addresses for SOCKS proxy servers.
static const SocketAddress kSocksProxyAddrs[2] = {
SocketAddress("11.11.11.1", 1080), SocketAddress("22.22.22.1", 1080)};
// Internal addresses for NAT boxes.
static const SocketAddress kNatAddrs[2] = {SocketAddress("192.168.1.1", 0),
SocketAddress("192.168.2.1", 0)};
@ -317,7 +311,6 @@ class P2PTransportChannelTestBase : public ::testing::Test,
BLOCK_UDP, // Firewall, UDP in/out blocked
BLOCK_UDP_AND_INCOMING_TCP, // Firewall, UDP in/out and TCP in blocked
BLOCK_ALL_BUT_OUTGOING_HTTP, // Firewall, only TCP out on 80/443
PROXY_HTTPS, // All traffic through HTTPS proxy
NUM_CONFIGS
};
@ -563,13 +556,6 @@ class P2PTransportChannelTestBase : public ::testing::Test,
GetEndpoint(endpoint)->network_manager_.RemoveInterface(addr);
fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, addr);
}
void SetProxy(int endpoint, rtc::ProxyType type) {
rtc::ProxyInfo info;
info.type = type;
info.address = (type == rtc::PROXY_HTTPS) ? kHttpsProxyAddrs[endpoint]
: kSocksProxyAddrs[endpoint];
GetAllocator(endpoint)->set_proxy("unittest/1.0", info);
}
void SetAllocatorFlags(int endpoint, int flags) {
GetAllocator(endpoint)->set_flags(flags);
}
@ -1165,7 +1151,6 @@ class P2PTransportChannelTest : public P2PTransportChannelTestBase {
case BLOCK_UDP:
case BLOCK_UDP_AND_INCOMING_TCP:
case BLOCK_ALL_BUT_OUTGOING_HTTP:
case PROXY_HTTPS:
AddAddress(endpoint, kPublicAddrs[endpoint]);
// Block all UDP
fw()->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kPublicAddrs[endpoint]);
@ -1181,13 +1166,6 @@ class P2PTransportChannelTest : public P2PTransportChannelTestBase {
SocketAddress(rtc::IPAddress(INADDR_ANY), 443));
fw()->AddRule(false, rtc::FP_TCP, rtc::FD_ANY,
kPublicAddrs[endpoint]);
} else if (config == PROXY_HTTPS) {
// Block all TCP to/from the endpoint except to the proxy server
fw()->AddRule(true, rtc::FP_TCP, kPublicAddrs[endpoint],
kHttpsProxyAddrs[endpoint]);
fw()->AddRule(false, rtc::FP_TCP, rtc::FD_ANY,
kPublicAddrs[endpoint]);
SetProxy(endpoint, rtc::PROXY_HTTPS);
}
break;
default:
@ -1227,33 +1205,30 @@ class P2PTransportChannelMatrixTest : public P2PTransportChannelTest,
// Test matrix. Originator behavior defined by rows, receiever by columns.
// TODO(?): Fix NULLs caused by lack of TCP support in NATSocket.
// TODO(?): Fix NULLs caused by no HTTP proxy support.
// TODO(?): Rearrange rows/columns from best to worst.
const P2PTransportChannelMatrixTest::Result*
P2PTransportChannelMatrixTest::kMatrix[NUM_CONFIGS][NUM_CONFIGS] = {
// OPEN CONE ADDR PORT SYMM 2CON SCON !UDP !TCP HTTP PRXH
// OPEN CONE ADDR PORT SYMM 2CON SCON !UDP !TCP HTTP
/*OP*/
{LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, LTPT, LTPT, LSRS, NULL},
{LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, LTPT, LTPT, LSRS},
/*CO*/
{SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL},
{SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS},
/*AD*/
{SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL},
{SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS},
/*PO*/
{SULU, SUSU, SUSU, SUSU, RUPU, SUSU, RUPU, NULL, NULL, LSRS, NULL},
{SULU, SUSU, SUSU, SUSU, RUPU, SUSU, RUPU, NULL, NULL, LSRS},
/*SY*/
{PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL},
{PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS},
/*2C*/
{SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL},
{SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS},
/*SC*/
{PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL},
{PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS},
/*!U*/
{LTPT, NULL, NULL, NULL, NULL, NULL, NULL, LTPT, LTPT, LSRS, NULL},
{LTPT, NULL, NULL, NULL, NULL, NULL, NULL, LTPT, LTPT, LSRS},
/*!T*/
{PTLT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTRT, LSRS, NULL},
{PTLT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTRT, LSRS},
/*HT*/
{LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, NULL},
/*PR*/
{NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
{LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS},
};
// The actual tests that exercise all the various configurations.
@ -1281,7 +1256,6 @@ const P2PTransportChannelMatrixTest::Result*
P2P_TEST(x, BLOCK_UDP) \
P2P_TEST(x, BLOCK_UDP_AND_INCOMING_TCP) \
P2P_TEST(x, BLOCK_ALL_BUT_OUTGOING_HTTP) \
P2P_TEST(x, PROXY_HTTPS)
P2P_TEST_SET(OPEN)
P2P_TEST_SET(NAT_FULL_CONE)
@ -1293,7 +1267,6 @@ P2P_TEST_SET(NAT_SYMMETRIC_THEN_CONE)
P2P_TEST_SET(BLOCK_UDP)
P2P_TEST_SET(BLOCK_UDP_AND_INCOMING_TCP)
P2P_TEST_SET(BLOCK_ALL_BUT_OUTGOING_HTTP)
P2P_TEST_SET(PROXY_HTTPS)
INSTANTIATE_TEST_SUITE_P(
All,

View file

@ -53,7 +53,6 @@
#include "rtc_base/network.h"
#include "rtc_base/network/received_packet.h"
#include "rtc_base/network/sent_packet.h"
#include "rtc_base/proxy_info.h"
#include "rtc_base/rate_tracker.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/system/rtc_export.h"
@ -326,11 +325,18 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> {
const std::vector<uint16_t>& unknown_types);
void set_proxy(absl::string_view user_agent, const rtc::ProxyInfo& proxy) {
RTC_DCHECK_NOTREACHED();
user_agent_ = std::string(user_agent);
proxy_ = proxy;
}
const std::string& user_agent() override { return user_agent_; }
const rtc::ProxyInfo& proxy() override { return proxy_; }
const std::string& user_agent() override {
RTC_DCHECK_NOTREACHED();
return user_agent_;
}
const rtc::ProxyInfo& proxy() override {
RTC_DCHECK_NOTREACHED();
return proxy_;
}
void EnablePortPackets() override;

View file

@ -29,7 +29,6 @@
#include "rtc_base/checks.h"
#include "rtc_base/helpers.h"
#include "rtc_base/network.h"
#include "rtc_base/proxy_info.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/ssl_certificate.h"
#include "rtc_base/system/rtc_export.h"
@ -463,25 +462,6 @@ class RTC_EXPORT PortAllocator : public sigslot::has_slots<> {
flags_ = flags;
}
// These three methods are deprecated. If connections need to go through a
// proxy, the application should create a BasicPortAllocator given a custom
// PacketSocketFactory that creates proxy sockets.
const std::string& user_agent() const {
CheckRunOnValidThreadIfInitialized();
return agent_;
}
const rtc::ProxyInfo& proxy() const {
CheckRunOnValidThreadIfInitialized();
return proxy_;
}
void set_proxy(absl::string_view agent, const rtc::ProxyInfo& proxy) {
CheckRunOnValidThreadIfInitialized();
agent_ = std::string(agent);
proxy_ = proxy;
}
// Gets/Sets the port range to use when choosing client ports.
int min_port() const {
CheckRunOnValidThreadIfInitialized();
@ -629,8 +609,6 @@ class RTC_EXPORT PortAllocator : public sigslot::has_slots<> {
bool initialized_ = false;
uint32_t flags_;
std::string agent_;
rtc::ProxyInfo proxy_;
int min_port_;
int max_port_;
int max_ipv6_networks_;

View file

@ -154,8 +154,10 @@ class PortInterface {
// The factory used to create the sockets of this port.
virtual rtc::PacketSocketFactory* socket_factory() const = 0;
virtual const std::string& user_agent() = 0;
virtual const rtc::ProxyInfo& proxy() = 0;
[[deprecated("Unsupported function")]] virtual const std::string&
user_agent() = 0;
[[deprecated("Unsupported function")]] virtual const rtc::ProxyInfo&
proxy() = 0;
// Identifies the generation that this port was created in.
virtual uint32_t generation() const = 0;

View file

@ -596,8 +596,7 @@ void TCPConnection::CreateOutgoingTcpSocket() {
tcp_opts.opts = opts;
socket_.reset(port()->socket_factory()->CreateClientTcpSocket(
rtc::SocketAddress(port()->Network()->GetBestIP(), 0),
remote_candidate().address(), port()->proxy(), port()->user_agent(),
tcp_opts));
remote_candidate().address(), rtc::ProxyInfo(), std::string(), tcp_opts));
if (socket_) {
RTC_LOG(LS_VERBOSE) << ToString() << ": Connecting from "
<< socket_->GetLocalAddress().ToSensitiveString()

View file

@ -425,7 +425,7 @@ bool TurnPort::CreateTurnClientSocket() {
tcp_options.tls_cert_verifier = tls_cert_verifier_;
socket_ = socket_factory()->CreateClientTcpSocket(
rtc::SocketAddress(Network()->GetBestIP(), 0), server_address_.address,
proxy(), user_agent(), tcp_options);
rtc::ProxyInfo(), std::string(), tcp_options);
}
if (!socket_) {

View file

@ -937,8 +937,6 @@ void BasicPortAllocatorSession::AddAllocatedPort(Port* port,
port->set_content_name(content_name());
port->set_component(component());
port->set_generation(generation());
if (allocator_->proxy().type != rtc::PROXY_NONE)
port->set_proxy(allocator_->user_agent(), allocator_->proxy());
port->set_send_retransmit_count_attribute(
(flags() & PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE) != 0);

View file

@ -1389,14 +1389,8 @@ rtc_library("dscp") {
rtc_library("proxy_info") {
visibility = [ "*" ]
sources = [
"proxy_info.cc",
"proxy_info.h",
]
deps = [
":crypt_string",
":socket_address",
]
sources = [ "proxy_info.h" ]
deps = []
}
rtc_library("file_rotating_stream") {

View file

@ -414,8 +414,7 @@ HttpAuthResult HttpAuthenticate(absl::string_view challenge,
if (neg) {
const size_t max_steps = 10;
if (++neg->steps >= max_steps) {
RTC_LOG(LS_WARNING) << "AsyncHttpsProxySocket::Authenticate(Negotiate) "
"too many retries";
RTC_LOG(LS_WARNING) << "HttpAuthenticate (Negotiate) too many retries";
return HAR_ERROR;
}
steps = neg->steps;

View file

@ -1,23 +0,0 @@
/*
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "rtc_base/proxy_info.h"
namespace rtc {
const char* ProxyToString(ProxyType proxy) {
const char* const PROXY_NAMES[] = {"none", "https", "socks5", "unknown"};
return PROXY_NAMES[proxy];
}
ProxyInfo::ProxyInfo() : type(PROXY_NONE), autodetect(false) {}
ProxyInfo::~ProxyInfo() = default;
} // namespace rtc

View file

@ -11,28 +11,9 @@
#ifndef RTC_BASE_PROXY_INFO_H_
#define RTC_BASE_PROXY_INFO_H_
#include <string>
#include "rtc_base/crypt_string.h"
#include "rtc_base/socket_address.h"
namespace rtc {
enum ProxyType { PROXY_NONE, PROXY_HTTPS, PROXY_SOCKS5, PROXY_UNKNOWN };
const char* ProxyToString(ProxyType proxy);
struct ProxyInfo {
ProxyType type;
SocketAddress address;
std::string autoconfig_url;
bool autodetect;
std::string bypass_list;
std::string username;
CryptString password;
ProxyInfo();
~ProxyInfo();
};
// TODO(tommi): Remove.
struct ProxyInfo {};
} // namespace rtc

View file

@ -216,257 +216,4 @@ void AsyncSSLSocket::ProcessInput(char* data, size_t* len) {
SignalReadEvent(this);
}
///////////////////////////////////////////////////////////////////////////////
AsyncHttpsProxySocket::AsyncHttpsProxySocket(Socket* socket,
absl::string_view user_agent,
const SocketAddress& proxy,
absl::string_view username,
const CryptString& password)
: BufferedReadAdapter(socket, 1024),
proxy_(proxy),
agent_(user_agent),
user_(username),
pass_(password),
force_connect_(false),
state_(PS_ERROR),
context_(0) {}
AsyncHttpsProxySocket::~AsyncHttpsProxySocket() {
delete context_;
}
int AsyncHttpsProxySocket::Connect(const SocketAddress& addr) {
int ret;
RTC_LOG(LS_VERBOSE) << "AsyncHttpsProxySocket::Connect("
<< proxy_.ToSensitiveString() << ")";
dest_ = addr;
state_ = PS_INIT;
if (ShouldIssueConnect()) {
BufferInput(true);
}
ret = BufferedReadAdapter::Connect(proxy_);
// TODO: Set state_ appropriately if Connect fails.
return ret;
}
SocketAddress AsyncHttpsProxySocket::GetRemoteAddress() const {
return dest_;
}
int AsyncHttpsProxySocket::Close() {
headers_.clear();
state_ = PS_ERROR;
dest_.Clear();
delete context_;
context_ = nullptr;
return BufferedReadAdapter::Close();
}
Socket::ConnState AsyncHttpsProxySocket::GetState() const {
if (state_ < PS_TUNNEL) {
return CS_CONNECTING;
} else if (state_ == PS_TUNNEL) {
return CS_CONNECTED;
} else {
return CS_CLOSED;
}
}
void AsyncHttpsProxySocket::OnConnectEvent(Socket* socket) {
RTC_LOG(LS_VERBOSE) << "AsyncHttpsProxySocket::OnConnectEvent";
if (!ShouldIssueConnect()) {
state_ = PS_TUNNEL;
BufferedReadAdapter::OnConnectEvent(socket);
return;
}
SendRequest();
}
void AsyncHttpsProxySocket::OnCloseEvent(Socket* socket, int err) {
RTC_LOG(LS_VERBOSE) << "AsyncHttpsProxySocket::OnCloseEvent(" << err << ")";
if ((state_ == PS_WAIT_CLOSE) && (err == 0)) {
state_ = PS_ERROR;
Connect(dest_);
} else {
BufferedReadAdapter::OnCloseEvent(socket, err);
}
}
void AsyncHttpsProxySocket::ProcessInput(char* data, size_t* len) {
size_t start = 0;
for (size_t pos = start; state_ < PS_TUNNEL && pos < *len;) {
if (state_ == PS_SKIP_BODY) {
size_t consume = std::min(*len - pos, content_length_);
pos += consume;
start = pos;
content_length_ -= consume;
if (content_length_ == 0) {
EndResponse();
}
continue;
}
if (data[pos++] != '\n')
continue;
size_t length = pos - start - 1;
if ((length > 0) && (data[start + length - 1] == '\r'))
--length;
data[start + length] = 0;
ProcessLine(data + start, length);
start = pos;
}
*len -= start;
if (*len > 0) {
memmove(data, data + start, *len);
}
if (state_ != PS_TUNNEL)
return;
bool remainder = (*len > 0);
BufferInput(false);
SignalConnectEvent(this);
// FIX: if SignalConnect causes the socket to be destroyed, we are in trouble
if (remainder)
SignalReadEvent(this); // TODO: signal this??
}
bool AsyncHttpsProxySocket::ShouldIssueConnect() const {
// TODO: Think about whether a more sophisticated test
// than dest port == 80 is needed.
return force_connect_ || (dest_.port() != 80);
}
void AsyncHttpsProxySocket::SendRequest() {
rtc::StringBuilder ss;
ss << "CONNECT " << dest_.ToString() << " HTTP/1.0\r\n";
ss << "User-Agent: " << agent_ << "\r\n";
ss << "Host: " << dest_.HostAsURIString() << "\r\n";
ss << "Content-Length: 0\r\n";
ss << "Proxy-Connection: Keep-Alive\r\n";
ss << headers_;
ss << "\r\n";
std::string str = ss.str();
DirectSend(str.c_str(), str.size());
state_ = PS_LEADER;
expect_close_ = true;
content_length_ = 0;
headers_.clear();
RTC_LOG(LS_VERBOSE) << "AsyncHttpsProxySocket >> " << str;
}
void AsyncHttpsProxySocket::ProcessLine(char* data, size_t len) {
RTC_LOG(LS_VERBOSE) << "AsyncHttpsProxySocket << " << data;
if (len == 0) {
if (state_ == PS_TUNNEL_HEADERS) {
state_ = PS_TUNNEL;
} else if (state_ == PS_ERROR_HEADERS) {
Error(defer_error_);
return;
} else if (state_ == PS_SKIP_HEADERS) {
if (content_length_) {
state_ = PS_SKIP_BODY;
} else {
EndResponse();
return;
}
} else {
if (!unknown_mechanisms_.empty()) {
RTC_LOG(LS_ERROR) << "Unsupported authentication methods: "
<< unknown_mechanisms_;
}
// Unexpected end of headers
Error(0);
return;
}
} else if (state_ == PS_LEADER) {
unsigned int code;
if (sscanf(data, "HTTP/%*u.%*u %u", &code) != 1) {
Error(0);
return;
}
switch (code) {
case 200:
// connection good!
state_ = PS_TUNNEL_HEADERS;
return;
#if defined(HTTP_STATUS_PROXY_AUTH_REQ) && (HTTP_STATUS_PROXY_AUTH_REQ != 407)
#error Wrong code for HTTP_STATUS_PROXY_AUTH_REQ
#endif
case 407: // HTTP_STATUS_PROXY_AUTH_REQ
state_ = PS_AUTHENTICATE;
return;
default:
defer_error_ = 0;
state_ = PS_ERROR_HEADERS;
return;
}
} else if ((state_ == PS_AUTHENTICATE) &&
absl::StartsWithIgnoreCase(data, "Proxy-Authenticate:")) {
std::string response, auth_method;
switch (HttpAuthenticate(absl::string_view(data + 19, len - 19), proxy_,
"CONNECT", "/", user_, pass_, context_, response,
auth_method)) {
case HAR_IGNORE:
RTC_LOG(LS_VERBOSE) << "Ignoring Proxy-Authenticate: " << auth_method;
if (!unknown_mechanisms_.empty())
unknown_mechanisms_.append(", ");
unknown_mechanisms_.append(auth_method);
break;
case HAR_RESPONSE:
headers_ = "Proxy-Authorization: ";
headers_.append(response);
headers_.append("\r\n");
state_ = PS_SKIP_HEADERS;
unknown_mechanisms_.clear();
break;
case HAR_CREDENTIALS:
defer_error_ = SOCKET_EACCES;
state_ = PS_ERROR_HEADERS;
unknown_mechanisms_.clear();
break;
case HAR_ERROR:
defer_error_ = 0;
state_ = PS_ERROR_HEADERS;
unknown_mechanisms_.clear();
break;
}
} else if (absl::StartsWithIgnoreCase(data, "Content-Length:")) {
content_length_ = strtoul(data + 15, 0, 0);
} else if (absl::StartsWithIgnoreCase(data, "Proxy-Connection: Keep-Alive")) {
expect_close_ = false;
/*
} else if (absl::StartsWithIgnoreCase(data, "Connection: close") {
expect_close_ = true;
*/
}
}
void AsyncHttpsProxySocket::EndResponse() {
if (!expect_close_) {
SendRequest();
return;
}
// No point in waiting for the server to close... let's close now
// TODO: Refactor out PS_WAIT_CLOSE
state_ = PS_WAIT_CLOSE;
BufferedReadAdapter::Close();
OnCloseEvent(this, 0);
}
void AsyncHttpsProxySocket::Error(int error) {
BufferInput(false);
Close();
SetError(error);
SignalCloseEvent(this, error);
}
} // namespace rtc

View file

@ -77,66 +77,6 @@ class AsyncSSLSocket : public BufferedReadAdapter {
void ProcessInput(char* data, size_t* len) override;
};
///////////////////////////////////////////////////////////////////////////////
// Implements a socket adapter that speaks the HTTP/S proxy protocol.
class AsyncHttpsProxySocket : public BufferedReadAdapter {
public:
AsyncHttpsProxySocket(Socket* socket,
absl::string_view user_agent,
const SocketAddress& proxy,
absl::string_view username,
const CryptString& password);
~AsyncHttpsProxySocket() override;
AsyncHttpsProxySocket(const AsyncHttpsProxySocket&) = delete;
AsyncHttpsProxySocket& operator=(const AsyncHttpsProxySocket&) = delete;
// If connect is forced, the adapter will always issue an HTTP CONNECT to the
// target address. Otherwise, it will connect only if the destination port
// is not port 80.
void SetForceConnect(bool force) { force_connect_ = force; }
int Connect(const SocketAddress& addr) override;
SocketAddress GetRemoteAddress() const override;
int Close() override;
ConnState GetState() const override;
protected:
void OnConnectEvent(Socket* socket) override;
void OnCloseEvent(Socket* socket, int err) override;
void ProcessInput(char* data, size_t* len) override;
bool ShouldIssueConnect() const;
void SendRequest();
void ProcessLine(char* data, size_t len);
void EndResponse();
void Error(int error);
private:
SocketAddress proxy_, dest_;
std::string agent_, user_, headers_;
CryptString pass_;
bool force_connect_;
size_t content_length_;
int defer_error_;
bool expect_close_;
enum ProxyState {
PS_INIT,
PS_LEADER,
PS_AUTHENTICATE,
PS_SKIP_HEADERS,
PS_ERROR_HEADERS,
PS_TUNNEL_HEADERS,
PS_SKIP_BODY,
PS_TUNNEL,
PS_WAIT_CLOSE,
PS_ERROR
} state_;
HttpAuthContext* context_;
std::string unknown_mechanisms_;
};
} // namespace rtc
#endif // RTC_BASE_SOCKET_ADAPTERS_H_