mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
net: move MaybeFlipIPv6toCJDNS() from net to netbase
It need not be in the `net` module and we need to call it from `LookupSubNet()`, thus move it to `netbase`.
This commit is contained in:
parent
6e308651c4
commit
53afa68026
4 changed files with 18 additions and 18 deletions
16
src/net.cpp
16
src/net.cpp
|
@ -269,22 +269,6 @@ std::optional<CService> GetLocalAddrForPeer(CNode& node)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* If an IPv6 address belongs to the address range used by the CJDNS network and
|
|
||||||
* the CJDNS network is reachable (-cjdnsreachable config is set), then change
|
|
||||||
* the type from NET_IPV6 to NET_CJDNS.
|
|
||||||
* @param[in] service Address to potentially convert.
|
|
||||||
* @return a copy of `service` either unmodified or changed to CJDNS.
|
|
||||||
*/
|
|
||||||
CService MaybeFlipIPv6toCJDNS(const CService& service)
|
|
||||||
{
|
|
||||||
CService ret{service};
|
|
||||||
if (ret.IsIPv6() && ret.HasCJDNSPrefix() && g_reachable_nets.Contains(NET_CJDNS)) {
|
|
||||||
ret.m_net = NET_CJDNS;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// learn a new local address
|
// learn a new local address
|
||||||
bool AddLocal(const CService& addr_, int nScore)
|
bool AddLocal(const CService& addr_, int nScore)
|
||||||
{
|
{
|
||||||
|
|
|
@ -166,8 +166,6 @@ void RemoveLocal(const CService& addr);
|
||||||
bool SeenLocal(const CService& addr);
|
bool SeenLocal(const CService& addr);
|
||||||
bool IsLocal(const CService& addr);
|
bool IsLocal(const CService& addr);
|
||||||
CService GetLocalAddress(const CNode& peer);
|
CService GetLocalAddress(const CNode& peer);
|
||||||
CService MaybeFlipIPv6toCJDNS(const CService& service);
|
|
||||||
|
|
||||||
|
|
||||||
extern bool fDiscover;
|
extern bool fDiscover;
|
||||||
extern bool fListen;
|
extern bool fListen;
|
||||||
|
|
|
@ -774,3 +774,12 @@ bool IsBadPort(uint16_t port)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CService MaybeFlipIPv6toCJDNS(const CService& service)
|
||||||
|
{
|
||||||
|
CService ret{service};
|
||||||
|
if (ret.IsIPv6() && ret.HasCJDNSPrefix() && g_reachable_nets.Contains(NET_CJDNS)) {
|
||||||
|
ret.m_net = NET_CJDNS;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
@ -307,4 +307,13 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
|
||||||
*/
|
*/
|
||||||
bool IsBadPort(uint16_t port);
|
bool IsBadPort(uint16_t port);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If an IPv6 address belongs to the address range used by the CJDNS network and
|
||||||
|
* the CJDNS network is reachable (-cjdnsreachable config is set), then change
|
||||||
|
* the type from NET_IPV6 to NET_CJDNS.
|
||||||
|
* @param[in] service Address to potentially convert.
|
||||||
|
* @return a copy of `service` either unmodified or changed to CJDNS.
|
||||||
|
*/
|
||||||
|
CService MaybeFlipIPv6toCJDNS(const CService& service);
|
||||||
|
|
||||||
#endif // BITCOIN_NETBASE_H
|
#endif // BITCOIN_NETBASE_H
|
||||||
|
|
Loading…
Reference in a new issue