curl-fuzzer C++ reference
Loading...
Searching...
No Matches
proto_fuzzer::FtpsMockServer Class Referencefinal

Runs FTP's control and passive data exchanges over implicit TLS. More...

#include <ftps_mock_server.h>

Inheritance diagram for proto_fuzzer::FtpsMockServer:
proto_fuzzer::FtpMockServer proto_fuzzer::MockServerBase proto_fuzzer::IncomingDataObserver

Public Member Functions

 FtpsMockServer ()
 Construct the OpenSSL server carrier used by every FTPS scenario.
 ~FtpsMockServer () override
 Release the TLS connections before the carrier-owned server context.
void ObserveState () override
 Retain protocol outcomes in coverage and introspector builds.
void Install (CURL *easy) override
 Install the shared socket callbacks and a stable local trust anchor.
int negotiated_tls_version () const
std::size_t completed_handshake_count () const
std::string negotiated_alpn () const
Public Member Functions inherited from proto_fuzzer::FtpMockServer
 FtpMockServer ()
 Begin without a borrowed protobuf or open socketpairs.
 ~FtpMockServer () override
 Release server-owned descriptors and socketpair peers after curl has returned its client fds.
const std::string & control_transcript () const
 Expose the bounded command capture from the most recent drive so tests can verify FTP states without coupling assertions to curl debug output.
const std::string & uploaded_data () const
 Expose a bounded upload prefix from the most recent drive while continuing to drain all client bytes, so test observability cannot create backpressure.
std::size_t opened_data_connection_count () const
 Report how many bounded data scripts curl assigned to passive or active transfer sockets, rather than how many scripts the protobuf contains.
std::size_t active_pollset_probe_count () const
 Report how many requested zero-timeout multi-poll probes ran during the most recent drive.
Public Member Functions inherited from proto_fuzzer::MockServerBase
virtual ~MockServerBase ()
 Out-of-line destructor so MockConnection can stay forward-declared in the base header (its complete type is only needed where unique_ptr is instantiated for destruction).
virtual void ConfigureRequestData (ScenarioRequestData *request_data)
 Bind protocol-specific work to the request-data callbacks after their per-scenario state has been constructed.
CURLcode DriveScenario (CURL *easy, const curl::fuzzer::proto::Scenario &scenario)
 Run 'scenario' to completion on 'easy': allocate a multi, attach 'easy', delegate protocol-specific work to RunLoop, consume its completion message, and clean up.
virtual CURLcode DriveEasyScenario (CURL *easy, const curl::fuzzer::proto::Scenario &scenario, bool use_events=false)
 Run through the public easy entrypoint when a protocol mock can preload all peer work before curl takes control.
virtual ConnectOnlyRunStats DriveConnectOnlyScenario (CURL *easy, const curl::fuzzer::proto::Scenario &scenario)
 Establish a CONNECT_ONLY transport, then perform bounded direct I/O.
void SetMultiObserver (MultiObserver observer)
 Register an observer invoked with the live multi handle after 'easy' is attached and before the drive loop starts.
MockConnection * connection ()

Protected Member Functions

std::unique_ptr< MockConnection > CreateConnection () override
 Wrap one control or passive-data socketpair endpoint in an OpenSSL acceptor.
bool SupportsActiveMode () const override
 Reject active-mode listener creation.
Protected Member Functions inherited from proto_fuzzer::FtpMockServer
void ReleaseConnections ()
 Close every server-owned transport before the borrowed scenario or a subclass transport disappears.
void ObserveIncomingData (const unsigned char *data, std::size_t size) override
 Retain decoded client bytes for the control parser.
curl_socket_t HandleOpenSocket (curlsocktype purpose=CURLSOCKTYPE_IPCXN, struct curl_sockaddr *address=nullptr) override
 Allocate one control socket followed by a bounded sequence of passive data sockets, or a real listener when CURLOPT_FTPPORT selected active mode.
SocketSetupDisposition GetSocketSetupDisposition (curl_socket_t curlfd, curlsocktype purpose) const override
 Control/passive sockets are connected AF_UNIX pairs, while active FTP needs curl to bind and listen on the real TCP descriptor returned by OpenActiveListener.
void RunLoop (CURLM *multi, CURL *easy, const curl::fuzzer::proto::Scenario &scenario) override
 Alternate curl transitions with immediate peer service until the transfer completes or deterministic idle/operation caps win.
Protected Member Functions inherited from proto_fuzzer::MockServerBase
 MockServerBase (MultiDrivePolicy drive_policy=MultiDrivePolicy::kPerform)
 Construct an empty base instance with a fixed multi-drive policy.
virtual void HandleDetachedMulti (CurlMultiPtr multi)
 Dispose of or retain the multi after its easy handle has been removed.
MultiSocketDriver * multi_socket_driver ()
 Expose the callback state installed for the current socket-action drive.
std::size_t additional_handle_cleanup_count () const
void ResumeResponseIfRequested (CURL *easy)
 Resume receive-side callback output at one bounded drive boundary when the dedicated API plan requested it.
void ApplyPendingBackpressure ()
 Apply the BackpressureConfig cached by DriveScenario to the new connection_.

Additional Inherited Members

Public Types inherited from proto_fuzzer::MockServerBase
using MultiObserver = std::function<void(CURLM*)>
 Callback type used to publish the driving multi handle to observers.
Static Protected Member Functions inherited from proto_fuzzer::MockServerBase
static int WaitOnMultiFdset (CURLM *multi, CURLMcode *rc)
 Wait on curl's fdset with a short timeout.
static void ProbeMultiPollset (CURLM *multi)
 Ask curl to construct and inspect its connection-filter pollset without waiting.
