curl-fuzzer C++ reference
Loading...
Searching...
No Matches
proxy_option_mock_server.h
Go to the documentation of this file.
1/*
2 * Copyright (C) Max Dymond, <cmeister2@gmail.com>, et al.
3 *
4 * SPDX-License-Identifier: curl
5 */
6
9
10#ifndef PROTO_FUZZER_PROXY_OPTION_MOCK_SERVER_H_
11#define PROTO_FUZZER_PROXY_OPTION_MOCK_SERVER_H_
12
13#include <curl/curl.h>
14
15#include <cstddef>
16#include <memory>
17#include <string>
18
19#include "curl_fuzzer.pb.h"
23
24namespace proto_fuzzer {
25
30 public:
31 explicit ProxyOptionMockServer(curl::fuzzer::proto::ProxySocketOptionMode mode);
32 ~ProxyOptionMockServer() override;
33
34 void ObserveState() override;
35
37 ProxyOptionMockServer& operator=(const ProxyOptionMockServer&) = delete;
38
39 void Install(CURL* easy) override;
40
41 const std::string& client_transcript() const;
42
43 protected:
44 std::unique_ptr<MockConnection> CreateConnection() override;
45
46 void ObserveIncomingData(const unsigned char* data, std::size_t size) override;
47
48 void RunLoop(CURLM* multi, CURL* easy, const curl::fuzzer::proto::Scenario& scenario) override;
49
50 private:
51 bool BeginProxyEnvironment();
52 void EndProxyEnvironment();
53
54 static constexpr std::size_t kMaxTranscriptBytes = 64 * 1024;
55
56 curl::fuzzer::proto::ProxySocketOptionMode mode_;
57 bool setup_ok_;
58 bool proxy_environment_active_;
59 bool saved_http_proxy_was_set_;
60 std::string saved_http_proxy_;
61 std::string client_transcript_;
62};
63
67class InterfaceOptionMockServer final : public HappyEyeballsMockServer {
68 public:
69 InterfaceOptionMockServer() = default;
70 ~InterfaceOptionMockServer() override = default;
71
72 InterfaceOptionMockServer(const InterfaceOptionMockServer&) = delete;
73 InterfaceOptionMockServer& operator=(const InterfaceOptionMockServer&) = delete;
74
75 void Install(CURL* easy) override;
76};
77
78} // namespace proto_fuzzer
79
80#endif // PROTO_FUZZER_PROXY_OPTION_MOCK_SERVER_H_
HappyEyeballsMockServer()
Construct an idle peer with no listener or accepted connections.
Receives bytes after any transport decoding.
void Install(CURL *easy) override
Install the inherited owned loopback TCP listener, then require curl to perform its normal INET setup...
MockServer(MultiDrivePolicy drive_policy=MultiDrivePolicy::kPerform)
Construct an idle MockServer with no scripted responses or open peers.
ProxyOptionMockServer(curl::fuzzer::proto::ProxySocketOptionMode mode)
Construct an idle peer for one policy-normalized mode.
void RunLoop(CURLM *multi, CURL *easy, const curl::fuzzer::proto::Scenario &scenario) override
Refuse to perform if the scoped environment or fixed setopts failed.
void ObserveIncomingData(const unsigned char *data, std::size_t size) override
Retain a bounded request transcript for exact routing assertions.
void Install(CURL *easy) override
Install socket callbacks and one fixed routing option.
std::unique_ptr< MockConnection > CreateConnection() override
Attach the transcript observer to a fresh in-process connection.
const std::string & client_transcript() const
~ProxyOptionMockServer() override
Restore process environment after curl has released the easy handle.
void ObserveState() override
Retain protocol outcomes in coverage and introspector builds.
HappyEyeballsMockServer — a loopback peer that lets curl's happy-eyeballs connection filter race seve...
Optional observer for application bytes consumed by mock peers.
MockConnection and MockServer — the in-process peer that feeds canned response bytes to libcurl over ...