improve python binding for torrent_handle::connect_peer

This commit is contained in:
arvidn 2018-03-09 12:00:56 +01:00 committed by Arvid Norberg
parent 05f7a95604
commit b841860643
2 changed files with 7 additions and 3 deletions

View File

@ -339,9 +339,9 @@ namespace
}
}
void connect_peer(torrent_handle& th, tuple ip, int source)
void connect_peer(torrent_handle& th, tuple ip, int source, int flags)
{
th.connect_peer(tuple_to_endpoint(ip), source);
th.connect_peer(tuple_to_endpoint(ip), source, flags);
}
std::vector<pool_file_status> file_status(torrent_handle const& h)
@ -516,7 +516,7 @@ void bind_torrent_handle()
.def("set_ratio", _(&torrent_handle::set_ratio))
.def("save_path", _(&torrent_handle::save_path))
#endif
.def("connect_peer", &connect_peer)
.def("connect_peer", &connect_peer, (arg("ip"), arg("source") = 0, arg("flags") = 0xd))
.def("set_max_uploads", _(&torrent_handle::set_max_uploads))
.def("max_uploads", _(&torrent_handle::max_uploads))
.def("set_max_connections", _(&torrent_handle::set_max_connections))

View File

@ -58,6 +58,10 @@ class test_torrent_handle(unittest.TestCase):
# also test the overload that takes a list of piece->priority mappings
self.h.prioritize_pieces([(0, 1)])
self.assertEqual(self.h.piece_priorities(), [1])
self.h.connect_peer(('127.0.0.1', 6881))
self.h.connect_peer(('127.0.0.2', 6881), source=4)
self.h.connect_peer(('127.0.0.3', 6881), flags=2)
self.h.connect_peer(('127.0.0.4', 6881), flags=2, source=4)
def test_torrent_handle_in_set(self):
self.setup()