Make IPAddress::get_ipv6 safe to use.
GitOrigin-RevId: 47d50318abac4231efe63820902ba4d74b6dd03d
This commit is contained in:
parent
fee023c29f
commit
bf963ccadf
@ -110,7 +110,7 @@ void Socks5::send_ip_address() {
|
||||
request += static_cast<char>((ipv4 >> 24) & 255);
|
||||
} else {
|
||||
request += '\x04';
|
||||
request += ip_address_.get_ipv6().str();
|
||||
request += ip_address_.get_ipv6();
|
||||
}
|
||||
auto port = ip_address_.get_port();
|
||||
request += static_cast<char>((port >> 8) & 255);
|
||||
|
@ -267,11 +267,11 @@ uint32 IPAddress::get_ipv4() const {
|
||||
return htonl(ipv4_addr_.sin_addr.s_addr);
|
||||
}
|
||||
|
||||
Slice IPAddress::get_ipv6() const {
|
||||
string IPAddress::get_ipv6() const {
|
||||
static_assert(sizeof(ipv6_addr_.sin6_addr) == 16, "ipv6 size == 16");
|
||||
CHECK(is_valid());
|
||||
CHECK(!is_ipv4());
|
||||
return Slice(ipv6_addr_.sin6_addr.s6_addr, 16);
|
||||
return Slice(ipv6_addr_.sin6_addr.s6_addr, 16).str();
|
||||
}
|
||||
|
||||
IPAddress IPAddress::get_any_addr() const {
|
||||
|
@ -39,7 +39,7 @@ class IPAddress {
|
||||
void set_port(int port);
|
||||
|
||||
uint32 get_ipv4() const;
|
||||
Slice get_ipv6() const;
|
||||
string get_ipv6() const;
|
||||
Slice get_ip_str() const;
|
||||
|
||||
IPAddress get_any_addr() const;
|
||||
|
Loading…
Reference in New Issue
Block a user