Commit d5cd9f25 authored by hydratim's avatar hydratim

Bug Fix

parent a32b5db1
...@@ -97,7 +97,7 @@ Ipv6::toString() const { ...@@ -97,7 +97,7 @@ Ipv6::toString() const {
inet_ntop(AF_INET6, &addr, buff6, INET6_ADDRSTRLEN); 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 { void Ipv6::toNetwork(in6_addr *addr6) const {
...@@ -196,7 +196,8 @@ Address::init(const std::string& addr) { ...@@ -196,7 +196,8 @@ Address::init(const std::string& addr) {
unsigned long s_pos = addr.find('['); unsigned long s_pos = addr.find('[');
if (pos != std::string::npos && s_pos != std::string::npos) { if (pos != std::string::npos && s_pos != std::string::npos) {
//IPv6 address //IPv6 address
host_ = addr.substr(s_pos, pos+1); host_ = addr.substr(s_pos+1, pos-1);
family_ = AF_INET6;
try { try {
in6_addr addr6; in6_addr addr6;
char buff6[INET6_ADDRSTRLEN+1]; char buff6[INET6_ADDRSTRLEN+1];
...@@ -212,6 +213,7 @@ Address::init(const std::string& addr) { ...@@ -212,6 +213,7 @@ Address::init(const std::string& addr) {
if (pos == std::string::npos) if (pos == std::string::npos)
throw std::invalid_argument("Invalid address"); throw std::invalid_argument("Invalid address");
host_ = addr.substr(0, pos); host_ = addr.substr(0, pos);
family_ = AF_INET;
if (host_ == "*") { if (host_ == "*") {
host_ = "0.0.0.0"; host_ = "0.0.0.0";
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment