Skip to content

Commit 53afa68

Browse files
committed
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`.
1 parent 6e30865 commit 53afa68

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/net.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -269,22 +269,6 @@ std::optional<CService> GetLocalAddrForPeer(CNode& node)
269269
return std::nullopt;
270270
}
271271

272-
/**
273-
* If an IPv6 address belongs to the address range used by the CJDNS network and
274-
* the CJDNS network is reachable (-cjdnsreachable config is set), then change
275-
* the type from NET_IPV6 to NET_CJDNS.
276-
* @param[in] service Address to potentially convert.
277-
* @return a copy of `service` either unmodified or changed to CJDNS.
278-
*/
279-
CService MaybeFlipIPv6toCJDNS(const CService& service)
280-
{
281-
CService ret{service};
282-
if (ret.IsIPv6() && ret.HasCJDNSPrefix() && g_reachable_nets.Contains(NET_CJDNS)) {
283-
ret.m_net = NET_CJDNS;
284-
}
285-
return ret;
286-
}
287-
288272
// learn a new local address
289273
bool AddLocal(const CService& addr_, int nScore)
290274
{

src/net.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ void RemoveLocal(const CService& addr);
166166
bool SeenLocal(const CService& addr);
167167
bool IsLocal(const CService& addr);
168168
CService GetLocalAddress(const CNode& peer);
169-
CService MaybeFlipIPv6toCJDNS(const CService& service);
170-
171169

172170
extern bool fDiscover;
173171
extern bool fListen;

src/netbase.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,3 +774,12 @@ bool IsBadPort(uint16_t port)
774774
}
775775
return false;
776776
}
777+
778+
CService MaybeFlipIPv6toCJDNS(const CService& service)
779+
{
780+
CService ret{service};
781+
if (ret.IsIPv6() && ret.HasCJDNSPrefix() && g_reachable_nets.Contains(NET_CJDNS)) {
782+
ret.m_net = NET_CJDNS;
783+
}
784+
return ret;
785+
}

src/netbase.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,4 +307,13 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
307307
*/
308308
bool IsBadPort(uint16_t port);
309309

310+
/**
311+
* If an IPv6 address belongs to the address range used by the CJDNS network and
312+
* the CJDNS network is reachable (-cjdnsreachable config is set), then change
313+
* the type from NET_IPV6 to NET_CJDNS.
314+
* @param[in] service Address to potentially convert.
315+
* @return a copy of `service` either unmodified or changed to CJDNS.
316+
*/
317+
CService MaybeFlipIPv6toCJDNS(const CService& service);
318+
310319
#endif // BITCOIN_NETBASE_H

0 commit comments

Comments
 (0)