# # patch "ChangeLog" # from [c90f0215265ef87f468fd2ebede50e9e62d49446] # to [675c896eda9f69d43763d54be265e7df3903b559] # # patch "configure.ac" # from [6b50b307f85eccc907f7d983675590c3bc18d481] # to [dcf107be42d8d50b00c0abd48f5975eb9076d49c] # # patch "monotone.cc" # from [8cb7a023798adb3cfe759d2030151cba793fa733] # to [a216d78a95be02911e6af6dc98458ff90e917d0c] # # patch "netsync.cc" # from [f5ebf69261757e767cf0da088341cb8decba07bb] # to [de943b9349718066bf634e1c5675efaeed8c8d2a] # # patch "netxx/address.cxx" # from [4cab9d6c49a51edabcc3b74ca48ec0bd085e3dee] # to [3966e013f1371ee30d428e9f11b7b24d46f59d41] # ======================================================================== --- ChangeLog c90f0215265ef87f468fd2ebede50e9e62d49446 +++ ChangeLog 675c896eda9f69d43763d54be265e7df3903b559 @@ -1,5 +1,15 @@ 2005-11-27 Grahame Bowland + * configure.ac: expose --enable-ipv6 in config.h + * monotone.cc (cpp_main): parse IPv6 addresses correctly + in --bind arguments + * netsync.cc (call_server,serve_connections): if USE_IPV6 defined, + create netxx Address instances with ipv6 enabled. + * netxx/address.cxx (parse_uri): parse IPv6 addresses as hostnames + * closes bug #14446 + +2005-11-27 Grahame Bowland + * automate.cc (automate_stdio_read): remove check for EINTR that was breaking win32 build. ======================================================================== --- configure.ac 6b50b307f85eccc907f7d983675590c3bc18d481 +++ configure.ac dcf107be42d8d50b00c0abd48f5975eb9076d49c @@ -327,6 +327,9 @@ ] ) AM_CONDITIONAL(MISSING_INET6, test x"${ac_inet6}" = x"no") +if test x"${ac_inet6}" = xyes; then + AC_DEFINE(USE_IPV6, 1, [Define whether to use IPv6.]) +fi # simple library checks AC_SEARCH_LIBS([dlsym], [dl], AC_DEFINE(USE_DLOPEN)) ======================================================================== --- monotone.cc 8cb7a023798adb3cfe759d2030151cba793fa733 +++ monotone.cc a216d78a95be02911e6af6dc98458ff90e917d0c @@ -462,9 +462,34 @@ case OPT_BIND: { std::string arg(argstr); - size_t colon = arg.find(':'); - std::string addr_part = (colon == std::string::npos ? arg : arg.substr(0, colon)); - std::string port_part = (colon == std::string::npos ? "" : arg.substr(colon+1, arg.size() - colon)); + std::string addr_part, port_part; + size_t l_colon = arg.find(':'); + size_t r_colon = arg.rfind(':'); + + // not an ipv6 address, as that would have at least two colons + if (l_colon == r_colon) + { + addr_part = (r_colon == std::string::npos ? arg : arg.substr(0, r_colon)); + port_part = (r_colon == std::string::npos ? "" : arg.substr(r_colon+1, arg.size() - r_colon)); + } + else + { + // IPv6 addresses have a port specified in the style: [2001:388:0:13::]:80 + size_t squareb = arg.rfind(']'); + if ((arg.find('[') == 0) && (squareb != std::string::npos)) + { + if (squareb < r_colon) + port_part = (r_colon == std::string::npos ? "" : arg.substr(r_colon+1, arg.size() - r_colon)); + else + port_part = ""; + addr_part = (squareb == std::string::npos ? arg.substr(1, arg.size()) : arg.substr(1, squareb-1)); + } + else + { + addr_part = arg; + port_part = ""; + } + } app.bind_address = utf8(addr_part); app.bind_port = utf8(port_part); } ======================================================================== --- netsync.cc f5ebf69261757e767cf0da088341cb8decba07bb +++ netsync.cc de943b9349718066bf634e1c5675efaeed8c8d2a @@ -3057,11 +3057,17 @@ { Netxx::Probe probe; Netxx::Timeout timeout(static_cast(timeout_seconds)), instant(0,1); +#ifdef USE_IPV6 + bool use_ipv6=true; +#else + bool use_ipv6=false; +#endif // FIXME: split into labels and convert to ace here. P(F("connecting to %s\n") % address()); - Netxx::Stream server(address().c_str(), default_port, timeout); + Netxx::Address addr(address().c_str(), default_port, use_ipv6); + Netxx::Stream server(addr, timeout); session sess(role, client_voice, include_pattern, exclude_pattern, app, address(), server.get_socketfd(), timeout); @@ -3342,7 +3348,13 @@ if (!app.bind_port().empty()) default_port = ::atoi(app.bind_port().c_str()); - Netxx::Address addr; +#ifdef USE_IPV6 + bool use_ipv6=true; +#else + bool use_ipv6=false; +#endif + Netxx::Address addr(use_ipv6); + if (!app.bind_address().empty()) addr.add_address(app.bind_address().c_str(), default_port); else ======================================================================== --- netxx/address.cxx 4cab9d6c49a51edabcc3b74ca48ec0bd085e3dee +++ netxx/address.cxx 3966e013f1371ee30d428e9f11b7b24d46f59d41 @@ -186,7 +186,7 @@ return true; } # endif - + // first look for the protocol seperator while (*uri != 0 && *uri != ':') ++uri; @@ -218,6 +218,18 @@ stop_pos = uri; uri = start_pos; + int colon_count = 0; + while (*uri != 0 && uri != stop_pos) { + if (*uri == ':') + colon_count++; + ++uri; + } + if (colon_count > 1) { + // ipv6 hostname + name.assign(start_pos, stop_pos - start_pos); + return true; + } + // check for a port number in the hostname while (*uri != 0 && uri != stop_pos && *uri != ':') ++uri;