fix: encode ip in network byte order for udp announce (#6126)

This commit is contained in:
Yat Ho
2023-10-18 22:46:57 +08:00
committed by GitHub
parent 0c3f65e1c6
commit c70c49e87b
3 changed files with 40 additions and 19 deletions

View File

@@ -181,13 +181,13 @@ struct tr_address
template<typename OutputIt>
static OutputIt to_compact_ipv4(OutputIt out, in_addr const& addr4)
{
return std::copy_n(reinterpret_cast<std::byte const*>(&addr4), sizeof(addr4), out);
return std::copy_n(reinterpret_cast<std::byte const*>(&addr4.s_addr), sizeof(addr4.s_addr), out);
}
template<typename OutputIt>
static OutputIt to_compact_ipv6(OutputIt out, in6_addr const& addr6)
{
return std::copy_n(reinterpret_cast<std::byte const*>(&addr6), sizeof(addr6), out);
return std::copy_n(reinterpret_cast<std::byte const*>(&addr6.s6_addr), sizeof(addr6.s6_addr), out);
}
template<typename OutputIt>