Skip to content

Commit

Permalink
Bug Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hydratim committed Dec 28, 2018
1 parent a32b5db commit d5cd9f2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/common/net.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Ipv6::toString() const {

inet_ntop(AF_INET6, &addr, buff6, INET6_ADDRSTRLEN);

return std::string("[") + std::string(buff6) + std::string("]");
return std::string(buff6);
}

void Ipv6::toNetwork(in6_addr *addr6) const {
Expand Down Expand Up @@ -196,7 +196,8 @@ Address::init(const std::string& addr) {
unsigned long s_pos = addr.find('[');
if (pos != std::string::npos && s_pos != std::string::npos) {
//IPv6 address
host_ = addr.substr(s_pos, pos+1);
host_ = addr.substr(s_pos+1, pos-1);
family_ = AF_INET6;
try {
in6_addr addr6;
char buff6[INET6_ADDRSTRLEN+1];
Expand All @@ -212,6 +213,7 @@ Address::init(const std::string& addr) {
if (pos == std::string::npos)
throw std::invalid_argument("Invalid address");
host_ = addr.substr(0, pos);
family_ = AF_INET;
if (host_ == "*") {
host_ = "0.0.0.0";
}
Expand Down

0 comments on commit d5cd9f2

Please sign in to comment.