Skip to content

Commit

Permalink
Added check for v4 address.
Browse files Browse the repository at this point in the history
  • Loading branch information
dchapyshev committed Nov 11, 2023
1 parent c8b3c09 commit 6d39a0a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion source/base/net/tcp_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,17 @@ std::u16string TcpChannel::peerAddress() const
if (!socket_.is_open())
return std::u16string();

return utf16FromLocal8Bit(socket_.remote_endpoint().address().to_string());
asio::ip::address address = socket_.remote_endpoint().address();
if (address.is_v4())
{
asio::ip::address ipv4_address = address.to_v4();
return utf16FromLocal8Bit(ipv4_address.to_string());
}
else
{
asio::ip::address ipv6_address = address.to_v6();
return utf16FromLocal8Bit(ipv6_address.to_string());
}
}

//--------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 6d39a0a

Please sign in to comment.