curl-fuzzer C++ reference
Loading...
Searching...
No Matches
socks4_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_SOCKS4_MOCK_SERVER_H_
11#define PROTO_FUZZER_SOCKS4_MOCK_SERVER_H_
12
13#include <cstddef>
14#include <memory>
15#include <string>
16
19
20namespace proto_fuzzer {
21
29 public:
30 ProxyTransportMockServer(curl::fuzzer::proto::SocksProxyMode mode, bool haproxy_protocol);
31 ~ProxyTransportMockServer() override = default;
32
33 void ObserveState() override;
34
36 ProxyTransportMockServer& operator=(const ProxyTransportMockServer&) = delete;
37
38 void Install(CURL* easy) override;
39
40 // Bounded raw client bytes from SOCKS negotiation through tunneled HTTP.
41 // Tests use this to assert exact handshake and HAProxy prefix ordering.
42 const std::string& client_transcript() const;
43
44 protected:
45 std::unique_ptr<MockConnection> CreateConnection() override;
46
47 void ObserveIncomingData(const unsigned char* data, std::size_t size) override;
48
49 bool SupportsRepeatedPollsetProbe() const override;
50
51 private:
52 static constexpr std::size_t kMaxTranscriptBytes = 64 * 1024;
53
54 curl::fuzzer::proto::SocksProxyMode mode_;
55 bool haproxy_protocol_;
56 std::string client_transcript_;
57};
58
59} // namespace proto_fuzzer
60
61#endif // PROTO_FUZZER_SOCKS4_MOCK_SERVER_H_
Receives bytes after any transport decoding.
MockServer(MultiDrivePolicy drive_policy=MultiDrivePolicy::kPerform)
Construct an idle MockServer with no scripted responses or open peers.
const std::string & client_transcript() const
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.
Optional observer for application bytes consumed by mock peers.
MockConnection and MockServer — the in-process peer that feeds canned response bytes to libcurl over ...