mirror of
https://github.com/monero-project/monero.git
synced 2026-01-24 13:24:22 +01:00
p2p: fix exclusive node DNS resolution for certain hosts
Fixes #8633. The function `append_net_address` did not parse hostname + port addresses (e.g. `bar:29080`) correctly if the hostname did not contain a `'.'` character. @vtnerd comments 1 clear up 2nd conditional statement
This commit is contained in:
@@ -38,7 +38,7 @@ namespace net
|
||||
{
|
||||
void get_network_address_host_and_port(const std::string& address, std::string& host, std::string& port)
|
||||
{
|
||||
// require ipv6 address format "[addr:addr:addr:...:addr]:port"
|
||||
// If IPv6 address format with port "[addr:addr:addr:...:addr]:port"
|
||||
if (address.find(']') != std::string::npos)
|
||||
{
|
||||
host = address.substr(1, address.rfind(']') - 1);
|
||||
@@ -47,6 +47,12 @@ namespace net
|
||||
port = address.substr(address.rfind(':') + 1);
|
||||
}
|
||||
}
|
||||
// Else if IPv6 address format without port e.g. "addr:addr:addr:...:addr"
|
||||
else if (std::count(address.begin(), address.end(), ':') >= 2)
|
||||
{
|
||||
host = address;
|
||||
}
|
||||
// Else IPv4, Tor, I2P address or hostname
|
||||
else
|
||||
{
|
||||
host = address.substr(0, address.rfind(':'));
|
||||
|
||||
Reference in New Issue
Block a user