From 6423c8175fad3163c10ffdb49e0df48e4e4931f1 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Mon, 1 Mar 2021 21:35:28 +0100 Subject: p2p, refactor: pass and use uint16_t CService::port as uint16_t --- src/util/strencodings.cpp | 3 ++- src/util/strencodings.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/util') diff --git a/src/util/strencodings.cpp b/src/util/strencodings.cpp index f3d54a2ac9..e9d85c4c30 100644 --- a/src/util/strencodings.cpp +++ b/src/util/strencodings.cpp @@ -107,7 +107,8 @@ std::vector ParseHex(const std::string& str) return ParseHex(str.c_str()); } -void SplitHostPort(std::string in, int &portOut, std::string &hostOut) { +void SplitHostPort(std::string in, uint16_t& portOut, std::string& hostOut) +{ size_t colon = in.find_last_of(':'); // if a : is found, and it either follows a [...], or no other : is in the string, treat it as port separator bool fHaveColon = colon != in.npos; diff --git a/src/util/strencodings.h b/src/util/strencodings.h index 98379e9138..a450b30ca2 100644 --- a/src/util/strencodings.h +++ b/src/util/strencodings.h @@ -65,7 +65,7 @@ std::string EncodeBase32(Span input, bool pad = true); */ std::string EncodeBase32(const std::string& str, bool pad = true); -void SplitHostPort(std::string in, int& portOut, std::string& hostOut); +void SplitHostPort(std::string in, uint16_t& portOut, std::string& hostOut); int64_t atoi64(const std::string& str); int atoi(const std::string& str); -- cgit v1.2.3