mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Merge bitcoin/bitcoin#25735: net: remove useless call to IsReachable() from CConnman::Bind()
9cbfe40d8af8567682284890c080b0c3cf434490 net: remove useless call to IsReachable() from CConnman::Bind() (Vasil Dimov) Pull request description: `CConnman::Bind()` is called without `BF_EXPLICIT` only when passed either `0.0.0.0` or `::`. For those addresses `IsReachable()` is always true (regardless of the `-onlynet=` setting!), meaning that the `if` condition never evaluates to true. `IsReachable()` is always true for the "any" IPv4 and IPv6 addresses because `CNetAddr::GetNetwork()` returns `NET_UNROUTABLE` instead of `NET_IPV4` or `NET_IPV6` and the network `NET_UNROUTABLE` is always considered reachable. It follows that `BF_EXPLICIT` is unnecessary, remove it too. ACKs for top commit: naumenkogs: ACK 9cbfe40d8af8567682284890c080b0c3cf434490 aureleoules: ACK 9cbfe40d8af8567682284890c080b0c3cf434490 mzumsande: ACK 9cbfe40d8af8567682284890c080b0c3cf434490 Tree-SHA512: 4e53ee8a73ddd133fd4ff25635135b65e5c19d1fc56fe5c30337406560664616c0adff414dca47602948919f34c81073aae6bfc2871509f3912663d86750928e
This commit is contained in:
parent
012b0b7169
commit
6bf786d168
14
src/net.cpp
14
src/net.cpp
@ -105,13 +105,12 @@ static constexpr auto FEELER_SLEEP_WINDOW{1s};
|
|||||||
/** Used to pass flags to the Bind() function */
|
/** Used to pass flags to the Bind() function */
|
||||||
enum BindFlags {
|
enum BindFlags {
|
||||||
BF_NONE = 0,
|
BF_NONE = 0,
|
||||||
BF_EXPLICIT = (1U << 0),
|
BF_REPORT_ERROR = (1U << 0),
|
||||||
BF_REPORT_ERROR = (1U << 1),
|
|
||||||
/**
|
/**
|
||||||
* Do not call AddLocal() for our special addresses, e.g., for incoming
|
* Do not call AddLocal() for our special addresses, e.g., for incoming
|
||||||
* Tor connections, to prevent gossiping them over the network.
|
* Tor connections, to prevent gossiping them over the network.
|
||||||
*/
|
*/
|
||||||
BF_DONT_ADVERTISE = (1U << 2),
|
BF_DONT_ADVERTISE = (1U << 1),
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef USE_WAKEUP_PIPE
|
#ifndef USE_WAKEUP_PIPE
|
||||||
@ -3329,9 +3328,6 @@ bool CConnman::Bind(const CService& addr_, unsigned int flags, NetPermissionFlag
|
|||||||
{
|
{
|
||||||
const CService addr{MaybeFlipIPv6toCJDNS(addr_)};
|
const CService addr{MaybeFlipIPv6toCJDNS(addr_)};
|
||||||
|
|
||||||
if (!(flags & BF_EXPLICIT) && !IsReachable(addr)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bilingual_str strError;
|
bilingual_str strError;
|
||||||
if (!BindListenPort(addr, strError, permissions)) {
|
if (!BindListenPort(addr, strError, permissions)) {
|
||||||
if ((flags & BF_REPORT_ERROR) && clientInterface) {
|
if ((flags & BF_REPORT_ERROR) && clientInterface) {
|
||||||
@ -3351,13 +3347,13 @@ bool CConnman::InitBinds(const Options& options)
|
|||||||
{
|
{
|
||||||
bool fBound = false;
|
bool fBound = false;
|
||||||
for (const auto& addrBind : options.vBinds) {
|
for (const auto& addrBind : options.vBinds) {
|
||||||
fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR), NetPermissionFlags::None);
|
fBound |= Bind(addrBind, BF_REPORT_ERROR, NetPermissionFlags::None);
|
||||||
}
|
}
|
||||||
for (const auto& addrBind : options.vWhiteBinds) {
|
for (const auto& addrBind : options.vWhiteBinds) {
|
||||||
fBound |= Bind(addrBind.m_service, (BF_EXPLICIT | BF_REPORT_ERROR), addrBind.m_flags);
|
fBound |= Bind(addrBind.m_service, BF_REPORT_ERROR, addrBind.m_flags);
|
||||||
}
|
}
|
||||||
for (const auto& addr_bind : options.onion_binds) {
|
for (const auto& addr_bind : options.onion_binds) {
|
||||||
fBound |= Bind(addr_bind, BF_EXPLICIT | BF_DONT_ADVERTISE, NetPermissionFlags::None);
|
fBound |= Bind(addr_bind, BF_DONT_ADVERTISE, NetPermissionFlags::None);
|
||||||
}
|
}
|
||||||
if (options.bind_on_any) {
|
if (options.bind_on_any) {
|
||||||
struct in_addr inaddr_any;
|
struct in_addr inaddr_any;
|
||||||
|
Loading…
Reference in New Issue
Block a user