Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
netbase_dns_lookup.cpp
Go to the documentation of this file.
1// Copyright (c) 2021-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <netaddress.h>
6#include <netbase.h>
8#include <test/fuzz/fuzz.h>
10
11#include <cstdint>
12#include <string>
13#include <vector>
14
16{
17 FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
19 const unsigned int max_results = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
22
23 auto fuzzed_dns_lookup_function = [&](const std::string&, bool) {
24 std::vector<CNetAddr> resolved_addresses;
27 }
28 return resolved_addresses;
29 };
30
31 {
34 assert(!resolved_address.IsInternal());
35 }
37 }
38 {
40 if (resolved_address.has_value()) {
41 assert(!resolved_address.value().IsInternal());
42 }
43 }
44 {
47 assert(!resolved_service.IsInternal());
48 }
50 }
51 {
53 if (resolved_service.has_value()) {
54 assert(!resolved_service.value().IsInternal());
55 }
56 }
57 {
59 assert(!resolved_service.IsInternal());
60 }
61 {
63 }
64}
Network address.
Definition netaddress.h:113
A combination of a network address (CNetAddr) and a (TCP) port.
Definition netaddress.h:530
std::string ConsumeRandomLengthString(size_t max_length)
#define FUZZ_TARGET(...)
Definition fuzz.h:35
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
Definition fuzz.h:22
CSubNet LookupSubNet(const std::string &subnet_str)
Parse and resolve a specified subnet string into the appropriate internal representation.
Definition netbase.cpp:812
std::vector< CNetAddr > LookupHost(const std::string &name, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function)
Resolve a host string to its corresponding network addresses.
Definition netbase.cpp:173
std::vector< CService > Lookup(const std::string &name, uint16_t portDefault, bool fAllowLookup, unsigned int nMaxSolutions, DNSLookupFn dns_lookup_function)
Resolve a service string to its corresponding service.
Definition netbase.cpp:191
CService LookupNumeric(const std::string &name, uint16_t portDefault, DNSLookupFn dns_lookup_function)
Resolve a service string with a numeric IP to its first corresponding service.
Definition netbase.cpp:216
const char * name
Definition rest.cpp:48
CNetAddr ConsumeNetAddr(FuzzedDataProvider &fuzzed_data_provider, FastRandomContext *rand) noexcept
Create a CNetAddr.
Definition net.cpp:29
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:73
assert(!tx.IsCoinBase())
FuzzedDataProvider & fuzzed_data_provider
Definition fees.cpp:38