Skip to content

Commit

Permalink
remove support for BEP 17 web seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Sep 2, 2020
1 parent 19e8c2f commit ea183a1
Show file tree
Hide file tree
Showing 41 changed files with 122 additions and 937 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ set(libtorrent_aux_include_files
heterogeneous_queue
http_connection
http_parser
http_seed_connection
invariant_check
instantiate_connection
io
Expand Down Expand Up @@ -327,7 +326,6 @@ set(sources
peer_connection
bt_peer_connection
web_peer_connection
http_seed_connection
peer_connection_handle
instantiate_connection
merkle
Expand Down
1 change: 0 additions & 1 deletion Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,6 @@ SOURCES =
bt_peer_connection
web_connection_base
web_peer_connection
http_seed_connection
peer_connection_handle
i2p_stream
instantiate_connection
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ SOURCES = \
hex.cpp \
http_connection.cpp \
http_parser.cpp \
http_seed_connection.cpp \
http_tracker_connection.cpp \
i2p_stream.cpp \
identify_client.cpp \
Expand Down Expand Up @@ -590,7 +589,6 @@ HEADERS = \
aux_/heterogeneous_queue.hpp \
aux_/http_connection.hpp \
aux_/http_parser.hpp \
aux_/http_seed_connection.hpp \
aux_/instantiate_connection.hpp \
aux_/invariant_check.hpp \
aux_/io.hpp \
Expand Down
3 changes: 0 additions & 3 deletions bindings/python/src/torrent_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ namespace
{
dict d;
d["url"] = i->url;
d["type"] = i->type;
d["auth"] = i->auth;
ret.append(d);
}
Expand All @@ -74,10 +73,8 @@ namespace
for (int i = 0; i < len; i++)
{
dict e = extract<dict>(ws[i]);
int const type = extract<int>(e["type"]);
web_seeds.push_back(web_seed_entry(
extract<std::string>(e["url"])
, static_cast<web_seed_entry::type_t>(type)
, extract<std::string>(e["auth"])));
}
ti.set_web_seeds(web_seeds);
Expand Down
15 changes: 0 additions & 15 deletions bindings/python/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ def test_torrent_parameter(self):
'trackers': ['http://test.com/announce'],
'dht_nodes': [('1.2.3.4', 6881), ('4.3.2.1', 6881)],
'file_priorities': [1, 1],
'http_seeds': ['http://test.com/file3'],
'url_seeds': ['http://test.com/announce-url'],
'peers': [('5.6.7.8', 6881)],
'banned_peers': [('8.7.6.5', 6881)],
Expand All @@ -306,7 +305,6 @@ def test_torrent_parameter(self):
self.assertEqual(trackers[0].get('url'), 'http://test.com/announce')
self.assertEqual(trackers[0].get('tier'), 0)
self.assertEqual(self.h.get_file_priorities(), [1, 1])
self.assertEqual(self.h.http_seeds(), ['http://test.com/file3'])
# url_seeds was already set, test that it did not get overwritten
self.assertEqual(self.h.url_seeds(),
['http://test.com/announce-url/', 'http://test.com/file/'])
Expand Down Expand Up @@ -401,19 +399,6 @@ def test_info_section(self):
self.assertTrue(len(ti.info_section()) != 0)
self.assertTrue(len(ti.hash_for_piece(0)) != 0)

def test_web_seeds(self):
ti = lt.torrent_info('base.torrent')

ws = [{'url': 'http://foo/test', 'auth': '', 'type': 0},
{'url': 'http://bar/test', 'auth': '', 'type': 1}]
ti.set_web_seeds(ws)
web_seeds = ti.web_seeds()
self.assertEqual(len(ws), len(web_seeds))
for i in range(len(web_seeds)):
self.assertEqual(web_seeds[i]["url"], ws[i]["url"])
self.assertEqual(web_seeds[i]["auth"], ws[i]["auth"])
self.assertEqual(web_seeds[i]["type"], ws[i]["type"])

def test_announce_entry(self):
ae = lt.announce_entry('test')
self.assertEqual(ae.url, 'test')
Expand Down
4 changes: 3 additions & 1 deletion docs/gen_reference_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ def trim_define(line):
.replace('TORRENT_ABI_VERSION == 1', '') \
.replace('TORRENT_ABI_VERSION <= 2', '') \
.replace('TORRENT_ABI_VERSION < 3', '') \
.replace('TORRENT_ABI_VERSION < 4', '') \
.replace('||', '').replace('&&', '').replace('(', '').replace(')', '') \
.replace('!', '').replace('\\', '').strip()

Expand Down Expand Up @@ -785,7 +786,8 @@ def consume_ifdef(lno, lines, warn_on_ifdefs=False):
' TORRENT_ASIO_DEBUGGING' in line) or
line == '#if TORRENT_ABI_VERSION == 1' or
line == '#if TORRENT_ABI_VERSION <= 2' or
line == '#if TORRENT_ABI_VERSION < 3'):
line == '#if TORRENT_ABI_VERSION < 3' or
line == '#if TORRENT_ABI_VERSION < 4'):
while lno < len(lines):
line = lines[lno].strip()
lno += 1
Expand Down
1 change: 0 additions & 1 deletion docs/hunspell/libtorrent.dic
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,6 @@ peers6
DNSName
SubjectAltName
SNI
httpseeds
Base16
lsd
xt
Expand Down
4 changes: 0 additions & 4 deletions docs/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,6 @@ The file format is a bencoded dictionary containing the following fields:
| | The URLs are expected to be properly encoded and not contain |
| | any illegal url characters. |
+--------------------------+--------------------------------------------------------------+
| ``httpseeds`` | list of strings. List of HTTP seed URLs used by this torrent.|
| | The URLs are expected to be properly encoded and not contain |
| | any illegal url characters. |
+--------------------------+--------------------------------------------------------------+
| ``trees`` | list. In case this is a v2 (or v1+v2-hybrid) torrent, this |
| | is an optional list containing the merkle tree nodes we know |
| | of so far, for all files. It's a list of dictionaries, one |
Expand Down
4 changes: 0 additions & 4 deletions examples/client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1559,10 +1559,6 @@ alert mask flags:
std::set<std::string> seeds = h.url_seeds();
for (auto const& s : seeds)
h.remove_url_seed(s);

