mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-17 02:57:33 +02:00
Merge bitcoin/bitcoin#34242: Prepare string and net utils for future HTTP operations
1911db8c6dstring: add LineReader (Matthew Zipkin)ee62405ccetime: implement and test RFC1123 timestamp string (Matthew Zipkin)eea38787b9string: add AsciiCaseInsensitive{KeyEqual, Hash} for unordered map (Matthew Zipkin)4e300df712string: add `base` argument for ToIntegral to operate on hexadecimal (Matthew Zipkin)0b0d9125c1Modernize GetBindAddress() (Matthew Zipkin)a0ca851d26Make GetBindAddress() callable from outside net.cpp (Matthew Zipkin) Pull request description: This is a component of [removing libevent as a dependency of the project](https://github.com/bitcoin/bitcoin/issues/31194). It is the first six commits of #32061 and provides a string-parsing utility (`LineReader`) that is also consumed by #34158. These are the functions that are added / updated for HTTP and Torcontrol: - `GetBindAddress()`: Given a socket, provides the bound address as a CService. Currently used by p2p but moved from `net` to `netbase` so other modules can call it. - `ToIntegral()`: Already used to parse numbers from strings, added new argument `base = 10` so it can also be used to parse hexadecimal integers. HTTP chunked transfer-encoding uses hex-encoded integers to specify payload size: https://datatracker.ietf.org/doc/html/rfc7230.html#section-4.1 - `AsciiCaseInsensitive` comparators: Needed to store HTTP headers in an `unordered_map`. Headers are key-value pairs that are parsed with case-insensitive keys: https://httpwg.org/specs/rfc9110.html#rfc.section.5.1 - `FormatRFC1123DateTime()`: The required datetime format for HTTP headers (e.g. `Fri, 31 May 2024 19:18:04 GMT`) - `LineReader`: Fields in HTTP requests are newline-terminated. This struct is given an input buffer and provides methods to read lines as strings. ACKs for top commit: maflcko: review ACK1911db8c6d👲 furszy: utACK1911db8c6dsedited: ACK1911db8c6dTree-SHA512: bb8d3b7b18f158386fd391df6d377c9f5b181051dc258efbf2a896c42e20417a1b0b0d4637671ebd2829f6bc371daa15775625af989c19ef8aee76118660deff
This commit is contained in:
14
src/net.cpp
14
src/net.cpp
@@ -369,20 +369,6 @@ bool CConnman::CheckIncomingNonce(uint64_t nonce)
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Get the bind address for a socket as CService. */
|
||||
static CService GetBindAddress(const Sock& sock)
|
||||
{
|
||||
CService addr_bind;
|
||||
struct sockaddr_storage sockaddr_bind;
|
||||
socklen_t sockaddr_bind_len = sizeof(sockaddr_bind);
|
||||
if (!sock.GetSockName((struct sockaddr*)&sockaddr_bind, &sockaddr_bind_len)) {
|
||||
addr_bind.SetSockAddr((const struct sockaddr*)&sockaddr_bind, sockaddr_bind_len);
|
||||
} else {
|
||||
LogWarning("getsockname failed\n");
|
||||
}
|
||||
return addr_bind;
|
||||
}
|
||||
|
||||
CNode* CConnman::ConnectNode(CAddress addrConnect,
|
||||
const char* pszDest,
|
||||
bool fCountFailure,
|
||||
|
||||
Reference in New Issue
Block a user