Skip to content

Commit fb42657

Browse files
committed
Add and use CNetAddr::HasCJDNSPrefix() helper
1 parent 5ba73cd commit fb42657

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ std::optional<CService> GetLocalAddrForPeer(CNode& node)
275275
CService MaybeFlipIPv6toCJDNS(const CService& service)
276276
{
277277
CService ret{service};
278-
if (ret.m_net == NET_IPV6 && ret.m_addr[0] == 0xfc && IsReachable(NET_CJDNS)) {
278+
if (ret.m_net == NET_IPV6 && ret.HasCJDNSPrefix() && IsReachable(NET_CJDNS)) {
279279
ret.m_net = NET_CJDNS;
280280
}
281281
return ret;

src/netaddress.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,7 @@ bool CNetAddr::IsValid() const
450450
return false;
451451
}
452452

453-
// CJDNS addresses always start with 0xfc
454-
if (IsCJDNS() && (m_addr[0] != 0xFC)) {
453+
if (IsCJDNS() && !HasCJDNSPrefix()) {
455454
return false;
456455
}
457456

src/netaddress.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ class CNetAddr
182182
bool IsTor() const;
183183
bool IsI2P() const;
184184
bool IsCJDNS() const;
185+
[[nodiscard]] bool HasCJDNSPrefix() const { return m_addr[0] == 0xfc; }
185186
bool IsLocal() const;
186187
bool IsRoutable() const;
187188
bool IsInternal() const;

0 commit comments

Comments
 (0)