Make GetBindAddress() callable from outside net.cpp

The function logic is moved-only from net.cpp to netbase.cpp
and redeclared (as non-static) in netbase.h
This commit is contained in:
Matthew Zipkin
2025-06-23 11:36:01 -07:00
parent aeaa67a9ea
commit a0ca851d26
3 changed files with 16 additions and 14 deletions

View File

@@ -947,3 +947,16 @@ CService MaybeFlipIPv6toCJDNS(const CService& service)
}
return ret;
}
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;
}