Coverage Report

Created: 2026-10-15 06:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/curl_fuzzer/proto_fuzzer/socks4_mock_server.cc
Line
Count
Source
1
/*
2
 * Copyright (C) Max Dymond, <cmeister2@gmail.com>, et al.
3
 *
4
 * SPDX-License-Identifier: curl
5
 */
6
7
/// @file
8
/// @brief SOCKS4 proxy option policy layered over the stream mock.
9
10
#include "proto_fuzzer/socks4_mock_server.h"
11
12
#include <curl/curl.h>
13
14
namespace proto_fuzzer {
15
16
/// Select local (SOCKS4) or proxy-side (SOCKS4A) name resolution.
17
/// @param mode Proxy protocol and hostname-resolution mode to install.
18
16.9k
Socks4MockServer::Socks4MockServer(curl::fuzzer::proto::SocksProxyMode mode) : mode_(mode) {}
19
20
/// Install common socket callbacks and the fixed SOCKS proxy policy.
21
/// @param easy Easy handle to configure.
22
16.8k
void Socks4MockServer::Install(CURL* easy) {
23
16.8k
  MockServer::Install(easy);
24
25
  // CONNECT_TO applies to the origin and would replace the hostname that the
26
  // SOCKS request is meant to exercise. The numeric proxy cannot require DNS,
27
  // while OPENSOCKETFUNCTION still replaces its outbound socket with the
28
  // in-process peer.
29
16.8k
  static constexpr char kProxyUrl[] = "socks4://127.0.0.1:1080";
30
16.8k
  static constexpr char kProxyUser[] = "fuzz-user";
31
16.8k
  (void)curl_easy_setopt(easy, CURLOPT_CONNECT_TO, nullptr);
32
16.8k
  (void)curl_easy_setopt(easy, CURLOPT_PROXY, kProxyUrl);
33
16.8k
  (void)curl_easy_setopt(
34
16.8k
      easy, CURLOPT_PROXYTYPE,
35
16.8k
      static_cast<long>(mode_ == curl::fuzzer::proto::SOCKS_PROXY_SOCKS4A ? CURLPROXY_SOCKS4A : CURLPROXY_SOCKS4));
36
16.8k
  (void)curl_easy_setopt(easy, CURLOPT_NOPROXY, "");
37
16.8k
  (void)curl_easy_setopt(easy, CURLOPT_PROXYUSERNAME, kProxyUser);
38
16.8k
}
39
40
}  // namespace proto_fuzzer