diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-07-03 12:51:12 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-07-03 12:51:12 +0100 |
commit | c2ad9caf013a7221022de79515ff2d65b62fa73a (patch) | |
tree | 21a70d6aa57f645ac60e6181f1d4290bd88d32d4 /contrib/epee/include/string_tools.h | |
parent | Merge pull request #870 (diff) | |
download | monero-c2ad9caf013a7221022de79515ff2d65b62fa73a.tar.xz |
allow peers without port
The default port is then used
Diffstat (limited to '')
-rw-r--r-- | contrib/epee/include/string_tools.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h index b973c6d48..b3623298c 100644 --- a/contrib/epee/include/string_tools.h +++ b/contrib/epee/include/string_tools.h @@ -350,19 +350,24 @@ POP_WARNINGS { //parse ip and address std::string::size_type p = addres.find(':'); + std::string ip_str, port_str; if(p == std::string::npos) { - return false; + port = 0; + ip_str = addres; + } + else + { + ip_str = addres.substr(0, p); + port_str = addres.substr(p+1, addres.size()); } - std::string ip_str = addres.substr(0, p); - std::string port_str = addres.substr(p+1, addres.size()); if(!get_ip_int32_from_string(ip, ip_str)) { return false; } - if(!get_xtype_from_string(port, port_str)) + if(p != std::string::npos && !get_xtype_from_string(port, port_str)) { return false; } |