Commit eb719e63 authored by hydratim's avatar hydratim

Bug Fix

parent 84da2c7d
......@@ -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 {
......@@ -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];
......@@ -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";
}
......
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