static bool MultiPollsetWantsWrite (CURLM *multi, curl_socket_t socket)
 Inspect one socket's current writable interest through curl's public multi fdset API.
static bool UsesTimedDrive (const curl::fuzzer::proto::Scenario &scenario)
 Treat a non-default BackpressureConfig as an explicit request for the slower, timed drive policy.
Protected Attributes inherited from proto_fuzzer::MockServerBase
std::unique_ptr< MockConnection > connection_
 The per-scenario MockConnection, lazily created by HandleOpenSocket().
int pending_recv_buf_bytes_
 Cached SO_RCVBUF/SO_SNDBUF setting in bytes.
std::size_t pending_drain_limit_
 Cached per-call DrainIncoming byte budget.
MultiSocketDriver * multi_socket_driver_
 Non-owning pointer into DriveScenario's stack.
std::size_t additional_handle_cleanup_count_
 Number of application-created handles, excluding the caller's parent, successfully removed from the current multi and cleaned up.
bool resume_response_
 True only for an API-plan multi drive with its one-shot write callback.
MultiObserver multi_observer_
 Observer receiving the live multi handle at the start of a drive.
Static Protected Attributes inherited from proto_fuzzer::MockServerBase
static constexpr int kMaxDriveIterations = 512
 Hard operation budget for one scenario.
static constexpr int kMaxIdleIterations = 8
 Consecutive no-progress budget for ordinary scenarios.
static constexpr int kMaxTimedIdleIterations = 256
 Explicit backpressure scenarios get a larger idle budget and may use the short timed wait above.

Detailed Description

Runs FTP's control and passive data exchanges over implicit TLS.

FTPS differs from FTP only in transport setup: curl establishes TLS immediately after the control TCP connection and, after PBSZ/PROT, wraps each passive data connection as well. This peer inherits the command-aware parser, channel bookkeeping, and bounded drive loop, replacing only the connection factory and trust installation. Both the control connection and every passive data channel are therefore real OpenSSL carriers.

Active mode (PORT/EPRT) is deliberately unsupported. Its data connection is a real TCP socket that the FTP server dials into curl's listener, while this harness only knows how to wrap socketpairs. The target policy removes CURLOPT_FTPPORT from FTPS scenarios, and SupportsActiveMode() makes any direct caller fail the data socket request boundedly rather than silently downgrade to plaintext.

FTPS handshakes carry no ALPN extension. The carrier is constructed with its closed HTTP/1.1 default, but OpenSSL only invokes the selector when the client offers ALPN, so curl negotiates no application protocol here.

Definition at line 44 of file ftps_mock_server.h.

Constructor & Destructor Documentation

◆ FtpsMockServer()

proto_fuzzer::FtpsMockServer::FtpsMockServer ( )

Construct the OpenSSL server carrier used by every FTPS scenario.

FTP sends no ALPN extension, so the closed HTTP/1.1 default is never selected and each control or data handshake completes without an application protocol.

Definition at line 24 of file ftps_mock_server.cc.

◆ ~FtpsMockServer()

proto_fuzzer::FtpsMockServer::~FtpsMockServer ( )
override

Release the TLS connections before the carrier-owned server context.

The inherited FTP peer owns both the control and passive data connections, so resetting only the base's generic connection would leave their SSL objects alive past this transport's lifetime.

Definition at line 30 of file ftps_mock_server.cc.

Member Function Documentation

◆ completed_handshake_count()

std::size_t proto_fuzzer::FtpsMockServer::completed_handshake_count ( ) const
Returns
Number of control and data connections that completed TLS negotiation.

Definition at line 59 of file ftps_mock_server.cc.

◆ CreateConnection()

std::unique_ptr< MockConnection > proto_fuzzer::FtpsMockServer::CreateConnection ( )
overrideprotectedvirtual

Wrap one control or passive-data socketpair endpoint in an OpenSSL acceptor.

The inherited FTP loop advances each handshake and then parses only decrypted control replies or drains decrypted upload bytes.

Returns
Newly allocated nonblocking TLS connection.

Reimplemented from proto_fuzzer::FtpMockServer.

Definition at line 46 of file ftps_mock_server.cc.

◆ Install()

void proto_fuzzer::FtpsMockServer::Install ( CURL * easy)
overridevirtual

Install the shared socket callbacks and a stable local trust anchor.

Curl copies the blob descriptor during setopt and borrows the inline certificate bytes, whose program lifetime safely exceeds every easy handle. Scenario options run afterwards and can still disable verification.

Parameters
easyEasy handle that will initiate the FTPS control connection.

Reimplemented from proto_fuzzer::MockServerBase.

Definition at line 37 of file ftps_mock_server.cc.

◆ negotiated_alpn()

std::string proto_fuzzer::FtpsMockServer::negotiated_alpn ( ) const
Returns
ALPN protocol selected by curl, or an empty string when absent.

Definition at line 62 of file ftps_mock_server.cc.

◆ negotiated_tls_version()

int proto_fuzzer::FtpsMockServer::negotiated_tls_version ( ) const
Returns
Protocol version selected by the most recent handshake, or zero.

Definition at line 55 of file ftps_mock_server.cc.

◆ SupportsActiveMode()

bool proto_fuzzer::FtpsMockServer::SupportsActiveMode ( ) const
overrideprotectedvirtual

Reject active-mode listener creation.

FTPS data channels must carry TLS, but curl's PORT/EPRT path expects a real loopback TCP socket that this peer cannot wrap; the lane therefore stays on EPSV/PASV.

Returns
false for every FTPS drive.

Reimplemented from proto_fuzzer::FtpMockServer.

Definition at line 52 of file ftps_mock_server.cc.


The documentation for this class was generated from the following files: