Skip to content

Commit 6d39a0a

Browse files
committed
Added check for v4 address.
1 parent c8b3c09 commit 6d39a0a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

source/base/net/tcp_channel.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,17 @@ std::u16string TcpChannel::peerAddress() const
119119
if (!socket_.is_open())
120120
return std::u16string();
121121

122-
return utf16FromLocal8Bit(socket_.remote_endpoint().address().to_string());
122+
asio::ip::address address = socket_.remote_endpoint().address();
123+
if (address.is_v4())
124+
{
125+
asio::ip::address ipv4_address = address.to_v4();
126+
return utf16FromLocal8Bit(ipv4_address.to_string());
127+
}
128+
else
129+
{
130+
asio::ip::address ipv6_address = address.to_v6();
131+
return utf16FromLocal8Bit(ipv6_address.to_string());
132+
}
123133
}
124134

125135
//--------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)