Skip to content

Commit

Permalink
fix: Bug in IP resolving (#328)
Browse files Browse the repository at this point in the history
* bugfix

Signed-off-by: xiafeng <[email protected]>

* bugfix

Signed-off-by: xiafeng <[email protected]>

---------

Signed-off-by: xiafeng <[email protected]>
  • Loading branch information
L-Xiafeng authored Oct 8, 2024
1 parent a11c9e0 commit a1ace47
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Utilities/PublicHeader/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ bool ResolveIpv6FromHostname(const std::string& hostname, ipv6_t* addr) {
if (ret == 0) {
for (int i = 0; i < 4; ++i) {
*addr = 0;
uint32_t part = ntohl(*(reinterpret_cast<uint64_t*>(
&ipv6_sockaddr->sin6_addr.s6_addr32[i])));
uint32_t part = ntohl(ipv6_sockaddr->sin6_addr.s6_addr32[i]);
*addr = (*addr << 32) | part;
}
} else
Expand Down Expand Up @@ -278,8 +277,7 @@ bool StrToIpv6(const std::string& ip, ipv6_t* addr) {

*addr = 0;
for (int i = 0; i < 4; ++i) {
uint32_t part =
ntohl(*(reinterpret_cast<uint64_t*>(&ipv6_addr.s6_addr32[i])));
uint32_t part = ntohl(ipv6_addr.s6_addr32[i]);
*addr = (*addr << 32) | part;
}

Expand Down

0 comments on commit a1ace47

Please sign in to comment.