From b841860643fb22ae90e52d6d81df185959c59fcc Mon Sep 17 00:00:00 2001 From: arvidn Date: Fri, 9 Mar 2018 12:00:56 +0100 Subject: [PATCH] improve python binding for torrent_handle::connect_peer --- bindings/python/src/torrent_handle.cpp | 6 +++--- bindings/python/test.py | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index 80c7eb52e..c440aa46a 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -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 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)) diff --git a/bindings/python/test.py b/bindings/python/test.py index 13348db0d..1f5b9292c 100644 --- a/bindings/python/test.py +++ b/bindings/python/test.py @@ -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()