seeds = h.http_seeds();
for (auto const& s : seeds)
h.remove_http_seed(s);
}

if (c == 'D' && h.is_valid())
Expand Down
6 changes: 1 addition & 5 deletions examples/dump_torrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,7 @@ int main(int argc, char const* argv[]) try
}
std::printf("web seeds:\n");
for (auto const& ws : t.web_seeds())
{
std::printf("%s %s\n"
, ws.type == lt::web_seed_entry::url_seed ? "BEP19" : "BEP17"
, ws.url.c_str());
}
std::printf("%s\n", ws.url.c_str());

return 0;
}
Expand Down
8 changes: 4 additions & 4 deletions include/libtorrent/add_torrent_params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ TORRENT_VERSION_NAMESPACE_3
// is set, these will be the _only_ ones to be used. i.e. any web seeds
// found in the .torrent file will be overridden.
//
// http_seeds expects URLs to web servers implementing the original HTTP
// seed specification `BEP 17`_.
//
// url_seeds expects URLs to regular web servers, aka "get right" style,
// URLs are expected to be regular web servers, aka "get right" style,
// specified in `BEP 19`_.
#if TORRENT_ABI_VERSION < 4
TORRENT_DEPRECATED
std::vector<std::string> http_seeds;
#endif
std::vector<std::string> url_seeds;

// peers to add to the torrent, to be tried to be connected to as
Expand Down
2 changes: 1 addition & 1 deletion include/libtorrent/aux_/export.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ see LICENSE file.

#if !defined TORRENT_ABI_VERSION
# ifdef TORRENT_NO_DEPRECATE
# define TORRENT_ABI_VERSION 3
# define TORRENT_ABI_VERSION 4
# else
# define TORRENT_ABI_VERSION 1
# endif
Expand Down
90 changes: 0 additions & 90 deletions include/libtorrent/aux_/http_seed_connection.hpp

This file was deleted.

7 changes: 3 additions & 4 deletions include/libtorrent/aux_/torrent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ namespace aux {
struct web_seed_t : web_seed_entry
{
explicit web_seed_t(web_seed_entry const& wse);
web_seed_t(std::string const& url_, web_seed_entry::type_t type_
web_seed_t(std::string const& url_
, std::string const& auth_ = std::string()
, web_seed_entry::headers_t const& extra_headers_ = web_seed_entry::headers_t());

Expand Down Expand Up @@ -622,20 +622,19 @@ namespace aux {
// add_web_seed won't add duplicates. If we have already added an entry
// with this URL, we'll get back the existing entry
web_seed_t* add_web_seed(std::string const& url
, web_seed_t::type_t type
, std::string const& auth = std::string()
, web_seed_t::headers_t const& extra_headers = web_seed_entry::headers_t()
, web_seed_flag_t flags = {});

void remove_web_seed(std::string const& url, web_seed_t::type_t type);
void remove_web_seed(std::string const& url);
void disconnect_web_seed(peer_connection* p);

void retry_web_seed(peer_connection* p, boost::optional<seconds32> retry = boost::none);

void remove_web_seed_conn(peer_connection* p, error_code const& ec
, operation_t op, disconnect_severity_t error = peer_connection_interface::normal);

std::set<std::string> web_seeds(web_seed_entry::type_t type) const;
std::set<std::string> web_seeds() const;

bool free_upload_slots() const
{ return m_num_uploads < m_max_uploads; }
Expand Down
7 changes: 4 additions & 3 deletions include/libtorrent/create_torrent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,12 @@ namespace libtorrent {
// content as the file of the torrent. For a multi-file torrent, it should point to
// a directory containing a directory with the same name as this torrent, and all the
// files of the torrent in it.
//
// The second function, ``add_http_seed()`` adds an HTTP seed instead.
void add_url_seed(string_view url);

#if TORRENT_ABI_VERSION < 4
TORRENT_DEPRECATED
void add_http_seed(string_view url);
#endif

// This adds a DHT node to the torrent. This especially useful if you're creating a
// tracker less torrent. It can be used by clients to bootstrap their DHT node from.
Expand Down Expand Up @@ -331,7 +333,6 @@ namespace libtorrent {
std::vector<std::pair<std::string, int>> m_urls;

std::vector<std::string> m_url_seeds;
std::vector<std::string> m_http_seeds;

aux::vector<sha1_hash, piece_index_t> m_piece_hash;

Expand Down
5 changes: 5 additions & 0 deletions include/libtorrent/torrent_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,18 @@ namespace aux {
void remove_url_seed(std::string const& url) const;
std::set<std::string> url_seeds() const;

#if TORRENT_ABI_VERSION < 4
// These functions are identical as the ``*_url_seed()`` variants, but
// they operate on `BEP 17`_ web seeds instead of `BEP 19`_.
//
// See http-seeding_ for more information.
TORRENT_DEPRECATED
void add_http_seed(std::string const& url) const;
TORRENT_DEPRECATED
void remove_http_seed(std::string const& url) const;
TORRENT_DEPRECATED
std::set<std::string> http_seeds() const;
#endif

// add the specified extension to this torrent. The ``ext`` argument is
// a function that will be called from within libtorrent's context
Expand Down
Loading

0 comments on commit ea183a1

Please sign in to comment.