18namespace proto_fuzzer {
22long ProxyType(curl::fuzzer::proto::SocksProxyMode mode) {
24 case curl::fuzzer::proto::SOCKS_PROXY_SOCKS4A:
25 return CURLPROXY_SOCKS4A;
26 case curl::fuzzer::proto::SOCKS_PROXY_SOCKS5:
27 return CURLPROXY_SOCKS5;
28 case curl::fuzzer::proto::SOCKS_PROXY_SOCKS5_HOSTNAME:
29 return CURLPROXY_SOCKS5_HOSTNAME;
30 case curl::fuzzer::proto::SOCKS_PROXY_SOCKS4:
32 return CURLPROXY_SOCKS4;
36const char* ProxyUrl(curl::fuzzer::proto::SocksProxyMode mode) {
38 case curl::fuzzer::proto::SOCKS_PROXY_SOCKS4A:
39 return "socks4a://127.0.0.1:1080";
40 case curl::fuzzer::proto::SOCKS_PROXY_SOCKS5:
41 return "socks5://127.0.0.1:1080";
42 case curl::fuzzer::proto::SOCKS_PROXY_SOCKS5_HOSTNAME:
43 return "socks5h://127.0.0.1:1080";
44 case curl::fuzzer::proto::SOCKS_PROXY_SOCKS4:
46 return "socks4://127.0.0.1:1080";
59 : mode_(mode), haproxy_protocol_(haproxy_protocol) {}
65 client_transcript_.clear();
71 static constexpr char kProxyUser[] =
"fuzz-user";
72 static constexpr char kProxyPassword[] =
"fuzz-pass";
73 static constexpr char kHaproxyClientIp[] =
"127.0.0.1";
74 (void)curl_easy_setopt(easy, CURLOPT_CONNECT_TO,
nullptr);
75 (void)curl_easy_setopt(easy, CURLOPT_PROXY, ProxyUrl(mode_));
76 (void)curl_easy_setopt(easy, CURLOPT_PROXYTYPE, ProxyType(mode_));
77 (void)curl_easy_setopt(easy, CURLOPT_NOPROXY,
"");
78 (void)curl_easy_setopt(easy, CURLOPT_PROXYUSERNAME, kProxyUser);
79 (void)curl_easy_setopt(easy, CURLOPT_PROXYPASSWORD, kProxyPassword);
83 (void)curl_easy_setopt(easy, CURLOPT_SOCKS5_AUTH,
static_cast<long>(CURLAUTH_BASIC));
86 (void)curl_easy_setopt(easy, CURLOPT_IPRESOLVE,
static_cast<long>(CURL_IPRESOLVE_V4));
87 (void)curl_easy_setopt(easy, CURLOPT_HAPROXY_CLIENT_IP, haproxy_protocol_ ? kHaproxyClientIp :
nullptr);
88 (void)curl_easy_setopt(easy, CURLOPT_HAPROXYPROTOCOL, haproxy_protocol_ ? 1L : 0L);
97 auto connection = std::make_unique<MockConnection>();
109 if (data ==
nullptr || size == 0 || client_transcript_.size() >= kMaxTranscriptBytes) {
112 const std::size_t remaining = kMaxTranscriptBytes - client_transcript_.size();
113 client_transcript_.append(
reinterpret_cast<const char*
>(data), std::min(size, remaining));
118#if defined(PROTO_FUZZER_OBSERVE_STATE)
121 (void)proxy_observation;
virtual void Install(CURL *easy)
Install the common OPENSOCKETFUNCTION / OPENSOCKETDATA / SOCKOPTFUNCTION callbacks on 'easy'.
MockConnection * connection()
virtual void ObserveState()
Default no-op for peers without protocol-specific observations.
const std::string & client_transcript() const
bool SupportsRepeatedPollsetProbe() const override
void ObserveState() override
Retain protocol outcomes in coverage and introspector builds.
void ObserveIncomingData(const unsigned char *data, std::size_t size) override
Retain a bounded prefix of client bytes for strict integration tests.
ProxyTransportMockServer(curl::fuzzer::proto::SocksProxyMode mode, bool haproxy_protocol)
Select a fixed SOCKS wire version, resolution side, and optional HAProxy prefix.
void Install(CURL *easy) override
Install common socket callbacks and the fixed SOCKS proxy policy.
std::unique_ptr< MockConnection > CreateConnection() override
Create one socketpair peer and attach the raw-byte transcript observer.
Deterministic SOCKS/HAProxy transport for HTTP scenarios.