diff --git a/ChangeLog b/ChangeLog index b94bd89f4..3c1c6f14b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ + * Fixed bug in URL parser that failed to parse IPv6 addresses + * added peer download rate approximation + * added port filter for outgoing connection (to prevent + triggering firewalls) + * made most parameters configurable via session_settings * added encryption support * added parole mode for peers whose data fails the hash check. * optimized heap usage in piece-picker and web seed downloader. @@ -8,7 +13,7 @@ * added a half-open tcp connection limit that takes all connections in to account, not just peer connections. * added alerts for filtered IPs. - * added support for SOCKS5 proxies and HTTP CONNECT proxies. + * added support for SOCKS4 and 5 proxies and HTTP CONNECT proxies. * fixed proper distributed copies calculation. * added option to use openssl for sha-1 calculations. * optimized the piece picker in the case where a peer is a seed. diff --git a/src/tracker_manager.cpp b/src/tracker_manager.cpp index 7ee8c57ba..4cf83b3ca 100755 --- a/src/tracker_manager.cpp +++ b/src/tracker_manager.cpp @@ -467,8 +467,19 @@ namespace libtorrent ++start; } - std::string::iterator port_pos - = std::find(start, url.end(), ':'); + std::string::iterator port_pos; + + // this is for IPv6 addresses + if (start != url.end() && *start == '[') + { + port_pos = std::find(start, url.end(), ']'); + if (port_pos == url.end()) throw std::runtime_error("invalid hostname syntax"); + port_pos = std::find(port_pos, url.end(), ':'); + } + else + { + port_pos = std::find(start, url.end(), ':'); + } if (port_pos < end) { diff --git a/test/test_primitives.cpp b/test/test_primitives.cpp index 0d64e8fb2..4c0e410be 100644 --- a/test/test_primitives.cpp +++ b/test/test_primitives.cpp @@ -40,6 +40,12 @@ int test_main() TEST_CHECK(parse_url_components("http://host.com/path?foo:bar@foo:") == make_tuple("http", "", "host.com", 80, "/path?foo:bar@foo:")); + TEST_CHECK(parse_url_components("http://192.168.0.1/path/to/file") + == make_tuple("http", "", "192.168.0.1", 80, "/path/to/file")); + + TEST_CHECK(parse_url_components("http://[::1]/path/to/file") + == make_tuple("http", "", "[::1]", 80, "/path/to/file")); + // base64 test vectors from http://www.faqs.org/rfcs/rfc4648.html TEST_CHECK(base64encode("") == "");