|
|
@ -47,12 +47,10 @@ void SplitHostPort(std::string in, int &portOut, std::string &hostOut) { |
|
|
|
bool fBracketed = fHaveColon && (in[0]=='[' && in[colon-1]==']'); // if there is a colon, and in[0]=='[', colon is not 0, so in[colon-1] is safe
|
|
|
|
bool fBracketed = fHaveColon && (in[0]=='[' && in[colon-1]==']'); // if there is a colon, and in[0]=='[', colon is not 0, so in[colon-1] is safe
|
|
|
|
bool fMultiColon = fHaveColon && (in.find_last_of(':',colon-1) != in.npos); |
|
|
|
bool fMultiColon = fHaveColon && (in.find_last_of(':',colon-1) != in.npos); |
|
|
|
if (fHaveColon && (colon==0 || fBracketed || !fMultiColon)) { |
|
|
|
if (fHaveColon && (colon==0 || fBracketed || !fMultiColon)) { |
|
|
|
char *endp = NULL; |
|
|
|
int32_t n; |
|
|
|
int n = strtol(in.c_str() + colon + 1, &endp, 10); |
|
|
|
if (ParseInt32(in.substr(colon + 1), &n) && n > 0 && n < 0x10000) { |
|
|
|
if (endp && *endp == 0 && n >= 0) { |
|
|
|
|
|
|
|
in = in.substr(0, colon); |
|
|
|
in = in.substr(0, colon); |
|
|
|
if (n > 0 && n < 0x10000) |
|
|
|
portOut = n; |
|
|
|
portOut = n; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (in.size()>0 && in[0] == '[' && in[in.size()-1] == ']') |
|
|
|
if (in.size()>0 && in[0] == '[' && in[in.size()-1] == ']') |
|
|
|