/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 | 11.7k | Socks4MockServer::Socks4MockServer(curl::fuzzer::proto::SocksProxyMode mode) : mode_(mode) {} |
17 | | |
18 | 11.7k | void Socks4MockServer::Install(CURL* easy) { |
19 | 11.7k | MockServer::Install(easy); |
20 | | |
21 | | // CONNECT_TO applies to the origin and would replace the hostname that the |
22 | | // SOCKS request is meant to exercise. The numeric proxy cannot require DNS, |
23 | | // while OPENSOCKETFUNCTION still replaces its outbound socket with the |
24 | | // in-process peer. |
25 | 11.7k | static constexpr char kProxyUrl[] = "socks4://127.0.0.1:1080"; |
26 | 11.7k | static constexpr char kProxyUser[] = "fuzz-user"; |
27 | 11.7k | (void)curl_easy_setopt(easy, CURLOPT_CONNECT_TO, nullptr); |
28 | 11.7k | (void)curl_easy_setopt(easy, CURLOPT_PROXY, kProxyUrl); |
29 | 11.7k | (void)curl_easy_setopt( |
30 | 11.7k | easy, CURLOPT_PROXYTYPE, |
31 | 11.7k | static_cast<long>(mode_ == curl::fuzzer::proto::SOCKS_PROXY_SOCKS4A ? CURLPROXY_SOCKS4A : CURLPROXY_SOCKS4)); |
32 | 11.7k | (void)curl_easy_setopt(easy, CURLOPT_NOPROXY, ""); |
33 | 11.7k | (void)curl_easy_setopt(easy, CURLOPT_PROXYUSERNAME, kProxyUser); |
34 | 11.7k | } |
35 | | |
36 | | } // namespace proto_fuzzer |